|
@@ -5,13 +5,16 @@ 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.management.platform.entity.*;
|
|
|
import com.management.platform.mapper.*;
|
|
|
import com.management.platform.service.ContactsService;
|
|
|
import com.management.platform.service.CustomService;
|
|
|
+import com.management.platform.service.WechatUserFollowService;
|
|
|
import com.management.platform.service.WxCorpInfoService;
|
|
|
import com.management.platform.service.impl.ExcelExportServiceImpl;
|
|
|
import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
@@ -22,9 +25,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -56,6 +62,8 @@ public class CustomController {
|
|
|
private BusinessOpportunityMapper businessOpportunityMapper;
|
|
|
@Autowired
|
|
|
private SalesOrderMapper salesOrderMapper;
|
|
|
+ @Autowired
|
|
|
+ private WechatUserFollowService wechatUserFollowService;
|
|
|
|
|
|
|
|
|
@RequestMapping("list")
|
|
@@ -134,63 +142,94 @@ public class CustomController {
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
List<String> titleList=new ArrayList<>();
|
|
|
List<String> modelList=new ArrayList<>();
|
|
|
- for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
- JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
- String type = item.getString("type");
|
|
|
- if (type.equals("grid")){
|
|
|
- JSONArray columns = item.getJSONArray("columns");
|
|
|
- for (int j = 0; j < columns.size(); j++) {
|
|
|
- JSONObject columnsJSONObject = columns.getJSONObject(j);
|
|
|
- JSONArray listJsonArray = columnsJSONObject.getJSONArray("list");
|
|
|
- for (int k = 0; k < listJsonArray.size(); k++) {
|
|
|
- JSONObject listJsonArrayJSONObject = listJsonArray.getJSONObject(k);
|
|
|
- titleList.add(listJsonArrayJSONObject.getString("label"));
|
|
|
- modelList.add(listJsonArrayJSONObject.getString("model"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- titleList.add(item.getString("label"));
|
|
|
- modelList.add(item.getString("model"));
|
|
|
- }
|
|
|
- }
|
|
|
- dataList.add(titleList);
|
|
|
-
|
|
|
HttpRespMsg respMsg = list(custom,request);
|
|
|
Map<String, Object> msgData = (Map<String, Object>) respMsg.getData();
|
|
|
List<Custom> list = (List<Custom>) msgData.get("data");
|
|
|
-
|
|
|
- for (Custom data : list) {
|
|
|
- List<String> item=new ArrayList<>();
|
|
|
- for (int i = 0; i < modelList.size(); i++) {
|
|
|
-
|
|
|
- String model = modelList.get(i);
|
|
|
- String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
- Class<? extends Custom> aClass = data.getClass();
|
|
|
- String value = "";
|
|
|
-
|
|
|
- if(model.equals("inchargerId")){
|
|
|
- if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
- value = "$userName="+String.valueOf(aClass.getMethod("getInchargerName").invoke(data))+"$";
|
|
|
- }else {
|
|
|
- value = String.valueOf(aClass.getMethod("getInchargerName").invoke(data)).equals("null") ? "" :String.valueOf(aClass.getMethod("getInchargerName").invoke(data));
|
|
|
+ if (user.getCompanyId()!=5807) {
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
+ JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
+ String type = item.getString("type");
|
|
|
+ if (type.equals("grid")) {
|
|
|
+ JSONArray columns = item.getJSONArray("columns");
|
|
|
+ for (int j = 0; j < columns.size(); j++) {
|
|
|
+ JSONObject columnsJSONObject = columns.getJSONObject(j);
|
|
|
+ JSONArray listJsonArray = columnsJSONObject.getJSONArray("list");
|
|
|
+ for (int k = 0; k < listJsonArray.size(); k++) {
|
|
|
+ JSONObject listJsonArrayJSONObject = listJsonArray.getJSONObject(k);
|
|
|
+ titleList.add(listJsonArrayJSONObject.getString("label"));
|
|
|
+ modelList.add(listJsonArrayJSONObject.getString("model"));
|
|
|
+ }
|
|
|
}
|
|
|
- }else {
|
|
|
- value= String.valueOf(aClass.getMethod("get" + targetName).invoke(data)==null?"":aClass.getMethod("get" + targetName).invoke(data));
|
|
|
+ } else {
|
|
|
+ titleList.add(item.getString("label"));
|
|
|
+ modelList.add(item.getString("model"));
|
|
|
}
|
|
|
+ }
|
|
|
+ dataList.add(titleList);
|
|
|
+ for (Custom data : list) {
|
|
|
+ List<String> item = new ArrayList<>();
|
|
|
+ for (int i = 0; i < modelList.size(); i++) {
|
|
|
+
|
|
|
+ String model = modelList.get(i);
|
|
|
+ String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
+ Class<? extends Custom> aClass = data.getClass();
|
|
|
+ String value = "";
|
|
|
+
|
|
|
+ if (model.equals("inchargerId")) {
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
+ value = "$userName=" + String.valueOf(aClass.getMethod("getInchargerName").invoke(data)) + "$";
|
|
|
+ } else {
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(data)).equals("null") ? "" : String.valueOf(aClass.getMethod("getInchargerName").invoke(data));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ value = String.valueOf(aClass.getMethod("get" + targetName).invoke(data) == null ? "" : aClass.getMethod("get" + targetName).invoke(data));
|
|
|
+ }
|
|
|
|
|
|
- if(model.equals("clueSourceId")){
|
|
|
- value = String.valueOf(null == aClass.getMethod("getClueSourceValue").invoke(data)?"":aClass.getMethod("getClueSourceValue").invoke(data));
|
|
|
+ if (model.equals("clueSourceId")) {
|
|
|
+ value = String.valueOf(null == aClass.getMethod("getClueSourceValue").invoke(data) ? "" : aClass.getMethod("getClueSourceValue").invoke(data));
|
|
|
+ }
|
|
|
+ if (model.equals("customerLevelId")) {
|
|
|
+ value = String.valueOf(null == aClass.getMethod("getCustomerLevelValue").invoke(data) ? "" : aClass.getMethod("getCustomerLevelValue").invoke(data));
|
|
|
+ }
|
|
|
+ if (model.equals("customerIndustryId")) {
|
|
|
+ value = String.valueOf(null == aClass.getMethod("getCustomerIndustryValue").invoke(data) ? "" : aClass.getMethod("getCustomerIndustryValue").invoke(data));
|
|
|
+ }
|
|
|
+ item.add(value);
|
|
|
}
|
|
|
- if(model.equals("customerLevelId")){
|
|
|
- value = String.valueOf(null == aClass.getMethod("getCustomerLevelValue").invoke(data)?"":aClass.getMethod("getCustomerLevelValue").invoke(data));
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ titleList.add("客户名称");
|
|
|
+ titleList.add("负责人");
|
|
|
+ titleList.add("关注日期");
|
|
|
+ titleList.add("关注时间");
|
|
|
+ dataList.add(titleList);
|
|
|
+ List<WechatUserFollow> userFollows = wechatUserFollowService.list(new QueryWrapper<WechatUserFollow>().eq("is_follow", 1).isNotNull("salesman_id"));
|
|
|
+
|
|
|
+ for (Custom data : list) {
|
|
|
+ List<String> item = new ArrayList<>();
|
|
|
+ item.add(data.getCustomName());
|
|
|
+ if (wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1) {
|
|
|
+ String value = "$userName=" + data.getInchargerName() + "$";
|
|
|
+ item.add(value);
|
|
|
+ } else {
|
|
|
+ String value = data.getInchargerName();
|
|
|
+ item.add(value);
|
|
|
}
|
|
|
- if(model.equals("customerIndustryId")){
|
|
|
- value = String.valueOf(null == aClass.getMethod("getCustomerIndustryValue").invoke(data)?"":aClass.getMethod("getCustomerIndustryValue").invoke(data));
|
|
|
+ Optional<WechatUserFollow> first = userFollows.stream().filter(u -> u.getOpenId() != null && StringUtils.isNotEmpty(data.getCustomName()) && u.getOpenId().equals(data.getCustomName())).findFirst();
|
|
|
+ if (first.isPresent()){
|
|
|
+ LocalDateTime followTime = first.get().getFollowTime();
|
|
|
+ DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");
|
|
|
+ item.add(dateFormatter.format(followTime));
|
|
|
+ item.add(timeFormatter.format(followTime));
|
|
|
+ }else {
|
|
|
+ item.add("");
|
|
|
+ item.add("");
|
|
|
}
|
|
|
- item.add(value);
|
|
|
+ dataList.add(item);
|
|
|
}
|
|
|
- dataList.add(item);
|
|
|
}
|
|
|
String fileName="客户表导出_"+ System.currentTimeMillis();
|
|
|
long endTimeSec = System.currentTimeMillis();
|