From 71f3101370c3db0ec00178d51a723816c9bcddbd Mon Sep 17 00:00:00 2001 From: zhanghua <314079846@qq.com> Date: 星期六, 18 三月 2023 17:42:14 +0800 Subject: [PATCH] Merge branch 'master' of http://42.193.1.25:9521/r/sccg_server --- ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java | 4 ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java | 107 +++++++++++++- ycl-common/src/main/java/com/ycl/controller/depart/DepartController.java | 50 +++++++ ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java | 6 ycl-common/src/main/java/com/ycl/mapper/user/UmsAdminMapper.java | 2 ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java | 23 ++ ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto1.java | 18 - ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java | 1 ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml | 19 ++ ycl-common/src/main/java/com/ycl/dto/user/UmsAdminParamDto.java | 47 ++++++ ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto.java | 2 ycl-common/src/main/java/com/ycl/controller/user/UmsAdminController.java | 97 +++++++++++++ 12 files changed, 332 insertions(+), 44 deletions(-) diff --git a/ycl-common/src/main/java/com/ycl/controller/depart/DepartController.java b/ycl-common/src/main/java/com/ycl/controller/depart/DepartController.java index 8485e5f..d2c0283 100644 --- a/ycl-common/src/main/java/com/ycl/controller/depart/DepartController.java +++ b/ycl-common/src/main/java/com/ycl/controller/depart/DepartController.java @@ -1,6 +1,9 @@ package com.ycl.controller.depart; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -11,6 +14,9 @@ import com.ycl.controller.BaseController; import com.ycl.dto.UmsDepartDto; import com.ycl.entity.depart.UmsDepart; +import com.ycl.entity.dict.DataDictionary; +import com.ycl.mapper.depart.UmsDepartMapper; +import com.ycl.mapper.dict.DataDictionaryMapper; import com.ycl.service.depart.UmsDepartService; import com.ycl.service.user.UmsDepartManageService; import com.ycl.utils.EasyExcelUtils; @@ -28,6 +34,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; +import java.util.Objects; /** * <p> @@ -137,10 +144,51 @@ EasyExcelUtils.export(response, sheetName, UmsDepartDto.class, umsDepartDtos); } + @Resource + private UmsDepartMapper sccgDepartMapper; + @Resource + private DataDictionaryMapper dataDictionaryMapper; @ApiOperation("閮ㄩ棬瀵煎叆") @PostMapping("/import") public CommonResult importDpt(MultipartFile file) throws IOException { - EasyExcelUtils.importDepartFile(file); + EasyExcel.read(file.getInputStream()) + .head(UmsDepartDto.class) + .registerReadListener(new ReadListener<UmsDepartDto>() { + @Override + public void invoke(UmsDepartDto umsDepartDto, AnalysisContext analysisContext) { + // 涓嶈兘閲嶅鎻掑叆 + String departTypeName = umsDepartDto.getDepartTypeName(); + UmsDepart one = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, departTypeName)); + if (Objects.nonNull(one)){ + throw new RuntimeException("璇ラ儴闂ㄥ凡缁忓瓨鍦�"); + } + UmsDepart umsDepart = new UmsDepart(); + // 璁剧疆閮ㄩ棬鍚嶅瓧 + umsDepart.setDepartName(umsDepartDto.getDepartTypeName()); + // 璁剧疆閮ㄩ棬鎻忚堪 + umsDepart.setDepartDes(umsDepartDto.getDepartDes()); + // 璁剧疆閮ㄩ棬绫诲瀷 + DataDictionary dataDictionary = dataDictionaryMapper.selectOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getName, umsDepartDto.getDepartType())); + if (Objects.isNull(dataDictionary)){ + throw new RuntimeException("閮ㄩ棬绫诲瀷涓嶅瓨鍦�"); + }else { + umsDepart.setDepartType(new Long(dataDictionary.getId()).intValue()); + } + // 璁剧疆鐖秈d + UmsDepart two = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, umsDepartDto.getParentDepartName())); + if (Objects.nonNull(two)){ + umsDepart.setParentId(two.getParentId()); + } + int insert = sccgDepartMapper.insert(umsDepart); + if (insert < 1){ + throw new RuntimeException("鎻掑叆澶辫触"); + } + } + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } + }).sheet().doRead(); return CommonResult.success(true, "瀵煎叆鎴愬姛"); } diff --git a/ycl-common/src/main/java/com/ycl/controller/user/UmsAdminController.java b/ycl-common/src/main/java/com/ycl/controller/user/UmsAdminController.java index fa325a3..fc838c5 100644 --- a/ycl-common/src/main/java/com/ycl/controller/user/UmsAdminController.java +++ b/ycl-common/src/main/java/com/ycl/controller/user/UmsAdminController.java @@ -1,14 +1,26 @@ package com.ycl.controller.user; import cn.hutool.core.collection.CollUtil; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.read.listener.ReadListener; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.annotation.LogSave; import com.ycl.api.CommonResult; import com.ycl.bo.AdminUserDetails; import com.ycl.controller.BaseController; import com.ycl.dto.*; +import com.ycl.dto.user.UmsAdminParamDto; +import com.ycl.dto.user.UmsUserDto1; +import com.ycl.entity.depart.UmsDepart; +import com.ycl.entity.dict.DataDictionary; import com.ycl.entity.user.UmsAdmin; import com.ycl.entity.user.UmsRole; +import com.ycl.mapper.depart.UmsDepartMapper; +import com.ycl.mapper.dict.DataDictionaryMapper; +import com.ycl.mapper.user.UmsAdminMapper; +import com.ycl.mapper.user.UmsRoleMapper; import com.ycl.service.redis.RedisService; import com.ycl.service.user.UmsAdminService; import com.ycl.service.user.UmsMenuService; @@ -32,9 +44,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.security.Principal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -138,15 +148,90 @@ @ApiOperation("鐢ㄦ埛瀵煎嚭") @PostMapping("/export") public void exportUser(HttpServletResponse response) { - List<UmsUserDto> umsUserDtos = adminService.userExp(); + List<UmsUserDto1> umsUserDtos = adminService.userExp(); String sheetName = "鐢ㄦ埛瀵煎嚭"; - EasyExcelUtils.export(response, sheetName, UmsUserDto.class, umsUserDtos); + EasyExcelUtils.export(response, sheetName, UmsUserDto1.class, umsUserDtos); } + @Resource + private UmsRoleMapper umsRoleMapper; + @Resource + private UmsAdminMapper umsAdminMapper; + @Resource + private DataDictionaryMapper dataDictionaryMapper; + @Resource + private UmsDepartMapper umsDepartMapper; @ApiOperation("鐢ㄦ埛瀵煎叆") @PostMapping("/import") public CommonResult importUser(MultipartFile file) throws IOException { - EasyExcelUtils.importDepartFile(file); + EasyExcel.read(file.getInputStream()) + .head(UmsAdminParamDto.class) + .registerReadListener(new ReadListener<UmsAdminParamDto>() { + @Override + public void invoke(UmsAdminParamDto item, AnalysisContext analysisContext) { + UmsAdminParam param = new UmsAdminParam(); + param.setUsername(item.getUsername()); + param.setPassword(item.getPassword()); + param.setNickName(item.getNickName()); + + String sex = item.getSex(); + if (sex.equals("鐢�")){ + param.setSex((byte) 1); + } else if (sex.equals("濂�")) { + param.setSex((byte) 0); + }else { + throw new RuntimeException("鎬у埆杈撳叆鏈夎"); + } + + String isDy = item.getIsDy(); + if (isDy.equals("鏄�")){ + param.setSex((byte) 1); + } else if (isDy.equals("鍚�")) { + param.setSex((byte) 0); + }else { + throw new RuntimeException("鍏氬憳杈撳叆鏈夎"); + } + + param.setMobile(item.getMobile()); + param.setEmail(item.getEmail()); + + String role = item.getRole(); + UmsRole umsRole = umsRoleMapper.selectOne(new LambdaQueryWrapper<UmsRole>().eq(UmsRole::getName, role)); + if (Objects.isNull(umsRole)){ + param.setRoleIds(null); + }else { + List list = new ArrayList<>(); + list.add(umsRole.getId()); + param.setRoleIds(list); + } + + String userType = item.getUserType(); + DataDictionary dataDictionary = dataDictionaryMapper.selectOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getName, userType)); + if (Objects.isNull(dataDictionary)){ + throw new RuntimeException("鐢ㄦ埛绫诲瀷涓嶅瓨鍦�"); + }else { + param.setUserType(dataDictionary.getId().intValue()); + } + + String department = item.getDepartment(); + UmsDepart umsDepart = umsDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, department)); + if (Objects.isNull(umsDepart)){ + throw new RuntimeException("閮ㄩ棬涓嶅瓨鍦�"); + }else { + param.setDepartmentId(umsDepart.getId()); + } + + param.setJobTitle(item.getJobTitle()); + + adminService.importExcl(param); + + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } + }).sheet().doRead(); return CommonResult.success(true, "瀵煎叆鎴愬姛"); } diff --git a/ycl-common/src/main/java/com/ycl/dto/user/UmsAdminParamDto.java b/ycl-common/src/main/java/com/ycl/dto/user/UmsAdminParamDto.java new file mode 100644 index 0000000..1b0c03a --- /dev/null +++ b/ycl-common/src/main/java/com/ycl/dto/user/UmsAdminParamDto.java @@ -0,0 +1,47 @@ +package com.ycl.dto.user; + +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class UmsAdminParamDto { + + @ExcelProperty(value = "鐢ㄦ埛鍚�", index = 0) + private String username; + + @ExcelProperty(value = "瀵嗙爜", index = 1) + private String password; + + @ExcelProperty(value = "鐪熷疄濮撳悕", index = 2) + private String nickName; + + @ExcelProperty(value = "鎬у埆,杈撳叆锛氱敺锛屽コ", index = 3) + private String sex; + + @ExcelProperty(value = "鍏氬憳,杈撳叆锛氭槸锛屽惁",index = 4) + private String isDy; + + @ExcelProperty(value = "鎵嬫満鍙风爜", index = 5) + private String mobile; + + @ExcelProperty(value = "閭", index = 6) + private String email; + + @ExcelProperty(value = "瑙掕壊", index = 7) + private String role; + + @ExcelProperty(value = "鐢ㄦ埛绫诲瀷", index = 8) + private String userType; + + @ExcelProperty(value = "鎵�灞為儴闂�", index = 9) + private String department; + + @ExcelProperty(value = "褰撳墠鑱屽姟", index = 10) + private String jobTitle; +} diff --git a/ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java b/ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto.java similarity index 97% rename from ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java rename to ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto.java index 7b7ce19..58a4c70 100644 --- a/ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java +++ b/ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto.java @@ -1,4 +1,4 @@ -package com.ycl.dto; +package com.ycl.dto.user; import com.alibaba.excel.annotation.ExcelProperty; import com.ycl.entity.depart.UmsDepart; diff --git a/ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java b/ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto1.java similarity index 73% copy from ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java copy to ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto1.java index 7b7ce19..626e90b 100644 --- a/ycl-common/src/main/java/com/ycl/dto/UmsUserDto.java +++ b/ycl-common/src/main/java/com/ycl/dto/user/UmsUserDto1.java @@ -1,22 +1,16 @@ -package com.ycl.dto; +package com.ycl.dto.user; import com.alibaba.excel.annotation.ExcelProperty; -import com.ycl.entity.depart.UmsDepart; -import com.ycl.entity.user.UmsRole; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; -import java.util.Date; -import java.util.List; - @Data @AllArgsConstructor @NoArgsConstructor @Builder -public class UmsUserDto { - +public class UmsUserDto1 { @ExcelProperty(value = "鐢ㄦ埛ID", index = 0) private Long id; @@ -30,17 +24,17 @@ private String mobile; @ExcelProperty(value = "鎵�灞炶鑹�", index = 4) - private List<UmsRole> roles; + private String roles; @ExcelProperty(value = "鎵�灞為儴闂�", index = 5) - private List<UmsDepart> depart; + private String depart; @ExcelProperty(value = "鎵�灞炶亴鍔�", index = 6) private String jobTitle; @ExcelProperty(value = "鍒涘缓鏃堕棿", index = 7) - private Date createTime; + private String createTime; @ExcelProperty(value = "鏄惁鍚敤", index = 8) - private Integer status; + private String status; } diff --git a/ycl-common/src/main/java/com/ycl/mapper/user/UmsAdminMapper.java b/ycl-common/src/main/java/com/ycl/mapper/user/UmsAdminMapper.java index fecdb07..0950b22 100644 --- a/ycl-common/src/main/java/com/ycl/mapper/user/UmsAdminMapper.java +++ b/ycl-common/src/main/java/com/ycl/mapper/user/UmsAdminMapper.java @@ -24,4 +24,6 @@ Page<UmsAdmin> selectCondPage(Page<UmsAdmin> page,UmsAdmin umsAdmin); + List<UmsAdmin> selectToExp(); + } diff --git a/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java b/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java index 837d69e..71a2f27 100644 --- a/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java +++ b/ycl-common/src/main/java/com/ycl/service/depart/impl/UmsDepartServiceImpl.java @@ -148,10 +148,10 @@ .map(item -> { UmsDepartDto umsDepartDto = new UmsDepartDto(); umsDepartDto.setId(item.getId()); - umsDepartDto.setParentDepartName(item.getDepartName()); + umsDepartDto.setDepartTypeName(item.getDepartName()); String departType = sccgDepartMapper.getDepartType(item.getDepartType()); umsDepartDto.setDepartType(departType); - UmsDepart umsDepartFather = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, item.getId())); + UmsDepart umsDepartFather = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getId, item.getParentId())); if (Objects.isNull(umsDepartFather)){ umsDepartDto.setParentDepartName(""); }else { diff --git a/ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java b/ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java index 5bb9f37..9fc5d34 100644 --- a/ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java +++ b/ycl-common/src/main/java/com/ycl/service/user/UmsAdminService.java @@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.ycl.dto.UmsAdminParam; -import com.ycl.dto.UmsUserDto; +import com.ycl.dto.user.UmsUserDto1; import com.ycl.dto.UpdateAdminPasswordParam; import com.ycl.entity.user.UmsAdmin; import com.ycl.entity.user.UmsMenu; @@ -29,6 +29,8 @@ * 娉ㄥ唽鍔熻兘 */ UmsAdmin register(UmsAdminParam umsAdminParam); + + void importExcl(UmsAdminParam umsAdminParam); /** * 鐧诲綍鍔熻兘 @@ -97,7 +99,7 @@ */ IPage<UmsAdmin> pageUser(UserVO.PageUserVO pageUserVO); - List<UmsUserDto> userExp(); + List<UmsUserDto1> userExp(); /** * 鎵归噺鍒犻櫎鐢ㄦ埛 diff --git a/ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java b/ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java index 3ba1f4d..d96a0ed 100644 --- a/ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java +++ b/ycl-common/src/main/java/com/ycl/service/user/impl/UmsAdminServiceImpl.java @@ -8,8 +8,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.bo.AdminUserDetails; import com.ycl.dto.UmsAdminParam; -import com.ycl.dto.UmsUserDto; +import com.ycl.dto.user.UmsUserDto1; import com.ycl.dto.UpdateAdminPasswordParam; +import com.ycl.entity.depart.UmsDepart; import com.ycl.entity.user.*; import com.ycl.exception.ApiException; import com.ycl.exception.Asserts; @@ -43,10 +44,11 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.function.Function; +import java.util.function.Consumer; import java.util.stream.Collectors; /** @@ -103,7 +105,7 @@ BeanUtils.copyProperties(umsAdminParam, umsAdmin); umsAdmin.setCreateTime(new Date()); umsAdmin.setStatus(1); - umsAdmin.setMacAddress(MacUtils.getMac()); +// umsAdmin.setMacAddress(MacUtils.getMac()); //鏌ヨ鏄惁鏈夌浉鍚岀敤鎴峰悕鐨勭敤鎴� QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); wrapper.lambda().eq(UmsAdmin::getUsername, umsAdmin.getUsername()); @@ -119,6 +121,57 @@ } if(umsAdmin.getUsername().equals(umsAdmin.getPassword())){ Asserts.fail("瀵嗙爜涓嶈兘鍜岀櫥褰曞悕瀹屽叏涓�鑷�"); + } + umsAdmin.setPassword(encodePassword); + baseMapper.insert(umsAdmin); + + //娣诲姞瑙掕壊鎺堟潈 + List<Long> ids = umsAdminParam.getRoleIds(); + if (!ids.isEmpty()) { + List<UmsAdminRoleRelation> roleIds = new ArrayList<>(); + for (Long id : ids) { + UmsAdminRoleRelation urr = new UmsAdminRoleRelation(); + urr.setAdminId(umsAdmin.getId()); + urr.setRoleId(id); + roleIds.add(urr); + } + umsAdminRoleRelationService.saveBatch(roleIds); + } + + //娣诲姞閮ㄩ棬 + UmsDepartManage departManage = new UmsDepartManage(); + departManage.setUserId(umsAdmin.getId()); + departManage.setDepartId(umsAdminParam.getDepartmentId()); + departManage.setCreateTime(new Date()); + departManage.setUpdateTime(new Date()); + umsDepartManageMapper.insert(departManage); + + baseMapper.updateById(umsAdmin); + return umsAdmin; + } + + @Override + public void importExcl(UmsAdminParam umsAdminParam) { + UmsAdmin umsAdmin = new UmsAdmin(); + BeanUtils.copyProperties(umsAdminParam, umsAdmin); + umsAdmin.setCreateTime(new Date()); + umsAdmin.setStatus(1); + umsAdmin.setMacAddress(MacUtils.getMac()); + //鏌ヨ鏄惁鏈夌浉鍚岀敤鎴峰悕鐨勭敤鎴� + QueryWrapper<UmsAdmin> wrapper = new QueryWrapper<>(); + wrapper.lambda().eq(UmsAdmin::getUsername, umsAdmin.getUsername()); + List<UmsAdmin> umsAdminList = list(wrapper); + if (umsAdminList.size() > 0) { + throw new RuntimeException("鐢ㄦ埛宸插瓨鍦�"); + } + //灏嗗瘑鐮佽繘琛屽姞瀵嗘搷浣� + String encodePassword = passwordEncoder.encode(umsAdmin.getPassword()); + + if ( !umsAdmin.getPassword().matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{8,16}$")) { + Asserts.fail("瀵嗙爜闀垮害8鍒�16浣嶄笖瀵嗙爜涓殑瀛楃蹇呴』鍖呭惈瀛楁瘝锛堝ぇ鍐欐垨鑰呭皬鍐欙級鍜屽繀椤诲寘鍚暟瀛楋紝涓嶈兘鍖呭惈绌烘牸"); + } + if(umsAdmin.getUsername().equals(umsAdmin.getPassword())){ + Asserts.fail("瀵嗙爜涓嶈兘鍜岀櫥褰曞悕瀹屽叏涓�鑷�"); } umsAdmin.setPassword(encodePassword); baseMapper.insert(umsAdmin); @@ -169,7 +222,6 @@ umsDepartManageMapper.insert(departManage); baseMapper.updateById(umsAdmin); - return umsAdmin; } @Override @@ -386,21 +438,50 @@ } @Override - public List<UmsUserDto> userExp() { - List<UmsAdmin> umsAdmins = baseMapper.selectList(null); - List<UmsUserDto> res = umsAdmins - .stream() + public List<UmsUserDto1> userExp() { + List<UmsAdmin> umsAdmins = baseMapper.selectToExp(); + List<UmsUserDto1> res = umsAdmins.stream() .map(item -> { - UmsUserDto res1 = new UmsUserDto(); + UmsUserDto1 res1 = new UmsUserDto1(); res1.setId(item.getId()); res1.setUsername(item.getUsername()); res1.setNickName(item.getNickName()); res1.setMobile(item.getMobile()); - res1.setRoles(item.getRoles()); - res1.setDepart(item.getDepart()); + StringBuffer roleStrBuffer = new StringBuffer(); + List<UmsRole> roles = item.getRoles(); + roles.forEach(new Consumer<UmsRole>() { + @Override + public void accept(UmsRole o) { + roleStrBuffer.append(o.getName()); + roleStrBuffer.append(","); + } + }); + roleStrBuffer.deleteCharAt(roleStrBuffer.length()-1); + res1.setRoles(roleStrBuffer.toString()); + StringBuffer departStrBuffer = new StringBuffer(); + List<UmsDepart> departs = item.getDepart(); + departs.forEach(new Consumer<UmsDepart>() { + @Override + public void accept(UmsDepart o) { + departStrBuffer.append(o.getDepartName()); + departStrBuffer.append(","); + } + }); + departStrBuffer.deleteCharAt(departStrBuffer.length()-1); + res1.setDepart(departStrBuffer.toString()); res1.setJobTitle(item.getJobTitle()); - res1.setCreateTime(item.getCreateTime()); - res1.setStatus(item.getStatus()); + Date createTime = item.getCreateTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + if (createTime != null){ + res1.setCreateTime(sdf.format(createTime)); + } + + Integer status = item.getStatus(); + if (status.equals(1)){ + res1.setStatus("鍚敤"); + }else { + res1.setStatus("绂佺敤"); + } return res1; }).collect(Collectors.toList()); return res; diff --git a/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java b/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java index d479f54..50156d9 100644 --- a/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java +++ b/ycl-common/src/main/java/com/ycl/utils/EasyExcelUtils.java @@ -14,7 +14,6 @@ public class EasyExcelUtils { - /** * @Description 瀵煎嚭 * @Param [response , sheetName sheet鍚嶅瓧, className 绫诲悕, collection data] diff --git a/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java b/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java index 9f8ab55..2dca4cf 100644 --- a/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java +++ b/ycl-common/src/main/java/com/ycl/utils/listener/DepartListener.java @@ -7,8 +7,10 @@ import com.ycl.entity.depart.UmsDepart; import com.ycl.mapper.depart.UmsDepartMapper; import com.ycl.mapper.dict.DataDictionaryMapper; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import javax.annotation.Resource; import java.util.Objects; @@ -17,10 +19,17 @@ @Resource private UmsDepartMapper sccgDepartMapper; - @Resource - DataDictionaryMapper dataDictionaryMapper; + private DataDictionaryMapper dataDictionaryMapper; +// private static DepartListener departListener; +// +// @PostConstruct +// public void init(){ +// departListener = this; +// departListener.sccgDepartMapper = this.sccgDepartMapper; +// departListener.dataDictionaryMapper = this.dataDictionaryMapper; +// } @Override public void invoke(UmsDepartDto umsDepartDto, AnalysisContext analysisContext) { @@ -40,10 +49,12 @@ umsDepart.setDepartDes(umsDepartDto.getDepartDes()); // 璁剧疆閮ㄩ棬绫诲瀷 -// LambdaQueryWrapper<DataDictionary> dataDictionaryLambdaQueryWrapper = new LambdaQueryWrapper<DataDictionary>(DataDictionary::getName, umsDepartDto.getDepartTypeName()); -//// DataDictionary dataDictionary = dataDictionaryMapper.selectOne(new LambdaQueryWrapper(DataDictionary)); -//// sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>(UmsDepart::getDepartType)) -//// umsDepart.setDepartType(umsDepartDto.getDepartType()); + DataDictionary dataDictionary = dataDictionaryMapper.selectOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getName, umsDepartDto.getDepartType())); + if (Objects.isNull(dataDictionary)){ + throw new RuntimeException("閮ㄩ棬绫诲瀷涓嶅瓨鍦�"); + }else { + umsDepart.setDepartType(new Long(dataDictionary.getId()).intValue()); + } // 璁剧疆鐖秈d UmsDepart two = sccgDepartMapper.selectOne(new LambdaQueryWrapper<UmsDepart>().eq(UmsDepart::getDepartName, umsDepartDto.getParentDepartName())); diff --git a/ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml b/ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml index 78369f0..77fdbc8 100644 --- a/ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml +++ b/ycl-common/src/main/resources/mapper/user/UmsAdminMapper.xml @@ -99,4 +99,23 @@ left join ums_role ur on uarr.role_id = ur.id where ua.id = #{id} </select> + <select id="selectToExp" resultType="com.ycl.entity.user.UmsAdmin" resultMap="CondMapResultMap"> + SELECT + ua.*, + ud.id depart_id, + ud.depart_name, + ud.depart_des, + ud.depart_type, + ud.parent_id, + ud.create_time depat_create_time, + ud.update_time depat_update_time, + ud.STATUS depart_status, + ud.is_deleted + FROM + ums_admin ua + LEFT JOIN ums_depart_manager udm ON ua.id = udm.user_id + LEFT JOIN ums_depart ud ON udm.depart_id = ud.id + ORDER BY + ua.id DESC + </select> </mapper> -- Gitblit v1.8.0