人员上传问题修改
This commit is contained in:
parent
ed487edfd2
commit
a4380c4309
|
|
@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -214,7 +215,7 @@ public class ImportServiceImpl implements ImportService {
|
|||
} catch (Exception e) {
|
||||
ajaxResult.isError();
|
||||
// throw new Exception("文件上传失败"+e);
|
||||
e.printStackTrace();
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
|
||||
return ajaxResult;
|
||||
|
|
@ -268,6 +269,7 @@ public class ImportServiceImpl implements ImportService {
|
|||
deleteAllFile(uploadUrl + folderName);
|
||||
}
|
||||
file.transferTo(new File(uploadUrl + packageName));
|
||||
String filesName = file.getOriginalFilename();
|
||||
if (file.getOriginalFilename().indexOf(".zip") > 0) {
|
||||
unPackZip(packageName, uploadUrl);
|
||||
}
|
||||
|
|
@ -313,6 +315,13 @@ public class ImportServiceImpl implements ImportService {
|
|||
@NotNull
|
||||
private static List<SysFileInfo> getSysFileInfos(List<SubPerson> inLibraryList, int i, SubPerson bean) {
|
||||
List<SysFileInfo> fileList = new ArrayList<>();
|
||||
int _index = 0;
|
||||
String[] parts = nameList.get(0).split("/");
|
||||
for (int m = 0; m < parts.length; m++) {
|
||||
if (parts[m].contains("_")) {
|
||||
_index = m;
|
||||
}
|
||||
}
|
||||
//当前人员的所有文件
|
||||
for (String path : nameList) {
|
||||
if (path.contains(inLibraryList.get(i).getPhone())) {
|
||||
|
|
@ -322,11 +331,11 @@ public class ImportServiceImpl implements ImportService {
|
|||
sysFileInfo.setId(inLibraryList.get(i).getId());
|
||||
sysFileInfo.setUuid(inLibraryList.get(i).getUuid());
|
||||
sysFileInfo.setProId(bean.getProId());
|
||||
sysFileInfo.setFileName(path.split("/")[3]);
|
||||
sysFileInfo.setFileName(path.split("/")[_index + 2]);
|
||||
sysFileInfo.setCreatePerson(SecurityUtils.getLoginUser().getUsername());
|
||||
sysFileInfo.setUserId(String.valueOf(SecurityUtils.getLoginUser().getUserid()));
|
||||
sysFileInfo.setUserType(bean.getUserType());
|
||||
switch (path.split("/")[2]) {
|
||||
switch (path.split("/")[_index + 1]) {
|
||||
case "人脸照片":
|
||||
sysFileInfo.setInformationType("5");
|
||||
break;
|
||||
|
|
@ -405,7 +414,7 @@ public class ImportServiceImpl implements ImportService {
|
|||
nameList = new ArrayList<>();
|
||||
namePhoneList = new ArrayList<>();
|
||||
map = new HashMap<>();
|
||||
String encoding = "GBK";
|
||||
String encoding = "UTF-8";
|
||||
ZipFile zipFile = new ZipFile(path);
|
||||
zipFile.setFileNameCharset(encoding);
|
||||
List<FileHeader> list = zipFile.getFileHeaders();
|
||||
|
|
@ -413,15 +422,23 @@ public class ImportServiceImpl implements ImportService {
|
|||
String beforeName = "";
|
||||
StringBuilder folderName = new StringBuilder();
|
||||
int i = 0;
|
||||
int _index = 0;
|
||||
while (i < list.size()) {
|
||||
FileHeader fileHeader = list.get(i);
|
||||
String fileName = fileHeader.getFileName();
|
||||
|
||||
if (fileName.contains(".")) {
|
||||
if (fileName.contains(".") && fileName.contains("_")) {
|
||||
if (StringUtils.isEmpty(folderName)) {
|
||||
//判断_在第几个位置
|
||||
String[] parts = fileName.split("/");
|
||||
for (int m = 0; m < parts.length; m++) {
|
||||
if (parts[m].contains("_")) {
|
||||
_index = m;
|
||||
}
|
||||
}
|
||||
// 初次进入赋值第一个人的名称_手机号 和对应的 value
|
||||
beforeName = fileName.split("/")[1].split("_")[1];
|
||||
map.put(beforeName, "其他文件".equals(fileName.split("/")[2]) ? "" : fileName.split("/")[2]);
|
||||
beforeName = fileName.split("/")[_index].split("_")[1];
|
||||
String name = fileName.split("/")[_index + 1];
|
||||
map.put(beforeName, "其他文件".equals(fileName.split("/")[_index + 1]) ? "" : fileName.split("/")[_index + 1]);
|
||||
}
|
||||
|
||||
// 设置编码
|
||||
|
|
@ -436,7 +453,7 @@ public class ImportServiceImpl implements ImportService {
|
|||
if (i == (list.size() - 1)) {
|
||||
map.put(beforeName, folderName.toString());
|
||||
}
|
||||
String currentName = fileName.split("/")[1].split("_")[1];
|
||||
String currentName = fileName.split("/")[_index].split("_")[1];
|
||||
if (!beforeName.equals(currentName)) {
|
||||
// 不相同名称时,对map进行赋值
|
||||
map.put(beforeName, folderName.toString());
|
||||
|
|
@ -444,8 +461,11 @@ public class ImportServiceImpl implements ImportService {
|
|||
folderName = new StringBuilder();
|
||||
}
|
||||
|
||||
if (!"其他文件".equals(fileName.split("/")[2])) {
|
||||
folderName.append(fileName.split("/")[2]).append(",");
|
||||
if (!"其他文件".equals(fileName.split("/")[_index + 1])) {
|
||||
folderName.append(fileName.split("/")[_index + 1]).append(",");
|
||||
}
|
||||
if (!"人脸照片".equals(fileName.split("/")[_index + 1])) {
|
||||
folderName.append(fileName.split("/")[_index + 1]).append(",");
|
||||
}
|
||||
|
||||
if (i == list.size() - 1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue