|
@@ -2,17 +2,15 @@ package com.ruixuan.salesLeads.service.impl;
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
import com.ruixuan.common.core.domain.ResultResponse;
|
|
|
-import com.ruixuan.common.utils.PageUtils;
|
|
|
import com.ruixuan.common.utils.StringUtils;
|
|
|
+import com.ruixuan.common.utils.file.FileTypeUtils;
|
|
|
import com.ruixuan.salesLeads.listener.ImportExcelListener;
|
|
|
import com.ruixuan.salesLeads.mapper.SaleClueInfoMapper;
|
|
|
import com.ruixuan.salesLeads.mapper.SaleQuotaInfoMapper;
|
|
|
-import com.ruixuan.salesLeads.mapper.TestMapper;
|
|
|
import com.ruixuan.salesLeads.pojo.SaleClueInfoPojo;
|
|
|
import com.ruixuan.salesLeads.pojo.SaleQuotaInfoPojo;
|
|
|
-import com.ruixuan.salesLeads.pojo.TestPojo;
|
|
|
import com.ruixuan.salesLeads.service.ISaleClueInfoService;
|
|
|
-import com.ruixuan.salesLeads.service.ITestService;
|
|
|
+import com.ruixuan.salesLeads.utils.CsvImportUtil;
|
|
|
import com.ruixuan.system.domain.SysAreaInfo;
|
|
|
import com.ruixuan.system.domain.SysIndustryInfo;
|
|
|
import com.ruixuan.system.mapper.SysAreaInfoMapper;
|
|
@@ -55,84 +53,120 @@ public class SaleClueInfoServiceImpl implements ISaleClueInfoService {
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * Author: zianY
|
|
|
+ * Description: 销售线索添加
|
|
|
+ * 支持excel 和 csv 文件上传
|
|
|
+ *------------
|
|
|
+ * @param files
|
|
|
+ * @param salesLeadsType 销售线索类型1:50W低潜;2:50W中高潜;3:200W高潜;4:200W-500w;5:500W
|
|
|
+ * @param uploadDate 时间 格式为202205
|
|
|
+ * @param createUserId
|
|
|
+ *------------
|
|
|
+ * Return com.ruixuan.common.core.domain.ResultResponse
|
|
|
+ */
|
|
|
@Override
|
|
|
- public ResultResponse importSaleClueExcel(List<MultipartFile> files, int salesLeadsType, Long uploadDate, Long createUserId) throws Exception{
|
|
|
+ public ResultResponse importSaleExcelOrCsv(List<MultipartFile> files, int salesLeadsType, Long uploadDate, Long createUserId) throws Exception{
|
|
|
|
|
|
|
|
|
- for (MultipartFile file : files) {
|
|
|
- //读取Excel
|
|
|
- EasyExcel.read(file.getInputStream(),null,
|
|
|
- new ImportExcelListener()).sheet().headRowNumber(1).doRead();
|
|
|
-
|
|
|
-
|
|
|
- //结果集
|
|
|
- List<Map<String,String>> dataList = ImportExcelListener.importDataList;
|
|
|
|
|
|
- //头 信息
|
|
|
- //Map<Integer, String> headList = ImportExcelListener.importHeadList;
|
|
|
+ List<Map<String,String>> dataList = new ArrayList<>();
|
|
|
|
|
|
- //log.info("--结果shuju---{}",dataList);
|
|
|
+ for (MultipartFile file : files) {
|
|
|
|
|
|
- //log.info("--结果表头---{}",headList);
|
|
|
+ //文件类型
|
|
|
+ String fileType = FileTypeUtils.gerFileTypeXlsOrCsv(file);
|
|
|
|
|
|
+ if (StringUtils.equals("excel",fileType)){
|
|
|
|
|
|
- List<SaleClueInfoPojo> clueList = new ArrayList<>();
|
|
|
- List<SaleQuotaInfoPojo> quotaList = new ArrayList<>();
|
|
|
- for (Map<String, String> dataMap : dataList) {
|
|
|
- SaleClueInfoPojo clue = new SaleClueInfoPojo();
|
|
|
- SaleQuotaInfoPojo quota = new SaleQuotaInfoPojo();
|
|
|
+ //读取Excel
|
|
|
+ EasyExcel.read(file.getInputStream(),null,
|
|
|
+ new ImportExcelListener()).sheet().headRowNumber(1).doRead();
|
|
|
|
|
|
- clue.setSalesLeadsType(salesLeadsType);
|
|
|
- clue.setSellerId(Long.valueOf(dataMap.get("sellerId")));
|
|
|
- clue.setSellerName(dataMap.get("sellerName"));
|
|
|
- clue.setFans(Long.valueOf(dataMap.get("fans")));
|
|
|
- clue.setTelephone(Long.valueOf(dataMap.get("telephone")));
|
|
|
- clue.setProviderFlag(dataMap.get("providerFlag").equals("否") ? 0 : 1);
|
|
|
- clue.setTransitionFlag(Integer.valueOf(dataMap.get("transitionFlag")));
|
|
|
- clue.setCreateUserId(createUserId);
|
|
|
+ //头 信息
|
|
|
+ //Map<Integer, String> headList = ImportExcelListener.importHeadList;
|
|
|
|
|
|
- //查询行业
|
|
|
- SysIndustryInfo industryInfo = sysIndustryInfoMapper.getIndustryInfoByName(dataMap.get("industryId"));
|
|
|
- clue.setIndustryId(StringUtils.isNull(industryInfo) ? 0 : industryInfo.getId());
|
|
|
+ //结果集
|
|
|
+ dataList = ImportExcelListener.importDataList;
|
|
|
|
|
|
- //根据城市查询 省市id
|
|
|
- SysAreaInfo areaInfo = sysAreaInfoMapper.getAreaInfoByName(dataMap.get("cityId"));
|
|
|
- clue.setProvinceId(areaInfo.getParentCode());
|
|
|
- clue.setCityId(areaInfo.getCode());
|
|
|
+ }
|
|
|
|
|
|
+ if (StringUtils.equals("csv",fileType)){
|
|
|
|
|
|
- quota.setNearlyThirtyDays(dataMap.get("NearlyThirtyDays"));
|
|
|
- quota.setGmvMonth(Long.valueOf(dataMap.get("gmvMonth")));
|
|
|
- quota.setGmv(dataMap.get("gmv"));
|
|
|
+ dataList = CsvImportUtil.readCSV(file);
|
|
|
|
|
|
- quota.setMtdDate(Long.valueOf(dataMap.get("mtdDate")));
|
|
|
- quota.setMtd(dataMap.get("mtd"));
|
|
|
- quota.setCreateUserId(createUserId);
|
|
|
- quota.setSellerId(Long.valueOf(dataMap.get("sellerId")));
|
|
|
+ }
|
|
|
|
|
|
+ //处理数据结果
|
|
|
+ resultData(dataList,salesLeadsType,createUserId);
|
|
|
|
|
|
|
|
|
- clueList.add(clue);
|
|
|
- quotaList.add(quota);
|
|
|
- }
|
|
|
+ //excel 清除监听数据
|
|
|
+ ImportExcelListener.importDataList.clear();
|
|
|
+ ImportExcelListener.importHeadList.clear();
|
|
|
|
|
|
|
|
|
- saleClueInfoMapper.replaceSaleClueInfoBatch(clueList);
|
|
|
- saleQuotaInfoMapper.replaceSaleQuotaInfoBatch(quotaList);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
+ return ResultResponse.successMsg("保存成功",null);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- ImportExcelListener.importDataList.clear();
|
|
|
- ImportExcelListener.importHeadList.clear();
|
|
|
+ /**
|
|
|
+ * 处理销售线索 数据结果
|
|
|
+ * @param dataList
|
|
|
+ * @param salesLeadsType
|
|
|
+ * @param createUserId
|
|
|
+ */
|
|
|
+ public void resultData(List<Map<String,String>> dataList,int salesLeadsType,Long createUserId){
|
|
|
+
|
|
|
+ List<SaleClueInfoPojo> clueList = new ArrayList<>();
|
|
|
+ List<SaleQuotaInfoPojo> quotaList = new ArrayList<>();
|
|
|
+ for (Map<String, String> dataMap : dataList) {
|
|
|
+ SaleClueInfoPojo clue = new SaleClueInfoPojo();
|
|
|
+ SaleQuotaInfoPojo quota = new SaleQuotaInfoPojo();
|
|
|
+
|
|
|
+ clue.setSalesLeadsType(salesLeadsType);
|
|
|
+ clue.setSellerId(Long.valueOf(dataMap.get("sellerId")));
|
|
|
+ clue.setSellerName(dataMap.get("sellerName"));
|
|
|
+ clue.setFans(Long.valueOf(dataMap.get("fans")));
|
|
|
+ clue.setTelephone(Long.valueOf(dataMap.get("telephone")));
|
|
|
+ clue.setProviderFlag(dataMap.get("providerFlag").equals("否") ? 0 : 1);
|
|
|
+ clue.setTransitionFlag(Integer.valueOf(dataMap.get("transitionFlag")));
|
|
|
+ clue.setCreateUserId(createUserId);
|
|
|
+
|
|
|
+ //查询行业
|
|
|
+ SysIndustryInfo industryInfo = sysIndustryInfoMapper.getIndustryInfoByName(dataMap.get("industryId"));
|
|
|
+ clue.setIndustryId(StringUtils.isNull(industryInfo) ? 0 : industryInfo.getId());
|
|
|
+
|
|
|
+ //根据城市查询 省市id
|
|
|
+ SysAreaInfo areaInfo = sysAreaInfoMapper.getAreaInfoByName(dataMap.get("cityId"));
|
|
|
+ clue.setProvinceId(areaInfo.getParentCode());
|
|
|
+ clue.setCityId(areaInfo.getCode());
|
|
|
+
|
|
|
+ quota.setNearlyThirtyDays(dataMap.get("NearlyThirtyDays"));
|
|
|
+ quota.setGmvMonth(Long.valueOf(dataMap.get("gmvMonth")));
|
|
|
+ quota.setGmv(dataMap.get("gmv"));
|
|
|
+
|
|
|
+ quota.setMtdDate(Long.valueOf(dataMap.get("mtdDate")));
|
|
|
+ quota.setMtd(dataMap.get("mtd"));
|
|
|
+ quota.setCreateUserId(createUserId);
|
|
|
+ quota.setSellerId(Long.valueOf(dataMap.get("sellerId")));
|
|
|
+
|
|
|
+ clueList.add(clue);
|
|
|
+ quotaList.add(quota);
|
|
|
+ }
|
|
|
|
|
|
+ //销售线索
|
|
|
+ saleClueInfoMapper.replaceSaleClueInfoBatch(clueList);
|
|
|
+ //线索-额度
|
|
|
+ saleQuotaInfoMapper.replaceSaleQuotaInfoBatch(quotaList);
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- return null;
|
|
|
- }
|
|
|
}
|