|
@@ -42,6 +42,7 @@ import java.lang.reflect.Method;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -370,6 +371,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public HttpRespMsg importData(MultipartFile multipartFile) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
String fileName = multipartFile.getOriginalFilename();
|
|
@@ -429,30 +431,30 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
XSSFCell cell = row.getCell(i);
|
|
|
if(cell!=null){
|
|
|
switch (item.getString("type")){
|
|
|
- case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
- break;
|
|
|
+// case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
+// break;
|
|
|
default:cell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
}
|
|
|
-// if(modelName.equals("inchargerId")){
|
|
|
-// System.out.println("=====");
|
|
|
-// System.out.println(modelName);
|
|
|
-// System.out.println(cell.toString());
|
|
|
-// if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
-// userNameList.add(cell.getStringCellValue());
|
|
|
-// }
|
|
|
-// }
|
|
|
+ if(modelName.equals("inchargerId")){
|
|
|
+ System.out.println("=====");
|
|
|
+ System.out.println(modelName);
|
|
|
+ System.out.println(cell.toString());
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
+ userNameList.add(cell.getStringCellValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
}
|
|
|
-// System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
|
|
|
-// if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
-// respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
-// if(respMsg.code.equals("0")){
|
|
|
-// msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
|
|
|
-// return msg;
|
|
|
-// }
|
|
|
-// }
|
|
|
+ System.out.println("参与搜索的人员列表"+userNameList + userNameList.size());
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1&&userNameList.size()>0){
|
|
|
+ respMsg = wxCorpInfoService.getBatchSearchUserInfo(wxCorpInfo, userNameList,null);
|
|
|
+ if(respMsg.code.equals("0")){
|
|
|
+ msg.setError("姓名为["+String.valueOf(respMsg.data)+"]的人员存在重复,请使用工号!");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ }
|
|
|
List<User> targetUserList= (List<User>) respMsg.data;
|
|
|
//直接忽略空行 从row1开始
|
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
@@ -479,8 +481,8 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
XSSFCell cell = row.getCell(i);
|
|
|
if(cell!=null){
|
|
|
switch (item.getString("type")){
|
|
|
- case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
- break;
|
|
|
+// case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
+// break;
|
|
|
default:cell.setCellType(CellType.STRING);
|
|
|
}
|
|
|
}
|
|
@@ -511,7 +513,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
return msg;
|
|
|
}
|
|
|
}
|
|
|
- }else if(modelName.equals("customLevel")){
|
|
|
+ }else if(modelName.equals("customLevelId")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
Optional<SysDict> first = sysDictOfCustomLevel.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
|
|
|
if(first.isPresent()){
|
|
@@ -520,7 +522,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
throw new Exception("客户级别["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
|
|
|
}
|
|
|
}
|
|
|
- }else if(modelName.equals("clueSources")){
|
|
|
+ }else if(modelName.equals("clueSourcesId")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
Optional<SysDict> first = sysDictOfClueSources.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
|
|
|
if(first.isPresent()){
|
|
@@ -530,7 +532,7 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
throw new Exception("线索来源["+cell.getStringCellValue()+"不存在,请在系统字典中增加");
|
|
|
}
|
|
|
}
|
|
|
- }else if(modelName.equals("customIndustry")){
|
|
|
+ }else if(modelName.equals("customIndustryId")){
|
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
Optional<SysDict> first = sysDictOfCustomIndustry.stream().filter(s -> s.getName().equals(cell.getStringCellValue())).findFirst();
|
|
|
if(first.isPresent()){
|
|
@@ -565,8 +567,65 @@ public class ClueServiceImpl extends ServiceImpl<ClueMapper, Clue> implements Cl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportData(Clue clue) {
|
|
|
- return null;
|
|
|
+ public HttpRespMsg exportData(Clue clue) 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);
|
|
|
+ List<Clue> list1 = getList(clue);
|
|
|
+ for (Clue clue1 : list1) {
|
|
|
+ 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 Clue> aClass = clue1.getClass();
|
|
|
+ String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(clue1)==null?"":aClass.getMethod("get" + targetName).invoke(clue1));
|
|
|
+ if(model.equals("inchargerId")){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1))+"$";
|
|
|
+ }else {
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.add(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String model = target.getString("model");
|
|
|
+ String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
+ Class<? extends Clue> aClass = clue1.getClass();
|
|
|
+ String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(clue1)==null?"":aClass.getMethod("get" + targetName).invoke(clue1));
|
|
|
+ if(model.equals("inchargerId")){
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1))+"$";
|
|
|
+ }else {
|
|
|
+ value = String.valueOf(aClass.getMethod("getInchargerName").invoke(clue1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.add(value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ String fileName="线索表导出_"+ System.currentTimeMillis();
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName,dataList,path);
|
|
|
}
|
|
|
|
|
|
|