|
@@ -1,15 +1,20 @@
|
|
package com.management.platform.controller;
|
|
package com.management.platform.controller;
|
|
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.entity.*;
|
|
import com.management.platform.mapper.BusinessOpportunityMapper;
|
|
import com.management.platform.mapper.BusinessOpportunityMapper;
|
|
|
|
+import com.management.platform.mapper.SysFormMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
import com.management.platform.mapper.UserMapper;
|
|
-import com.management.platform.service.BusinessOpportunityService;
|
|
|
|
-import com.management.platform.service.StageService;
|
|
|
|
-import com.management.platform.service.SysFunctionService;
|
|
|
|
-import com.management.platform.service.TaskService;
|
|
|
|
|
|
+import com.management.platform.service.*;
|
|
|
|
+import com.management.platform.service.impl.ExcelExportServiceImpl;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
@@ -19,10 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.HashMap;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
@@ -35,14 +37,20 @@ import java.util.List;
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/business-opportunity")
|
|
@RequestMapping("/business-opportunity")
|
|
public class BusinessOpportunityController {
|
|
public class BusinessOpportunityController {
|
|
-
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private ExcelExportServiceImpl excelExportService;
|
|
|
|
+ @Resource
|
|
|
|
+ private SysFormMapper sysFormMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private WxCorpInfoService wxCorpInfoService;
|
|
@Resource
|
|
@Resource
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
@Resource
|
|
@Resource
|
|
private SysFunctionService sysFunctionService;
|
|
private SysFunctionService sysFunctionService;
|
|
@Resource
|
|
@Resource
|
|
private StageService stageService;
|
|
private StageService stageService;
|
|
-
|
|
|
|
|
|
+ @Value(value = "${upload.path}")
|
|
|
|
+ private String path;
|
|
@Resource
|
|
@Resource
|
|
private BusinessOpportunityService bOservice;
|
|
private BusinessOpportunityService bOservice;
|
|
@Resource
|
|
@Resource
|
|
@@ -68,8 +76,74 @@ public class BusinessOpportunityController {
|
|
|
|
|
|
|
|
|
|
@RequestMapping("/exportData")
|
|
@RequestMapping("/exportData")
|
|
- public HttpRespMsg exportData(BusinessOpportunity bo) throws Exception {
|
|
|
|
- return bOservice.exportData(bo);
|
|
|
|
|
|
+ public HttpRespMsg exportData(BusinessOpportunity bo ,HttpServletRequest request) throws Exception {
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ SysForm sysForm = sysFormMapper.selectOne(new LambdaQueryWrapper<SysForm>().eq(SysForm::getCompanyId, user.getCompanyId()).eq(SysForm::getCode, "Thread").eq(SysForm::getIsCurrent, 1));
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
|
+ String config = sysForm.getConfig();
|
|
|
|
+ JSONObject configOb = JSON.parseObject(config);
|
|
|
|
+ JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
|
+ JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
|
+ titleList.add(item.getString("label"));
|
|
|
|
+ }
|
|
|
|
+ dataList.add(titleList);
|
|
|
|
+ HttpRespMsg msg = list(bo, request);
|
|
|
|
+ Map<String, Object> msgData = (Map<String, Object>) msg.getData();
|
|
|
|
+ List<BusinessOpportunity> bos = (List<BusinessOpportunity>) msgData.get("record");
|
|
|
|
+ for (BusinessOpportunity bo1 : bos) {
|
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
|
+ JSONObject target = configObJSONArray.getJSONObject(i);
|
|
|
|
+ if(target.getString("type").equals("grid")){
|
|
|
|
+ JSONArray columns = target.getJSONArray("columns");
|
|
|
|
+ for (int i1 = 0; i1 < columns.size(); i1++) {
|
|
|
|
+ JSONObject columnsJSONObject = columns.getJSONObject(i1);
|
|
|
|
+ JSONArray list = columnsJSONObject.getJSONArray("list");
|
|
|
|
+ for (int i2 = 0; i2 < list.size(); i2++) {
|
|
|
|
+ JSONObject object = list.getJSONObject(i2);
|
|
|
|
+ String model = object.getString("model");
|
|
|
|
+ String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
|
+ Class<? extends BusinessOpportunity> aClass = bo1.getClass();
|
|
|
|
+ String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(bo1)==null?"":aClass.getMethod("get" + targetName).invoke(bo1));
|
|
|
|
+ if(model.equals("inchargerId")){
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(bo1))+"$";
|
|
|
|
+ }else {
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(bo1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ item.add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ String model = target.getString("model");
|
|
|
|
+ String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
|
+ Class<? extends BusinessOpportunity> aClass = bo1.getClass();
|
|
|
|
+ String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(bo1)==null?"":aClass.getMethod("get" + targetName).invoke(bo1));
|
|
|
|
+ if(model.equals("inchargerId")){
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(bo1))+"$";
|
|
|
|
+ }else {
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(bo1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(model.equals("contactsId")){
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getContactsName").invoke(bo1))+"$";
|
|
|
|
+ }else {
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getContactsName").invoke(bo1));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ item.add(value);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ dataList.add(item);
|
|
|
|
+ }
|
|
|
|
+ String fileName="商机表导出_"+ System.currentTimeMillis();
|
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|