|
@@ -3,6 +3,7 @@ package com.management.platform.service.impl;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
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.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -21,6 +22,10 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -75,6 +80,9 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
@Resource
|
|
@Resource
|
|
private ExcelExportServiceImpl excelExportService;
|
|
private ExcelExportServiceImpl excelExportService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private StageMapper stageMapper;
|
|
|
|
+
|
|
@Value(value = "${upload.path}")
|
|
@Value(value = "${upload.path}")
|
|
private String path;
|
|
private String path;
|
|
|
|
|
|
@@ -270,11 +278,24 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
|
|
|
ContactsVo contactsVo = new ContactsVo();
|
|
ContactsVo contactsVo = new ContactsVo();
|
|
Contacts contactsSelect = contactsMapper.selectById(contacts.getId());
|
|
Contacts contactsSelect = contactsMapper.selectById(contacts.getId());
|
|
|
|
+
|
|
|
|
+ String token = String.valueOf(request.getHeader("Token"));
|
|
|
|
+ User user = userMapper.selectById(token);
|
|
|
|
+
|
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("is_active", 1));
|
|
if (contactsSelect != null) {
|
|
if (contactsSelect != null) {
|
|
//操作记录
|
|
//操作记录
|
|
LambdaQueryWrapper<ContactsLog> cLoglqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ContactsLog> cLoglqw = new LambdaQueryWrapper<>();
|
|
cLoglqw.eq(ContactsLog::getContactsId, contactsSelect.getId());
|
|
cLoglqw.eq(ContactsLog::getContactsId, contactsSelect.getId());
|
|
List<ContactsLog> contactsLogs = contactsLogMapper.selectList(cLoglqw);
|
|
List<ContactsLog> contactsLogs = contactsLogMapper.selectList(cLoglqw);
|
|
|
|
+ if (contactsLogs!=null&&!contactsLogs.isEmpty()){
|
|
|
|
+ for (ContactsLog contactsLog : contactsLogs) {
|
|
|
|
+ if (contactsLog.getOperateId()!=null&&StringUtils.isNotEmpty(contactsLog.getOperateId())){
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(contactsLog.getOperateId())).findFirst();
|
|
|
|
+ first.ifPresent(value -> contactsLog.setOperateName(value.getName()));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
//相关任务
|
|
//相关任务
|
|
LambdaQueryWrapper<Task> tLqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Task> tLqw = new LambdaQueryWrapper<>();
|
|
@@ -297,6 +318,9 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
LambdaQueryWrapper<BusinessOpportunity> bLqw = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<BusinessOpportunity> bLqw = new LambdaQueryWrapper<>();
|
|
bLqw.eq(BusinessOpportunity::getContactsId,contactsSelect.getId());
|
|
bLqw.eq(BusinessOpportunity::getContactsId,contactsSelect.getId());
|
|
List<BusinessOpportunity> opportunityList = businessOpportunityMapper.selectList(bLqw);
|
|
List<BusinessOpportunity> opportunityList = businessOpportunityMapper.selectList(bLqw);
|
|
|
|
+ LambdaQueryWrapper<Stage> stageLQW = new LambdaQueryWrapper<>();
|
|
|
|
+ List<Stage> stages = stageMapper.selectList(stageLQW);
|
|
|
|
+
|
|
opportunityList.forEach(businessOpportunity -> {
|
|
opportunityList.forEach(businessOpportunity -> {
|
|
Custom custom = customMapper.selectById(businessOpportunity.getCustomerId());
|
|
Custom custom = customMapper.selectById(businessOpportunity.getCustomerId());
|
|
businessOpportunity.setCustomerName(custom.getCustomName());
|
|
businessOpportunity.setCustomerName(custom.getCustomName());
|
|
@@ -308,6 +332,10 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
User creatorUser = userMapper.selectById(businessOpportunity.getCreatorId());
|
|
User creatorUser = userMapper.selectById(businessOpportunity.getCreatorId());
|
|
businessOpportunity.setCreatorName(creatorUser.getName());
|
|
businessOpportunity.setCreatorName(creatorUser.getName());
|
|
}
|
|
}
|
|
|
|
+ if (businessOpportunity.getStageId()!=null){
|
|
|
|
+ Optional<Stage> first = stages.stream().filter(s -> s.getId().equals(businessOpportunity.getStageId())).findFirst();
|
|
|
|
+ first.ifPresent(stage -> businessOpportunity.setStageValue(stage.getName()));
|
|
|
|
+ }
|
|
});
|
|
});
|
|
|
|
|
|
//附件信息查询
|
|
//附件信息查询
|
|
@@ -321,6 +349,22 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
contactsVo.setTaskList(taskList);
|
|
contactsVo.setTaskList(taskList);
|
|
contactsVo.setBusinessOpportunityList(opportunityList);
|
|
contactsVo.setBusinessOpportunityList(opportunityList);
|
|
contactsVo.setContactsDocumentList(contactsDocuments);
|
|
contactsVo.setContactsDocumentList(contactsDocuments);
|
|
|
|
+ if (contactsVo.getCustomId()!=null){
|
|
|
|
+ Custom custom = customMapper.selectById(contactsVo.getCustomId());
|
|
|
|
+ contactsVo.setCustomName(custom.getCustomName());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(contactsVo.getOwnerId())){
|
|
|
|
+// User user = userMapper.selectById(contactsVo.getOwnerId());
|
|
|
|
+// contactsVo.setOwnerName(user.getName());
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(contactsVo.getOwnerId())).findFirst();
|
|
|
|
+ first.ifPresent(value -> contactsVo.setOwnerName(value.getName()));
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotEmpty(contactsVo.getCreatorId())){
|
|
|
|
+// User user = userMapper.selectById(contactsVo.getCreatorId());
|
|
|
|
+// contactsVo.setCreatorName(user.getName());
|
|
|
|
+ Optional<User> first = userList.stream().filter(u -> u.getId().equals(contactsVo.getCreatorId())).findFirst();
|
|
|
|
+ first.ifPresent(value -> contactsVo.setCreatorName(value.getName()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
msg.setData(contactsVo);
|
|
msg.setData(contactsVo);
|
|
return msg;
|
|
return msg;
|
|
@@ -334,7 +378,6 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
Integer companyId = user.getCompanyId();
|
|
Integer companyId = user.getCompanyId();
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
- List<Contacts> contactsList = contactsMapper.selectList(new LambdaQueryWrapper<Contacts>().eq(Contacts::getCompanyId, companyId));
|
|
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>().eq(User::getCompanyId, companyId));
|
|
InputStream inputStream = null;
|
|
InputStream inputStream = null;
|
|
OutputStream outputStream = null;
|
|
OutputStream outputStream = null;
|
|
@@ -351,9 +394,9 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
outputStream.close();
|
|
outputStream.close();
|
|
|
|
|
|
//解析表格
|
|
//解析表格
|
|
- HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(file));
|
|
|
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(file));
|
|
//我们只需要第一个sheet
|
|
//我们只需要第一个sheet
|
|
- HSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
|
|
+ XSSFSheet sheet = workbook.getSheetAt(0);
|
|
//由于第一行需要指明列对应的标题
|
|
//由于第一行需要指明列对应的标题
|
|
int rowNum = sheet.getLastRowNum();
|
|
int rowNum = sheet.getLastRowNum();
|
|
//获取当前表单模板 校验规则
|
|
//获取当前表单模板 校验规则
|
|
@@ -367,12 +410,43 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
JSONObject configOb = JSON.parseObject(config);
|
|
JSONObject configOb = JSON.parseObject(config);
|
|
JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
|
|
|
|
|
|
+ //可能存在栅格布局的情况需要特殊处理
|
|
|
|
+ List<String> modelNameList=new ArrayList<>();
|
|
|
|
+ List<String> typeList=new ArrayList<>();
|
|
|
|
+ List<String> labelList=new ArrayList<>();
|
|
|
|
+ List<Boolean> requiredList=new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
|
+ JSONObject jsonObject = configObJSONArray.getJSONObject(i);
|
|
|
|
+ if(jsonObject.getString("type").equals("grid")){
|
|
|
|
+ JSONArray columns = jsonObject.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);
|
|
|
|
+ modelNameList.add(object.getString("model"));
|
|
|
|
+ typeList.add(object.getString("type"));
|
|
|
|
+ labelList.add(object.getString("label"));
|
|
|
|
+ Boolean required = object.getJSONObject("options").getJSONObject("rules").getBoolean("required");
|
|
|
|
+ requiredList.add(required);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ modelNameList.add(jsonObject.getString("model"));
|
|
|
|
+ typeList.add(jsonObject.getString("type"));
|
|
|
|
+ labelList.add(jsonObject.getString("label"));
|
|
|
|
+ Boolean required = jsonObject.getJSONObject("options").getJSONObject("rules").getBoolean("required");
|
|
|
|
+ requiredList.add(required);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
List<Contacts> importContactsList=new ArrayList<>();
|
|
List<Contacts> importContactsList=new ArrayList<>();
|
|
List<String> userNameList=new ArrayList<>();
|
|
List<String> userNameList=new ArrayList<>();
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
HttpRespMsg respMsg=new HttpRespMsg();
|
|
|
|
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
- HSSFRow row = sheet.getRow(rowIndex);
|
|
|
|
|
|
+ XSSFRow row = sheet.getRow(rowIndex);
|
|
if (row == null) {
|
|
if (row == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -384,19 +458,24 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
int cellNum = row.getLastCellNum();
|
|
int cellNum = row.getLastCellNum();
|
|
|
|
|
|
for (int i = 0; i < cellNum; i++) {
|
|
for (int i = 0; i < cellNum; i++) {
|
|
- JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
|
- String modelName = item.getString("model");
|
|
|
|
- HSSFCell cell = row.getCell(i);
|
|
|
|
- if(cell!=null){
|
|
|
|
- switch (item.getString("type")){
|
|
|
|
- case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
|
- break;
|
|
|
|
- case "int":cell.setCellType(CellType.NUMERIC);
|
|
|
|
- break;
|
|
|
|
- default:cell.setCellType(CellType.STRING);
|
|
|
|
|
|
+ String modelName = modelNameList.get(i);
|
|
|
|
+ XSSFCell cell = row.getCell(i);
|
|
|
|
+ if(modelName.equals("inchargerId")){
|
|
|
|
+ if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ userNameList.add(cell.getStringCellValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(modelName.equals("inchargerId")){
|
|
|
|
|
|
+ if(modelName.equals("ownerId")){
|
|
|
|
+ if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ userNameList.add(cell.getStringCellValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(modelName.equals("customSigner")){
|
|
|
|
+ if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ userNameList.add(cell.getStringCellValue());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(modelName.equals("companySigner")){
|
|
if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
userNameList.add(cell.getStringCellValue());
|
|
userNameList.add(cell.getStringCellValue());
|
|
}
|
|
}
|
|
@@ -416,7 +495,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
List<User> targetUserList= (List<User>) respMsg.data;
|
|
List<User> targetUserList= (List<User>) respMsg.data;
|
|
|
|
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
for (int rowIndex = 1; rowIndex <= rowNum; rowIndex++) {
|
|
- HSSFRow row = sheet.getRow(rowIndex);
|
|
|
|
|
|
+ XSSFRow row = sheet.getRow(rowIndex);
|
|
if (row == null) {
|
|
if (row == null) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -430,18 +509,13 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
contacts.setCompanyId(companyId);
|
|
contacts.setCompanyId(companyId);
|
|
contacts.setCreatorId(user.getId());
|
|
contacts.setCreatorId(user.getId());
|
|
for (int i = 0; i < cellNum; i++) {
|
|
for (int i = 0; i < cellNum; i++) {
|
|
- JSONObject item = configObJSONArray.getJSONObject(i);
|
|
|
|
- String modelName = item.getString("model");
|
|
|
|
|
|
+ String modelName = modelNameList.get(i);
|
|
String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
|
|
String className = modelName.substring(0, 1).toUpperCase() + modelName.substring(1);
|
|
String getter="get"+className;
|
|
String getter="get"+className;
|
|
String setter="set"+className;
|
|
String setter="set"+className;
|
|
- HSSFCell cell = row.getCell(i);
|
|
|
|
|
|
+ XSSFCell cell = row.getCell(i);
|
|
if(cell!=null){
|
|
if(cell!=null){
|
|
- switch (item.getString("type")){
|
|
|
|
- case "time":cell.setCellType(CellType.NUMERIC);
|
|
|
|
- break;
|
|
|
|
- case "int":cell.setCellType(CellType.NUMERIC);
|
|
|
|
- break;
|
|
|
|
|
|
+ switch (typeList.get(i)){
|
|
default:cell.setCellType(CellType.STRING);
|
|
default:cell.setCellType(CellType.STRING);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -450,25 +524,36 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
Class<?> type = field.getType();
|
|
Class<?> type = field.getType();
|
|
Method method = contactsClass.getMethod(setter, type);
|
|
Method method = contactsClass.getMethod(setter, type);
|
|
//校验当前列是否为必填
|
|
//校验当前列是否为必填
|
|
- JSONObject options = item.getJSONObject("options");
|
|
|
|
- JSONObject rules = options.getJSONObject("rules");
|
|
|
|
- Boolean required = rules.getBoolean("required");
|
|
|
|
- if(required){
|
|
|
|
|
|
+ if(requiredList.get(i)){
|
|
if(StringUtils.isEmpty(cell.getStringCellValue())){
|
|
if(StringUtils.isEmpty(cell.getStringCellValue())){
|
|
- msg.setError(item.getString("label")+"值不能为空值");
|
|
|
|
|
|
+ msg.setError(labelList.get(i)+"值不能为空值");
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- /*if(modelName.equals("contactsCode")){
|
|
|
|
- if(!org.springframework.util.StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
- //系统中同公司已存在的产品编码 更新
|
|
|
|
- Optional<Contacts> first = contactsList.stream().filter(p ->p.getContactsCode()!=null&& p.getContactsCode().equals(cell.getStringCellValue())).findFirst();
|
|
|
|
- if(first.isPresent()){
|
|
|
|
- contacts.setId(first.get().getId());
|
|
|
|
|
|
+ if(modelName.equals("customId")){
|
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ String customerName = cell.getStringCellValue();
|
|
|
|
+ List<Custom> customList = customMapper.selectList(new QueryWrapper<Custom>().eq("custom_name", customerName));
|
|
|
|
+ if (customList!=null&&!customList.isEmpty()){
|
|
|
|
+ Custom custom = customList.get(0);
|
|
|
|
+ contacts.setCustomId(custom.getId());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ msg.setError("负责人["+customerName+"]在系统中不存在");
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }*/
|
|
|
|
- if(modelName.equals("inchargerId")){
|
|
|
|
|
|
+ }else if(modelName.equals("sex")){
|
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ String stringCellValue = cell.getStringCellValue();
|
|
|
|
+ if (stringCellValue.equals("男")){
|
|
|
|
+ contacts.setSex(1);
|
|
|
|
+ } else if (stringCellValue.equals("女")) {
|
|
|
|
+ contacts.setSex(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if(modelName.equals("ownerId")){
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
String userName = cell.getStringCellValue();
|
|
String userName = cell.getStringCellValue();
|
|
Optional<User> first;
|
|
Optional<User> first;
|
|
@@ -484,30 +569,12 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
throw new Exception("["+userName+"]在系统中不存在");
|
|
throw new Exception("["+userName+"]在系统中不存在");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- /*if(cell.getCellType()==CellType.STRING.getCode()&&!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
- method.invoke(contacts,cell.getStringCellValue());
|
|
|
|
- } else if (cell.getCellType()==CellType.NUMERIC.getCode()) {
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }*/
|
|
|
|
- if (cell != null && cell.getCellTypeEnum() != CellType.BLANK) {
|
|
|
|
- if (cell.getCellTypeEnum() == CellType.STRING && cell.getStringCellValue() != null && !cell.getStringCellValue().isEmpty()) {
|
|
|
|
- // 字符串类型不为空
|
|
|
|
|
|
+ }else{
|
|
|
|
+ if(!StringUtils.isEmpty(cell.getStringCellValue())){
|
|
|
|
+ System.out.println(cell.getStringCellValue());
|
|
method.invoke(contacts,cell.getStringCellValue());
|
|
method.invoke(contacts,cell.getStringCellValue());
|
|
- } else if (cell.getCellTypeEnum() == CellType.NUMERIC) {
|
|
|
|
- // 数值类型不为空
|
|
|
|
- double numericCellValue = cell.getNumericCellValue();
|
|
|
|
- if (type.getSimpleName().equals("Integer")){
|
|
|
|
- int intValue = (int) numericCellValue;
|
|
|
|
- method.invoke(contacts,intValue);
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- method.invoke(contacts, numericCellValue);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
importContactsList.add(contacts);
|
|
importContactsList.add(contacts);
|
|
}
|
|
}
|
|
@@ -539,9 +606,26 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
JSONArray configObJSONArray = configOb.getJSONArray("list");
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
List<String> titleList=new ArrayList<>();
|
|
List<String> titleList=new ArrayList<>();
|
|
|
|
+ List<String> modelList=new ArrayList<>();
|
|
for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
JSONObject item = configObJSONArray.getJSONObject(i);
|
|
JSONObject item = configObJSONArray.getJSONObject(i);
|
|
- titleList.add(item.getString("label"));
|
|
|
|
|
|
+ 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);
|
|
dataList.add(titleList);
|
|
|
|
|
|
@@ -557,26 +641,40 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
|
|
|
|
for (ContactsVo contactsVo : records) {
|
|
for (ContactsVo contactsVo : records) {
|
|
List<String> item=new ArrayList<>();
|
|
List<String> item=new ArrayList<>();
|
|
- for (int i = 0; i < configObJSONArray.size(); i++) {
|
|
|
|
- JSONObject target = configObJSONArray.getJSONObject(i);
|
|
|
|
- String model = target.getString("model");
|
|
|
|
-// String targetName = model.substring(0, 1).toUpperCase() + model.substring(1);
|
|
|
|
|
|
+ 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 ContactsVo> aClass = contactsVo.getClass();
|
|
Class<? extends ContactsVo> aClass = contactsVo.getClass();
|
|
- String value="";
|
|
|
|
-// String value = String.valueOf(aClass.getMethod("get" + targetName).invoke(contactsVo)==null?"":aClass.getMethod("get" + targetName).invoke(contactsVo));
|
|
|
|
- /*if(model.equals("inchargerId")){
|
|
|
|
|
|
+ String value = "";
|
|
|
|
+
|
|
|
|
+ if(model.equals("customId")){
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
- value = "$userName"+String.valueOf(aClass.getMethod("getInchargerName").invoke(product))+"$";
|
|
|
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getCustomName").invoke(contactsVo))+"$";
|
|
}else {
|
|
}else {
|
|
- value = String.valueOf(aClass.getMethod("getInchargerName").invoke(product));
|
|
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getCustomName").invoke(contactsVo)).equals("null") ?"" :String.valueOf(aClass.getMethod("getCustomName").invoke(contactsVo));
|
|
}
|
|
}
|
|
- }*/
|
|
|
|
- if(model.equals("sex")){
|
|
|
|
- value = String.valueOf(aClass.getMethod("getSex").invoke(contactsVo)).equals("null") ?"":String.valueOf(aClass.getMethod("getSex").invoke(contactsVo));
|
|
|
|
}
|
|
}
|
|
- if(model.equals("name")){
|
|
|
|
- value = String.valueOf(aClass.getMethod("getName").invoke(contactsVo)).equals("null")?"":String.valueOf(aClass.getMethod("getName").invoke(contactsVo));
|
|
|
|
|
|
+ else if(model.equals("sex")){
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getSex").invoke(contactsVo)).equals("null") ?"":String.valueOf(aClass.getMethod("getSex").invoke(contactsVo));
|
|
|
|
+ if (StringUtils.isNotEmpty(value)){
|
|
|
|
+ if (value.equals("0")){
|
|
|
|
+ value="女";
|
|
|
|
+ }else {
|
|
|
|
+ value="男";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ else if(model.equals("ownerId")){
|
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
|
+ value = "$userName"+String.valueOf(aClass.getMethod("getOwnerName").invoke(contactsVo))+"$";
|
|
|
|
+ }else {
|
|
|
|
+ value = String.valueOf(aClass.getMethod("getOwnerName").invoke(contactsVo)).equals("null") ? "" :String.valueOf(aClass.getMethod("getOwnerName").invoke(contactsVo));
|
|
|
|
+ }
|
|
|
|
+ }else
|
|
|
|
+ value= String.valueOf(aClass.getMethod("get" + targetName).invoke(contactsVo)==null?"":aClass.getMethod("get" + targetName).invoke(contactsVo));
|
|
|
|
+
|
|
item.add(value);
|
|
item.add(value);
|
|
}
|
|
}
|
|
dataList.add(item);
|
|
dataList.add(item);
|
|
@@ -620,5 +718,34 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> i
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public int claimContacts(Contacts contactsGet, User user) {
|
|
|
|
+ UpdateWrapper<Contacts> contactsUpdateWrapper = new UpdateWrapper<>();
|
|
|
|
+ contactsUpdateWrapper.eq("id", contactsGet.getId());
|
|
|
|
+ contactsUpdateWrapper.set("owner_id", contactsGet.getOwnerId());
|
|
|
|
+ int count1 = contactsMapper.update(null, contactsUpdateWrapper);
|
|
|
|
+
|
|
|
|
+ ContactsLog contactsLog = new ContactsLog();
|
|
|
|
+ contactsLog.setCompanyId(user.getCompanyId());
|
|
|
|
+ contactsLog.setContactsId(contactsGet.getId());
|
|
|
|
+ contactsLog.setOperateId(user.getId());
|
|
|
|
+ contactsLog.setOperateDate(LocalDateTime.now());
|
|
|
|
+ contactsLog.setMsg("认领联系人");
|
|
|
|
+ int count2 = contactsLogMapper.insert(contactsLog);
|
|
|
|
+ if (count1>0&&count2>0){
|
|
|
|
+ return 1;
|
|
|
|
+ }else {
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getAll(HttpServletRequest request) {
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
+ httpRespMsg.setData(contactsMapper.selectList(new QueryWrapper<Contacts>().eq("company_id",user.getCompanyId())));
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|