| | |
| | | package com.consum.base.controller; |
| | | |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import java.io.IOException; |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.event.AnalysisEventListener; |
| | | import com.alibaba.excel.exception.ExcelDataConvertException; |
| | | import com.consum.base.BaseController; |
| | | import com.consum.base.core.utils.CommonUtil; |
| | | import com.consum.base.core.utils.MapperUtil; |
| | | import com.consum.base.pojo.FinSysTenantUserSearchParam; |
| | | import com.consum.base.pojo.FinSysTenantUserUpdParam; |
| | |
| | | import com.walker.infrastructure.utils.PhoneNumberUtils; |
| | | import com.walker.infrastructure.utils.StringUtils; |
| | | import com.walker.web.ResponseValue; |
| | | |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import java.io.IOException; |
| | | import java.lang.reflect.Field; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.HashMap; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import org.apache.commons.compress.utils.Lists; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | /** |
| | | * @Description 系统用户 |
| | |
| | | |
| | | private UserServiceImpl userService; |
| | | |
| | | |
| | | private FinSysTenantServiceImpl finSysTenantService; |
| | | |
| | | private RoleServiceImpl roleService; |
| | |
| | | @Autowired |
| | | private FinSysTenantDepartmentService finSysTenantDepartmentService; |
| | | |
| | | |
| | | @Autowired |
| | | public void setUserService(UserServiceImpl userService) { |
| | | this.userService = userService; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | public FinSysTenantUserController(FinSysTenantServiceImpl finSysTenantService, FinSysTenantUserServiceImpl finSysTenantUserService, |
| | | RoleServiceImpl roleService) { |
| | | public FinSysTenantUserController(FinSysTenantServiceImpl finSysTenantService, |
| | | FinSysTenantUserServiceImpl finSysTenantUserService, RoleServiceImpl roleService) { |
| | | this.finSysTenantUserService = finSysTenantUserService; |
| | | this.finSysTenantService = finSysTenantService; |
| | | this.roleService = roleService; |
| | |
| | | * @Date 2023/7/11 13:59 |
| | | */ |
| | | @RequestMapping("/select/list") |
| | | public ResponseValue allocatedList(FinSysTenantUserSearchParam param) { |
| | | public ResponseValue allocatedList() { |
| | | FinSysTenantUserSearchParam param = CommonUtil.getObjFromReq(FinSysTenantUserSearchParam.class); |
| | | FinSysTenantUserSearchParam param2 = new FinSysTenantUserSearchParam(); |
| | | CommonUtil.copyProperties(param, param2); |
| | | param = param2; |
| | | if (param.getTenantCode() == 0) { |
| | | FinSysTenantUser user = new FinSysTenantUser(); |
| | | Long id = this.getCurrentUser().getId(); |
| | |
| | | ReflectUtil.setFieldValue(pager, fieldDatas, resultList); |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | logger.error("分页列表查询失败,原因:" + e); |
| | | } |
| | | return ResponseValue.success(pager); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "根据机构id查询用户", notes = "根据机构id查询用户") |
| | | @ApiImplicitParam(name = "tenantId", value = "机构id", required = true, dataType = "Long", paramType = "query") |
| | |
| | | return ResponseValue.success(result); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 新增 |
| | | * @Author wh |
| | |
| | | */ |
| | | @PostMapping("/add") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResponseValue add(@RequestBody FinSysTenantUser user) { |
| | | public ResponseValue add() { |
| | | FinSysTenantUser user = CommonUtil.getObjFromReqBody(FinSysTenantUser.class); |
| | | FinSysTenantUser formInventoryParam = new FinSysTenantUser(); |
| | | CommonUtil.copyProperties(user, formInventoryParam); |
| | | user = formInventoryParam; |
| | | if (user == null) { |
| | | return ResponseValue.error("参数为空"); |
| | | } |
| | | //根据员工编号查询,如果存在则提示 |
| | | if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { |
| | | if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null |
| | | && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { |
| | | return ResponseValue.error("员工编号重复"); |
| | | } |
| | | if (user.getTenantId() == null || "".equals(user.getTenantId()) || new Integer(user.getTenantId()) == 0) { |
| | |
| | | return ResponseValue.success(1); |
| | | } |
| | | |
| | | |
| | | public static class ImportUserParam { |
| | | |
| | | @ExcelProperty("用户姓名") |
| | |
| | | * @Date 2023/10/12 15:56 |
| | | */ |
| | | @PostMapping("/import") |
| | | public ResponseValue importUser(@RequestParam String tenantId, @RequestParam String tenantCode, MultipartFile file) throws IOException { |
| | | public ResponseValue importUser(@RequestParam String tenantId, @RequestParam String tenantCode, MultipartFile file) |
| | | throws IOException { |
| | | String originalFilename = file.getOriginalFilename(); |
| | | if (!"xls".equals(originalFilename.substring(originalFilename.lastIndexOf(".") + 1))) { |
| | | return ResponseValue.error("文件格式有误!"); |
| | |
| | | EasyExcel.read(file.getInputStream(), ImportUserParam.class, new AnalysisEventListener<ImportUserParam>() { |
| | | @Override |
| | | public void invoke(ImportUserParam data, AnalysisContext context) { |
| | | if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) || StringUtils.isEmpty(data.getUserPhone()) |
| | | || null == data.getSex() || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() || StringUtils.isEmpty(data.getRoleName())) { |
| | | if (StringUtils.isEmpty(data.getUserName()) || StringUtils.isEmpty(data.getUserCode()) |
| | | || StringUtils.isEmpty(data.getUserPhone()) || null == data.getSex() |
| | | || StringUtils.isEmpty(data.getEmail()) || null == data.getSeq() |
| | | || StringUtils.isEmpty(data.getRoleName())) { |
| | | throw new ImportUserParamVerifyException("单元格不能为空!"); |
| | | } |
| | | //根据员工编号查询,如果存在则提示 |
| | |
| | | user.setTenantId(tenantId); |
| | | user.setTenantCode(tenantCode); |
| | | //设置角色 |
| | | Optional<S_role> sRole = roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); |
| | | Optional<S_role> sRole = |
| | | roles.stream().filter(role -> role.getRole_name().equals(data.getRoleName())).findFirst(); |
| | | user.setRoleList(Arrays.asList(sRole.orElse(new S_role()).getRole_id())); |
| | | |
| | | user.setId(NumberGenerator.getLongSequenceNumber()); |
| | |
| | | // 如果是某一个单元格的转换异常 能获取到具体行号 封装时异常 |
| | | if (exception instanceof ExcelDataConvertException) { |
| | | ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception; |
| | | logger.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), excelDataConvertException.getColumnIndex() + 1, |
| | | logger.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(), |
| | | excelDataConvertException.getColumnIndex() + 1, |
| | | excelDataConvertException.getCellData().getStringValue()); |
| | | throw new IllegalStateException( |
| | | "第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ " |
| | | throw new IllegalStateException("第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" |
| | | + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ " |
| | | + excelDataConvertException.getCellData().getStringValue() + " ]"); |
| | | } |
| | | if (exception instanceof ImportUserParamVerifyException) { |
| | | throw new IllegalStateException("第" + context.readSheetHolder().getRowIndex() + "行, 解析错误:[ " + exception.getMessage() + " ]"); |
| | | throw new IllegalStateException("第" + context.readSheetHolder().getRowIndex() + "行, 解析错误:[ " |
| | | + exception.getMessage() + " ]"); |
| | | } |
| | | throw exception; |
| | | } |
| | |
| | | super(message); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 编辑 |
| | |
| | | } |
| | | |
| | | // 查询 用户角色 TODO 临时解决 将来放配置文件中 |
| | | List<S_role> list = finSysTenantUserService.getByUserId(sysInfo.getSysUserId()); //已有的权限 |
| | | // 已有的权限 |
| | | List<S_role> list = finSysTenantUserService.getByUserId(sysInfo.getSysUserId()); |
| | | for (S_role s_role : list) { |
| | | if (s_role.getRole_id() != null && s_role.getRole_id().equals(1690961420053L)) { |
| | | sysInfo.setKfStatus(1); |
| | |
| | | if (select != null && select.size() > 0) { |
| | | FinSysTenant finSysTenant = select.get(0); |
| | | if (finSysTenant != null && finSysTenant.getParentId() != null) { |
| | | List<FinSysTenant> parents = finSysTenantService.select(new FinSysTenant(finSysTenant.getParentId())); |
| | | List<FinSysTenant> parents = |
| | | finSysTenantService.select(new FinSysTenant(finSysTenant.getParentId())); |
| | | if (parents != null && parents.size() > 0) { |
| | | sysInfo.setParentCode(parents.get(0).getCode()); |
| | | } |
| | |
| | | } |
| | | return ResponseValue.success(sysInfo); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新角色权限 |
| | |
| | | return ResponseValue.success(1); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description 新增 |
| | | * @Author llb |
| | |
| | | return ResponseValue.error(roleName + "的角色不存在"); |
| | | } |
| | | //根据员工编号查询,如果存在则提示 |
| | | if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { |
| | | if (finSysTenantUserService.getByUserCode(user.getUserCode()) != null |
| | | && finSysTenantUserService.getByUserCode(user.getUserCode()) > 0) { |
| | | return ResponseValue.error("员工编号重复"); |
| | | } |
| | | FinSysTenantUser sysInfo = this.getSysInfo(); |
| | |
| | | return ResponseValue.success(1); |
| | | } |
| | | |
| | | private Set<String> picFormatArr = new HashSet<String>() {{ |
| | | private Set<String> picFormatArr = new HashSet<String>() { |
| | | { |
| | | add(".pjp"); |
| | | add(".svgz"); |
| | | add(".jxl"); |
| | |
| | | add(".pjpeg"); |
| | | add(".bmp"); |
| | | add(".webp"); |
| | | }}; |
| | | } |
| | | }; |
| | | |
| | | @PostMapping("/updatePerson") |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | |
| | | @ApiOperation(value = "根据机构id查询部门中的用户", notes = "根据机构id查询部门中的用户") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "agencyId", value = "机构id", required = true, dataType = "Long", paramType = "query") |
| | | }) |
| | | @ApiImplicitParam(name = "agencyId", value = "机构id", required = true, dataType = "Long", paramType = "query")}) |
| | | @GetMapping("/select/department") |
| | | public ResponseValue selectDepartment(Long agencyId) { |
| | | FinSysTenantVO finSysTenantVO = new FinSysTenantVO(); |
| | |
| | | // 部门 |
| | | FinSysTenantDepartment finSysTenantDepartment = new FinSysTenantDepartment(); |
| | | finSysTenantDepartment.setTenantId(agencyId); |
| | | List<FinSysTenantDepartment> tenantDepartmentList = finSysTenantDepartmentService.select(finSysTenantDepartment); |
| | | List<FinSysTenantDepartment> tenantDepartmentList = |
| | | finSysTenantDepartmentService.select(finSysTenantDepartment); |
| | | List<DepartmentVO> departmentVOList = Lists.newArrayList(); |
| | | tenantDepartmentList.forEach(department -> { |
| | | DepartmentVO departmentVO = new DepartmentVO(); |
| | |
| | | departmentVO.setName(department.getName()); |
| | | departmentVO.setType("department"); |
| | | |
| | | String sql = "SELECT SYS_USER_ID,USER_NAME FROM " |
| | | + "fin_sys_tenant_user " |
| | | String sql = "SELECT SYS_USER_ID,USER_NAME FROM " + "fin_sys_tenant_user " |
| | | + "WHERE SYS_DEPT_ID =:deptId AND SYS_USER_ID NOT IN(SELECT MANAGER_ID FROM base_warehouse_manager)"; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("deptId", id); |
| | |
| | | |
| | | return ResponseValue.success(finSysTenantVO); |
| | | } |
| | | |
| | | |
| | | } |