|
|
|
@ -32,6 +32,7 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 单位(unit)表控制层
|
|
|
|
@ -178,6 +179,9 @@ public class UnitController {
|
|
|
|
|
public AjaxResult importData(MultipartFile file) throws Exception {
|
|
|
|
|
ExcelUtil<Unit> util = new ExcelUtil<>(Unit.class);
|
|
|
|
|
List<Unit> list = util.importExcel(file.getInputStream());
|
|
|
|
|
List<Unit> collect = new ArrayList<>(list.stream()
|
|
|
|
|
.collect(Collectors.toMap(Unit::getUserName, entity -> entity, (e1, e2) -> e1))
|
|
|
|
|
.values());
|
|
|
|
|
//做组织架构的处理和更新处理
|
|
|
|
|
List<SysDept> sd = sysDeptMapper.selectDeptList(new SysDept());
|
|
|
|
|
Set<String> set = new HashSet<>();
|
|
|
|
@ -185,28 +189,28 @@ public class UnitController {
|
|
|
|
|
set.add(i.getDeptName());
|
|
|
|
|
}
|
|
|
|
|
List<Unit> list1 = unitService.list();
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
if(!CreditCodeUtil.isCreditCode(list.get(i).getUserName())){
|
|
|
|
|
for (int i = 0; i < collect.size(); i++) {
|
|
|
|
|
if(collect.get(i).getUserName().length()!=18){
|
|
|
|
|
throw new ServiceException("第" + i + "行,统一社会信用代码格式错误!");
|
|
|
|
|
}
|
|
|
|
|
for (Unit unit : list1) {
|
|
|
|
|
if (unit.getNickName().equals(list.get(i).getNickName())
|
|
|
|
|
|| unit.getUserName().equals(list.get(i).getUserName())
|
|
|
|
|
if (unit.getNickName().equals(collect.get(i).getNickName())
|
|
|
|
|
|| unit.getUserName().equals(collect.get(i).getUserName())
|
|
|
|
|
) {
|
|
|
|
|
list.get(i).setId(unit.getId());
|
|
|
|
|
collect.get(i).setId(unit.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int lastIndex = list.get(i).getDeptName().lastIndexOf("-");
|
|
|
|
|
int lastIndex = collect.get(i).getDeptName().lastIndexOf("-");
|
|
|
|
|
String result = null;
|
|
|
|
|
if (lastIndex!= -1) {
|
|
|
|
|
result = list.get(i).getDeptName().substring(lastIndex + 1);
|
|
|
|
|
result = collect.get(i).getDeptName().substring(lastIndex + 1);
|
|
|
|
|
}else {
|
|
|
|
|
result = list.get(i).getDeptName();
|
|
|
|
|
result = collect.get(i).getDeptName();
|
|
|
|
|
}
|
|
|
|
|
if (set.contains(result)) {
|
|
|
|
|
for (SysDept s : sd) {
|
|
|
|
|
if (list.get(i).getDeptName().equals(s.getDeptName())) {
|
|
|
|
|
list.get(i).setDeptId(s.getDeptId());
|
|
|
|
|
if (result.equals(s.getDeptName())) {
|
|
|
|
|
collect.get(i).setDeptId(s.getDeptId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -214,9 +218,9 @@ public class UnitController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//批量新增或者修改单位
|
|
|
|
|
unitService.saveOrUpdateBatch(list);
|
|
|
|
|
unitService.saveOrUpdateBatch(collect);
|
|
|
|
|
Map<String, String> a1 = new HashMap<>();
|
|
|
|
|
for (Unit x : list) {
|
|
|
|
|
for (Unit x : collect) {
|
|
|
|
|
//查询用户表是否存在该用户
|
|
|
|
|
String s = unitService.validUser(x);
|
|
|
|
|
a1.put(x.getUserName(), s);
|
|
|
|
|