|
@@ -21,6 +21,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;
|
|
@@ -390,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();
|
|
//获取当前表单模板 校验规则
|
|
//获取当前表单模板 校验规则
|
|
@@ -406,12 +410,31 @@ 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<>();
|
|
|
|
+ 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"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ modelNameList.add(jsonObject.getString("model"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
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;
|
|
}
|
|
}
|
|
@@ -423,19 +446,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());
|
|
}
|
|
}
|
|
@@ -455,7 +483,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;
|
|
}
|
|
}
|
|
@@ -474,7 +502,7 @@ public class ContactsServiceImpl extends ServiceImpl<ContactsMapper, Contacts> 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")){
|
|
switch (item.getString("type")){
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|
|
case "time":cell.setCellType(CellType.NUMERIC);
|