diff --git a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java index f732bde..b9db3b9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/tc/controller/UnitController.java @@ -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 util = new ExcelUtil<>(Unit.class); List list = util.importExcel(file.getInputStream()); + List collect = new ArrayList<>(list.stream() + .collect(Collectors.toMap(Unit::getUserName, entity -> entity, (e1, e2) -> e1)) + .values()); //做组织架构的处理和更新处理 List sd = sysDeptMapper.selectDeptList(new SysDept()); Set set = new HashSet<>(); @@ -185,28 +189,28 @@ public class UnitController { set.add(i.getDeptName()); } List 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 a1 = new HashMap<>(); - for (Unit x : list) { + for (Unit x : collect) { //查询用户表是否存在该用户 String s = unitService.validUser(x); a1.put(x.getUserName(), s); diff --git a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml index 9ce2b17..4ce1422 100644 --- a/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/AssetCurrentMapper.xml @@ -130,7 +130,7 @@ yjbbxx AS aqyjbbxx, yjyt AS aqyjyt, yjbsxx AS aqyjbswz - FROM asset_basic_network WHERE type = 3 GROUP BY asset_id,sblx,pp,sb_ip ) l ON a.id = l.asset_id + FROM asset_basic_network WHERE type = 3 GROUP BY asset_id,sblx,pp,sb_ip,yjxh,yjxlh,yjbbxx,yjyt,yjbsxx ) l ON a.id = l.asset_id a.del_flag = '0' and a.isbf = '0' diff --git a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml index 216deeb..b0d428d 100644 --- a/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/UnitMapper.xml @@ -248,7 +248,10 @@ d.STATUS, d.del_flag, d.create_by, - d.create_time UNION ALL-- 递归查询,根据parentid为上级id继续查询下一级数据 + d.create_time, + d.update_by, + d.update_time + UNION ALL-- 递归查询,根据parentid为上级id继续查询下一级数据 SELECT d.* FROM @@ -258,6 +261,21 @@ * FROM category_tree + group by + dept_id, + parent_id, + ancestors, + dept_name, + order_num, + leader, + phone, + email, + STATUS, + del_flag, + create_by, + create_time, + update_by, + update_time ORDER BY dept_id desc