| | |
| | | |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.dto.BasicDataDTO; |
| | | import com.ruoyi.system.query.ScoreQuery; |
| | | import com.ruoyi.system.service.TbBasicDataService; |
| | |
| | | |
| | | @ApiOperation("获取基础数据填报相关信息") |
| | | @GetMapping("/basic-fields") |
| | | public R<BasicDataReportingVO> getBasicFields(@RequestParam("deptAreaCode") String deptAreaCode) { |
| | | //TODO 如果能够获取到当前登录用户,则不需要传区划代码 |
| | | public R<BasicDataReportingVO> getBasicFields() { |
| | | try { |
| | | return tbBasicDataService.getBasicFields(deptAreaCode); |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | String areaCode = user.getAreaCode(); |
| | | return tbBasicDataService.getBasicFields(areaCode); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | |
| | | */ |
| | | @GetMapping("/download") |
| | | @ApiOperation("模板下载") |
| | | public R<Void> downloadImportTemplate() { |
| | | public void downloadImportTemplate() { |
| | | try { |
| | | tbBasicDataService.downloadImportTemplate(); |
| | | } catch (Exception e) { |
| | | log.error("模板下载异常",e); |
| | | return R.fail("模板下载失败,请联系管理员!"); |
| | | throw new ServiceException("模板下载失败,请联系管理员!"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/import") |
New file |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/4/1 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/history-data") |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "历史数据相关接口") |
| | | public class HistoryDataController { |
| | | |
| | | } |
| | |
| | | package com.ruoyi.web.controller.interceptor; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | @Configuration |
| | |
| | | /** |
| | | * 注册拦截器 |
| | | */ |
| | | @Bean |
| | | /* @Bean |
| | | public MybatisInterceptor getMybatisInterceptor() { |
| | | return new MybatisInterceptor(); |
| | | } |
| | | }*/ |
| | | |
| | | } |
| | |
| | | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.executor.Executor; |
| | | import org.apache.ibatis.mapping.MappedStatement; |
| | | import org.apache.ibatis.mapping.SqlCommandType; |
| | | import org.apache.ibatis.plugin.*; |
| | | import org.apache.ibatis.plugin.Interceptor; |
| | | import org.apache.ibatis.plugin.Invocation; |
| | | import org.apache.ibatis.plugin.Plugin; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) }) |
| | | /*@Component |
| | | @Intercepts({ @Signature(type = Executor.class, method = "update", args = { MappedStatement.class, Object.class }) })*/ |
| | | public class MybatisInterceptor implements Interceptor { |
| | | |
| | | @Autowired |
| | |
| | | //注入创建时间 |
| | | if ("createTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | field.set(parameter, LocalDateTime.now()); |
| | | field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | if ("updateTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | field.set(parameter, LocalDateTime.now()); |
| | | field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | // 生成令牌 |
| | | LoginUser loginUser = loginService.loginPwd(loginBody.getUsername(), loginBody.getPassword(),loginBody.getCode(),loginBody.getUuid()); |
| | | ajax.put(Constants.TOKEN, tokenService.createToken(loginUser)); |
| | | List<SysRole> roles = loginUser.getUser().getRoles(); |
| | | if(CollectionUtils.isEmpty(roles)){ |
| | | return AjaxResult.error("请关联角色!"); |
| | | } |
| | | List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | //List<SysRole> roles = loginUser.getUser().getRoles(); |
| | | //if(CollectionUtils.isEmpty(roles)){ |
| | | // return AjaxResult.error("请关联角色!"); |
| | | //} |
| | | //List<SysMenu> menus = roleService.roleInfoFromUserId(loginUser.getUserId()); |
| | | |
| | | ajax.put("menus",menus); |
| | | ajax.put("roleName",roles.get(0).getRoleName()); |
| | | //ajax.put("menus",menus); |
| | | //ajax.put("roleName",roles.get(0).getRoleName()); |
| | | ajax.put("userInfo",loginUser); |
| | | return ajax; |
| | | } |
| | |
| | | SysUser currentUser = loginUser.getUser(); |
| | | currentUser.setNickName(user.getNickName()); |
| | | currentUser.setEmail(user.getEmail()); |
| | | currentUser.setPhonenumber(user.getPhonenumber()); |
| | | currentUser.setPhoneNumber(user.getPhoneNumber()); |
| | | currentUser.setSex(user.getSex()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import com.ruoyi.system.vo.UserAddListVO; |
| | | import com.ruoyi.system.vo.UserLevelVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | | List<SysUser> list = userService.queryList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | |
| | | // if(StringUtils.isNotEmpty(name) && type == 3){ |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId()) |
| | | // && ((StringUtils.isNotEmpty(e.getNickName()) && e.getNickName().contains(name))) |
| | | // || (StringUtils.isNotEmpty(e.getPhonenumber()) && e.getPhonenumber().contains(name))).collect(Collectors.toList()); |
| | | // || (StringUtils.isNotEmpty(e.getPhoneNumber()) && e.getPhoneNumber().contains(name))).collect(Collectors.toList()); |
| | | // }else { |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId())).collect(Collectors.toList()); |
| | | // } |
| | |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | user.setUserName(user.getPhoneNumber()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | else if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | user.setUserName(user.getPhoneNumber()); |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | else if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | max-wait: -1ms |
| | | jackson: |
| | | default-property-inclusion: non_null |
| | | deserialization: |
| | | read-unknown-enum-values-as-null: true |
| | | |
| | | # token配置 |
| | | token: |
| | | # 令牌自定义标识 |
| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.ExcelUtil; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.system.dto.update.DeptFocusDTO; |
| | | import com.ruoyi.system.dto.update.DeptUpdateDTO; |
| | | import com.ruoyi.system.query.DeptQuery; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TbDeptService; |
| | | import com.ruoyi.system.vo.DeptVO; |
| | | import com.ruoyi.web.controller.excel.DeptExcel; |
| | | import com.ruoyi.web.controller.lisenter.DeptImportListener; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | import java.util.Optional; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private final HttpServletResponse response; |
| | | private final TbDeptService tbDeptService; |
| | | |
| | | private final ISysUserService sysUserService; |
| | | /** |
| | | * 导入模板下载 |
| | | */ |
| | |
| | | @ApiOperation("模板下载") |
| | | public void download() { |
| | | try { |
| | | ArrayList<TbDept> list = new ArrayList<>(); |
| | | ExcelUtil.exportExcel(list, "部门导入模板", "部门导入模板", TbDept.class, "部门导入模板", response); |
| | | //ArrayList<TbDept> list = new ArrayList<>(); |
| | | //ExcelUtil.exportExcel(list, "部门导入模板", "部门导入模板", TbDept.class, "部门导入模板", response); |
| | | // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 |
| | | String fileName = URLEncoder.encode("部门导入模板", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), DeptExcel.class).sheet("模板").doWrite(CollUtils.emptyList()); |
| | | } catch (Exception e) { |
| | | log.error("模板下载异常",e); |
| | | throw new ServiceException("模板下载失败,请联系管理员!"); |
| | |
| | | */ |
| | | @PostMapping("/import") |
| | | @ApiOperation("导入") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Void> importExcel(@RequestPart("file")MultipartFile file) { |
| | | try { |
| | | tbDeptService.importExcel(file); |
| | | //tbDeptService.importExcel(file); |
| | | InputStream inputStream = file.getInputStream(); |
| | | EasyExcel.read(inputStream, DeptExcel.class, new DeptImportListener(sysUserService)).sheet().doRead(); |
| | | inputStream.close(); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | |
| | | |
| | | /** |
| | | * 根据id查询部门详情 |
| | | * @param id 部门id |
| | | * @param userId 部门id |
| | | * @return DeptVO |
| | | */ |
| | | @GetMapping("/get-details") |
| | | @ApiOperation("根据id查询部门详情") |
| | | public R<DeptVO> getDetails(@RequestParam Integer id) { |
| | | public R<DeptVO> getDetails(@RequestParam Long userId) { |
| | | try { |
| | | TbDept dept = tbDeptService.getById(id); |
| | | return R.ok(BeanUtils.copyBean(dept,DeptVO.class)); |
| | | Optional<SysUser> sysUser = sysUserService.lambdaQuery().eq(SysUser::getUserId, userId).oneOpt(); |
| | | if (sysUser.isPresent()) { |
| | | return R.ok(BeanUtils.copyBean(sysUser.get(),DeptVO.class)); |
| | | } |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | |
| | | log.error("根据id查询部门详情异常", e); |
| | | return R.fail(); |
| | | } |
| | | return R.ok(new DeptVO()); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @PostMapping("/edit") |
| | | @ApiOperation("编辑") |
| | | public R<Object> edit(@RequestBody DeptUpdateDTO dto){ |
| | | public R<Void> edit(@RequestBody DeptUpdateDTO dto){ |
| | | try { |
| | | TbDept tbDept = BeanUtils.copyBean(dto, TbDept.class); |
| | | tbDeptService.updateById(tbDept); |
| | | dto.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); |
| | | sysUserService.lambdaUpdate().set(SysUser::getAreaAlias, dto.getAreaAlias()) |
| | | .set(SysUser::getPersonInCharge, dto.getPersonInCharge()) |
| | | .set(SysUser::getPhoneNumber, dto.getPhoneNumber()) |
| | | .set(SysUser::getUserName, dto.getUserName()) |
| | | .set(SysUser::getPassword, dto.getPassword()) |
| | | .eq(SysUser::getUserId, dto.getUserId()) |
| | | .update(); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | return R.fail(e.getMessage()); |
| | |
| | | tbDeptService.focus(dto); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 部门未上传季度数据提示 |
| | | * @return Void |
| | | */ |
| | | @PostMapping("/reporting-message") |
| | | @ApiOperation(value = "部门未上传季度数据提示",notes = "code=200不展示,code=500 展示返回的msg") |
| | | public R<Void> reportingMessage(){ |
| | | return tbDeptService.reportingMessage(); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | @GetMapping("/get-details") |
| | | @ApiOperation("根据id获取字段分类详情") |
| | | public R<FieldCategoryDetailVO> getById(@RequestParam(value = "id") Integer id) { |
| | | public R<FieldCategoryDetailVO> getById(@RequestParam(value = "id") Long id) { |
| | | try { |
| | | FieldCategoryDetailVO vo = tbFieldCategoryService.getDetailsById(id); |
| | | return R.ok(vo); |
| | |
| | | */ |
| | | @DeleteMapping("/delete-children") |
| | | @ApiOperation("编辑页面删除子字段分类") |
| | | public R<Object> deleteChildren(@RequestParam(value = "id") Integer id){ |
| | | public R<Object> deleteChildren(@RequestParam(value = "id") Long id){ |
| | | try { |
| | | tbFieldCategoryService.deleteChildren(id); |
| | | } catch (Exception e) { |
| | |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("列表页面删除分类") |
| | | public R<Void> delete(@RequestParam(value = "id") Integer id){ |
| | | public R<Void> delete(@RequestParam(value = "id") Long id){ |
| | | try { |
| | | tbFieldCategoryService.delete(id); |
| | | } catch (Exception e) { |
| | |
| | | */ |
| | | @GetMapping("/categories") |
| | | @ApiOperation(value = "获取分类列表",notes = "一级分类id传0,二级分类传一级分类id,三级分类同理") |
| | | public R<List<FieldCategoryVO>> queryFieldCategories(@RequestParam Integer id) { |
| | | public R<List<FieldCategoryVO>> queryFieldCategories(@RequestParam Long id) { |
| | | try { |
| | | return R.ok(tbFieldCategoryService.queryFieldCategories(id)); |
| | | } catch (Exception e) { |
| | |
| | | |
| | | @GetMapping("/influenced-data") |
| | | @ApiOperation("隐藏字段,获取同步隐藏的基础数据") |
| | | public R<String> influencedData(@RequestParam Integer id) { |
| | | public R<String> influencedData(@RequestParam Long id) { |
| | | try { |
| | | return R.ok(tbFieldService.influencedData(id)); |
| | | } catch (Exception e) { |
| | |
| | | */ |
| | | @GetMapping("/get-details") |
| | | @ApiOperation("获取详情") |
| | | public R<FieldVO> getDetails(@RequestParam Integer id){ |
| | | public R<FieldVO> getDetails(@RequestParam Long id){ |
| | | try { |
| | | TbField field = tbFieldService.getById(id); |
| | | return R.ok(BeanUtils.copyBean(field, FieldVO.class)); |
| | |
| | | */ |
| | | @DeleteMapping("/delete") |
| | | @ApiOperation("删除") |
| | | public R<Void> delete(@RequestParam Integer id){ |
| | | public R<Void> delete(@RequestParam Long id){ |
| | | try { |
| | | tbFieldService.removeById(id); |
| | | } catch (Exception e) { |
New file |
| | |
| | | package com.ruoyi.web.controller.conveter; |
| | | |
| | | import com.alibaba.excel.converters.Converter; |
| | | import com.alibaba.excel.enums.CellDataTypeEnum; |
| | | import com.alibaba.excel.metadata.GlobalConfiguration; |
| | | import com.alibaba.excel.metadata.data.ReadCellData; |
| | | import com.alibaba.excel.metadata.data.WriteCellData; |
| | | import com.alibaba.excel.metadata.property.ExcelContentProperty; |
| | | import com.ruoyi.common.enums.DisabledEnum; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/28 |
| | | */ |
| | | public class CountyFlagConverter implements Converter<DisabledEnum> { |
| | | @Override |
| | | public Class<?> supportJavaTypeKey() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public CellDataTypeEnum supportExcelTypeKey() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public DisabledEnum convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | if (cellData.toString().equals("是")) { |
| | | return DisabledEnum.YES; |
| | | } else { |
| | | return DisabledEnum.NO; |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public WriteCellData<?> convertToExcelData(DisabledEnum value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception { |
| | | return Converter.super.convertToExcelData(value, contentProperty, globalConfiguration); |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.web.controller.excel; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.ruoyi.common.enums.DisabledEnum; |
| | | import com.ruoyi.web.controller.conveter.CountyFlagConverter; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * <p> |
| | | * 部门管理表 |
| | | * </p> |
| | | * |
| | | * @author mitao |
| | | * @since 2024-03-13 |
| | | */ |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = false) |
| | | @ApiModel(value="部门导入Excel对象") |
| | | public class DeptExcel implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | @ApiModelProperty(value = "部门地区") |
| | | @Excel(name = "部门地区") |
| | | @ExcelProperty(value = "部门地区",index = 0) |
| | | private String areaName; |
| | | |
| | | @ApiModelProperty(value = "别名") |
| | | @Excel(name = "别名") |
| | | @ExcelProperty(value = "别名",index = 1) |
| | | private String areaAlias; |
| | | |
| | | @ApiModelProperty(value = "区划代码") |
| | | @Excel(name = "区划代码") |
| | | @ExcelProperty(value = "区划代码",index = 2) |
| | | private String areaCode; |
| | | |
| | | @ApiModelProperty(value = "级次(省、市、县)") |
| | | @Excel(name = "级次(省、市、县)") |
| | | @ExcelProperty(value = "级次 (省、市、县)",index = 3) |
| | | private String areaLevel; |
| | | |
| | | @ApiModelProperty(value = "县级标志(不包含直辖市的区 0:否 1:是)") |
| | | @Excel(name = "县级标志 是/否",enumImportMethod = "getByDesc") |
| | | @ExcelProperty(value = "县级标志 是/否",index = 4,converter = CountyFlagConverter.class) |
| | | private DisabledEnum countyFlag; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | @Excel(name = "登录账号") |
| | | @ExcelProperty(value = "登录账号",index = 6) |
| | | private String userName; |
| | | |
| | | @ApiModelProperty(value = "负责人姓名") |
| | | @ExcelProperty(value = "负责人姓名",index = 5) |
| | | private String personInCharge; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | @Excel(name = "联系电话") |
| | | @ExcelProperty(value = "联系电话",index = 7) |
| | | private String phoneNumber; |
| | | |
| | | @ApiModelProperty(value = "登录密码") |
| | | @Excel(name = "登录密码") |
| | | @ExcelProperty(value = "登录密码",index = 8) |
| | | private String password; |
| | | |
| | | } |
| | |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | |
| | | //注入创建时间 |
| | | if ("createTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | field.set(parameter, LocalDateTime.now()); |
| | | field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | if ("updateTime".equals(field.getName())) { |
| | | field.setAccessible(true); |
| | | field.set(parameter, LocalDateTime.now()); |
| | | field.set(parameter, new Date()); |
| | | field.setAccessible(false); |
| | | } |
| | | } catch (Exception e) { |
New file |
| | |
| | | package com.ruoyi.web.controller.lisenter; |
| | | |
| | | import com.alibaba.excel.context.AnalysisContext; |
| | | import com.alibaba.excel.read.listener.ReadListener; |
| | | import com.alibaba.excel.util.ListUtils; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.UserTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.web.controller.excel.DeptExcel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/28 |
| | | */ |
| | | @Slf4j |
| | | public class DeptImportListener implements ReadListener<DeptExcel> { |
| | | /** |
| | | * 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收 |
| | | */ |
| | | private static final int BATCH_COUNT = 2000; |
| | | |
| | | /** |
| | | * 缓存的数据 |
| | | */ |
| | | private List<DeptExcel> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); |
| | | |
| | | public ISysUserService sysUserService; |
| | | |
| | | public DeptImportListener() { |
| | | } |
| | | |
| | | public DeptImportListener(ISysUserService sysUserService) { |
| | | this.sysUserService = sysUserService; |
| | | } |
| | | |
| | | @Override |
| | | public void invoke(DeptExcel data, AnalysisContext context) { |
| | | log.info("解析到一条数据:{}", JSON.toJSONString(data)); |
| | | if (StringUtils.isEmpty(data.getAreaName()) || StringUtils.isEmpty(data.getAreaCode()) || |
| | | StringUtils.isEmpty(data.getAreaLevel()) || StringUtils.isNull(data.getCountyFlag()) || |
| | | StringUtils.isEmpty(data.getPersonInCharge()) || StringUtils.isEmpty(data.getUserName()) || |
| | | StringUtils.isEmpty(data.getPhoneNumber()) || StringUtils.isEmpty(data.getPassword())) { |
| | | throw new ServiceException(String.format("数据校验失败,请检查第%d行内容填写是否完整", cachedDataList.size()+1)); |
| | | } |
| | | boolean flag = sysUserService.lambdaQuery().eq(SysUser::getUserType,UserTypeEnum.PLATFORM.getCode()).eq(SysUser::getUserName, data.getUserName()).oneOpt().isPresent(); |
| | | if (flag) { |
| | | throw new ServiceException(String.format("数据校验失败,第%d行的登录账号:%s已存在", cachedDataList.size()+1,data.getUserName())); |
| | | } |
| | | flag = cachedDataList.stream().anyMatch(item -> item.getAreaCode().equals(data.getAreaCode())); |
| | | if (flag) { |
| | | throw new ServiceException(String.format("数据校验失败,第%d行区划代码%s重复", cachedDataList.size()+1,data.getAreaCode())); |
| | | } |
| | | flag = cachedDataList.stream().anyMatch(item -> item.getUserName().equals(data.getUserName())); |
| | | if (flag) { |
| | | throw new ServiceException(String.format("数据校验失败,第%d行登录账号%s重复", cachedDataList.size()+1,data.getAreaCode())); |
| | | } |
| | | cachedDataList.add(data); |
| | | // 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM |
| | | if (cachedDataList.size() >= BATCH_COUNT) { |
| | | saveData(); |
| | | // 存储完成清理 list |
| | | cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT); |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | log.info("所有数据解析完成!"); |
| | | saveData(); |
| | | } |
| | | private void saveData() { |
| | | log.info("{}条数据,开始存储数据库!", cachedDataList.size()); |
| | | List<SysUser> sysUsers = BeanUtils.copyList(cachedDataList, SysUser.class); |
| | | sysUsers.forEach(item->{ |
| | | item.setPassword(SecurityUtils.encryptPassword(item.getPassword())); |
| | | item.setNickName(item.getAreaName()); |
| | | item.setUserType("2"); |
| | | }); |
| | | sysUserService.remove(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode())); |
| | | sysUserService.saveBatch(sysUsers); |
| | | log.info("{}条数据,导入成功!", cachedDataList.size()); |
| | | } |
| | | } |
| | |
| | | SysUser currentUser = loginUser.getUser(); |
| | | currentUser.setNickName(user.getNickName()); |
| | | currentUser.setEmail(user.getEmail()); |
| | | currentUser.setPhonenumber(user.getPhonenumber()); |
| | | currentUser.setPhoneNumber(user.getPhoneNumber()); |
| | | currentUser.setSex(user.getSex()); |
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(currentUser)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.service.ISysDeptService; |
| | | import com.ruoyi.system.service.ISysRoleService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import com.ruoyi.system.vo.UserAddListVO; |
| | | import com.ruoyi.system.vo.UserLevelVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @PostMapping("/listNotPage") |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | | List<SysUser> list = userService.queryList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | |
| | | // if(StringUtils.isNotEmpty(name) && type == 3){ |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId()) |
| | | // && ((StringUtils.isNotEmpty(e.getNickName()) && e.getNickName().contains(name))) |
| | | // || (StringUtils.isNotEmpty(e.getPhonenumber()) && e.getPhonenumber().contains(name))).collect(Collectors.toList()); |
| | | // || (StringUtils.isNotEmpty(e.getPhoneNumber()) && e.getPhoneNumber().contains(name))).collect(Collectors.toList()); |
| | | // }else { |
| | | // users = sysUsers.stream().filter(e -> userLevelVO1.getKey().equals(e.getDeptId())).collect(Collectors.toList()); |
| | | // } |
| | |
| | | @PostMapping("/add") |
| | | public AjaxResult add(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | user.setUserName(user.getPhoneNumber()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | else if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | @PostMapping("/edit") |
| | | public AjaxResult edit(@Validated @RequestBody SysUser user) |
| | | { |
| | | user.setUserName(user.getPhonenumber()); |
| | | user.setUserName(user.getPhoneNumber()); |
| | | // userService.checkUserAllowed(user); |
| | | // userService.checkUserDataScope(user.getUserId()); |
| | | if (!userService.checkUserNameUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在"); |
| | | } |
| | | else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) |
| | | else if (StringUtils.isNotEmpty(user.getPhoneNumber()) && !userService.checkPhoneUnique(user)) |
| | | { |
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | |
| | | package com.ruoyi.common.config; |
| | | |
| | | import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.ibatis.reflection.MetaObject; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | |
| | | */ |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); // 起始版本 3.3.0(推荐使用) |
| | | this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername()); // 起始版本 3.3.0(推荐使用) |
| | | // 获取登录信息 |
| | | /* String userName = JwtTokenUtils.getUsername(); |
| | | if (StringUtils.isNotBlank(userName)) { |
| | |
| | | */ |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); // 起始版本 3.3.0(推荐) |
| | | this.strictUpdateFill(metaObject, "updateBy", String.class, SecurityUtils.getUsername()); // 起始版本 3.3.0(推荐) |
| | | // 获取登录信息 |
| | | /*String userName = JwtTokenUtils.getUsername(); |
| | | if (StringUtils.isNotBlank(userName)) { |
| | |
| | | * 密码长度限制 |
| | | */ |
| | | public static final int PASSWORD_MIN_LENGTH = 5; |
| | | public static final int PASSWORD_MAX_LENGTH = 20; |
| | | public static final int PASSWORD_MAX_LENGTH = 40; |
| | | } |
| | |
| | | package com.ruoyi.common.core.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | |
| | | /** |
| | | * Entity基类 |
| | |
| | | |
| | | /** 搜索值 */ |
| | | @JsonIgnore |
| | | @TableField(exist = false) |
| | | private String searchValue; |
| | | |
| | | /** 创建者 */ |
| | | @TableField("create_by") |
| | | private String createBy; |
| | | |
| | | /** 创建时间 */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @TableField("create_time") |
| | | private Date createTime; |
| | | |
| | | /** 更新者 */ |
| | | @TableField("update_by") |
| | | private String updateBy; |
| | | |
| | | /** 更新时间 */ |
| | | @TableField("update_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** 备注 */ |
| | | @TableField("remark") |
| | | private String remark; |
| | | |
| | | /** 请求参数 */ |
| | | @JsonInclude(JsonInclude.Include.NON_EMPTY) |
| | | @TableField(exist = false) |
| | | private Map<String, Object> params; |
| | | |
| | | public String getSearchValue() |
| | |
| | | package com.ruoyi.common.core.domain.entity; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import javax.validation.constraints.*; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.enums.DisabledEnum; |
| | | import com.ruoyi.common.xss.Xss; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.xss.Xss; |
| | | |
| | | import javax.validation.constraints.Email; |
| | | import javax.validation.constraints.Size; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户对象 sys_user |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Data |
| | | @TableName("sys_user") |
| | | public class SysUser extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | /** 用户ID */ |
| | | //@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") |
| | | @ApiModelProperty(value = "用户id") |
| | | @TableId(value = "user_id", type = IdType.AUTO) |
| | | @TableField("user_id") |
| | | private Long userId; |
| | | |
| | | /** 部门ID */ |
| | | //@Excel(name = "部门编号", type = Type.IMPORT) |
| | | @ApiModelProperty(value = "部门id") |
| | | @TableField("dept_id") |
| | | private Long deptId; |
| | | |
| | | @ApiModelProperty(value = "用户类型") |
| | | @TableField("user_type") |
| | | private String userType; |
| | | |
| | | /** 用户账号 */ |
| | | //@Excel(name = "登录名称") |
| | | @ApiModelProperty(value = "登录名称") |
| | | @TableField("user_name") |
| | | private String userName; |
| | | |
| | | /** 用户昵称 */ |
| | | //@Excel(name = "用户名称") |
| | | @ApiModelProperty(value = "用户名称") |
| | | @TableField("nick_name") |
| | | private String nickName; |
| | | |
| | | /** 用户邮箱 */ |
| | | //@Excel(name = "用户邮箱") |
| | | @ApiModelProperty(value = "用户邮箱") |
| | | @TableField("email") |
| | | private String email; |
| | | |
| | | /** 手机号码 */ |
| | | //@Excel(name = "手机号码") |
| | | @ApiModelProperty(value = "手机号码") |
| | | private String phonenumber; |
| | | @TableField("phone_number") |
| | | private String phoneNumber; |
| | | |
| | | /** 用户性别 */ |
| | | //@Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知") |
| | | @ApiModelProperty(value = "用户性别 0=男,1=女,2=未知") |
| | | @TableField("sex") |
| | | private String sex; |
| | | |
| | | /** 用户头像 */ |
| | | @ApiModelProperty(value = "用户头像") |
| | | @TableField("avatar") |
| | | private String avatar; |
| | | |
| | | /** 密码 */ |
| | | @ApiModelProperty(value = "密码") |
| | | @TableField("password") |
| | | private String password; |
| | | |
| | | /** 帐号状态(0正常 1停用) */ |
| | | //@Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用") |
| | | @ApiModelProperty(value = "帐号状态 0=正常,1=停用") |
| | | @TableField("status") |
| | | private String status; |
| | | |
| | | /** 删除标志(0代表存在 2代表删除) */ |
| | | @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)") |
| | | @TableField("del_flag") |
| | | private String delFlag; |
| | | |
| | | /** 最后登录IP */ |
| | | //@Excel(name = "最后登录IP", type = Type.EXPORT) |
| | | @ApiModelProperty(value = "最后登录IP") |
| | | @TableField("login_ip") |
| | | private String loginIp; |
| | | |
| | | /** 最后登录时间 */ |
| | | //@Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @ApiModelProperty(value = "最后登录时间") |
| | | @TableField("login_date") |
| | | private Date loginDate; |
| | | |
| | | /** 部门对象 */ |
| | |
| | | //@Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), |
| | | //@Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) |
| | | // }) |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "部门对象") |
| | | private SysDept dept; |
| | | |
| | | /** 角色对象 */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "角色对象") |
| | | private List<SysRole> roles; |
| | | |
| | | /** 角色组 */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "角色组") |
| | | private Long[] roleIds; |
| | | |
| | | /** 岗位组 */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "岗位组") |
| | | private Long[] postIds; |
| | | |
| | | /** 角色ID */ |
| | | @TableField(exist = false) |
| | | @ApiModelProperty(value = "角色ID") |
| | | private Long roleId; |
| | | /** |
| | | * 是否为黑名单 1是 0否 |
| | | */ |
| | | @ApiModelProperty(value = "是否为黑名单 1是 0否") |
| | | private Integer ifBlack; |
| | | |
| | | @TableField(exist = false) |
| | | private String roleName; |
| | | |
| | | @TableField(exist = false) |
| | | private String deptName; |
| | | |
| | | @ApiModelProperty(value = "部门地区") |
| | | @TableField("area_name") |
| | | private String areaName; |
| | | |
| | | @ApiModelProperty(value = "别名") |
| | | @TableField("area_alias") |
| | | private String areaAlias; |
| | | |
| | | @ApiModelProperty(value = "区划代码") |
| | | @TableField("area_code") |
| | | private String areaCode; |
| | | |
| | | @ApiModelProperty(value = "级次(省、市、县)") |
| | | @TableField("area_level") |
| | | private String areaLevel; |
| | | |
| | | @ApiModelProperty(value = "县级标志(不包含直辖市的区 0:否 1:是)") |
| | | @TableField("county_flag") |
| | | private DisabledEnum countyFlag; |
| | | |
| | | @ApiModelProperty(value = "负责人") |
| | | @TableField("person_in_charge") |
| | | private String personInCharge; |
| | | |
| | | @ApiModelProperty(value = "是否重点关注(0:否 1:是)") |
| | | @TableField("focussed") |
| | | private DisabledEnum focussed; |
| | | |
| | | |
| | | public String getRoleName() { |
| | | return roleName; |
| | |
| | | } |
| | | |
| | | @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符") |
| | | public String getPhonenumber() |
| | | public String getPhoneNumber() |
| | | { |
| | | return phonenumber; |
| | | return phoneNumber; |
| | | } |
| | | |
| | | public void setPhonenumber(String phonenumber) |
| | | public void setPhoneNumber(String phoneNumber) |
| | | { |
| | | this.phonenumber = phonenumber; |
| | | this.phoneNumber = phoneNumber; |
| | | } |
| | | |
| | | public String getSex() |
| | |
| | | this.roleId = roleId; |
| | | } |
| | | |
| | | public Integer getIfBlack() { |
| | | return ifBlack; |
| | | } |
| | | |
| | | public void setIfBlack(Integer ifBlack) { |
| | | this.ifBlack = ifBlack; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | |
| | | .append("userName", getUserName()) |
| | | .append("nickName", getNickName()) |
| | | .append("email", getEmail()) |
| | | .append("phonenumber", getPhonenumber()) |
| | | .append("phoneNumber", getPhoneNumber()) |
| | | .append("sex", getSex()) |
| | | .append("avatar", getAvatar()) |
| | | .append("password", getPassword()) |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.EnumValue; |
| | | import com.fasterxml.jackson.annotation.JsonValue; |
| | | import lombok.Getter; |
| | | import lombok.AllArgsConstructor; |
| | | @Getter |
| | |
| | | public enum FieldInputTypeEnum { |
| | | MANUAL_INPUT(1, "手动输入"), |
| | | FIXED_CONTENT(2, "固定内容"); |
| | | |
| | | @EnumValue |
| | | private final Integer code; |
| | | @JsonValue |
| | | private final String desc; |
| | | |
| | | public static FieldInputTypeEnum getEnumByCode(Integer code) { |
New file |
| | |
| | | package com.ruoyi.common.enums; |
| | | |
| | | import lombok.Getter; |
| | | import lombok.AllArgsConstructor; |
| | | @Getter |
| | | @AllArgsConstructor |
| | | public enum UserTypeEnum { |
| | | PLATFORM("1", "平台"), |
| | | DEPARTMENT("2", "部门"); |
| | | |
| | | private final String code; |
| | | private final String desc; |
| | | |
| | | public static UserTypeEnum getEnumByCode(String code) { |
| | | for (UserTypeEnum e : UserTypeEnum.values()) { |
| | | if (e.code.equals(code)) { |
| | | return e; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | operLog.setUserId(loginUser.getUserId()); |
| | | if(Objects.nonNull(loginUser.getUser())){ |
| | | operLog.setNickName(loginUser.getUser().getNickName()); |
| | | operLog.setPhonenumber(loginUser.getUser().getPhonenumber()); |
| | | operLog.setPhoneNumber(loginUser.getUser().getPhoneNumber()); |
| | | // 设置角色名称 |
| | | SysRole sysRole = roleService.selectRoleByUserId(loginUser.getUserId()); |
| | | if(Objects.nonNull(sysRole)){ |
| | |
| | | // 过滤请求 |
| | | .authorizeRequests() |
| | | // 对于登录login 注册register 验证码captchaImage 允许匿名访问 |
| | | /*.antMatchers("/getPrivacyAgreement/{agreementType}","/applet/queryProtocolConfigByType","/applet/login","/login","/applet/queryProtocolConfigByType", "/register","/applet/getCode","/applet/loginCode","/applet/changepwd", "/captchaImage","/getCode","/loginCode","/operations/getBySingleNum/**", |
| | | "/user/getUserInfoByNumber/**","/genAccount","/loginPwd").permitAll()*/ |
| | | .antMatchers("/getPrivacyAgreement/{agreementType}","/applet/queryProtocolConfigByType","/applet/login","/login","/applet/queryProtocolConfigByType", "/register","/applet/getCode","/applet/loginCode","/applet/changepwd", "/captchaImage","/getCode","/loginCode","/operations/getBySingleNum/**", |
| | | "/user/getUserInfoByNumber/**","/genAccount","/loginPwd").permitAll() |
| | | //放行所有 |
| | | .antMatchers("/*/**").permitAll() |
| | | //.antMatchers("/*/**").permitAll() |
| | | // 静态资源,可匿名访问 |
| | | .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() |
| | | .antMatchers("/swagger-ui.html","/doc.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | |
| | | import com.ruoyi.framework.manager.AsyncManager; |
| | | import com.ruoyi.framework.manager.factory.AsyncFactory; |
| | | import com.ruoyi.framework.security.context.AuthenticationContextHolder; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TbDeptService; |
| | |
| | | // 用户验证 |
| | | Authentication authentication = null; |
| | | // 用户验证 |
| | | SysUser user = userService.selectUserByUserName(username); |
| | | SysUser user = userService.selectPlatUserByUserName(username); |
| | | if (StringUtils.isNull(user)){ |
| | | log.info("登录用户:{} 不存在.", username); |
| | | throw new ServiceException(MessageUtils.message("user.not.exists")); |
| | |
| | | throw new ServiceException("不可用短信验证码登录"); |
| | | } |
| | | // 校验验证码 |
| | | Object cacheObject = redisCache.getCacheObject(user.getPhonenumber()); |
| | | Object cacheObject = redisCache.getCacheObject(user.getPhoneNumber()); |
| | | if(!code.equals(String.valueOf(cacheObject))){ |
| | | log.info("登录用户:{} 短信验证码错误{}", username,code); |
| | | throw new ServiceException("短信验证码错误"); |
| | |
| | | /** |
| | | * 登录验证 |
| | | * |
| | | * @param account 用户名 |
| | | * @param username 用户名 |
| | | * @param password 密码 |
| | | * @param uuid uuid |
| | | * @param loginBodyUuid |
| | | |
| | | * @return 结果 |
| | | */ |
| | | public LoginUser loginPwd(String account, String password, String code, String uuid) |
| | | public LoginUser loginPwd(String username, String password, String code, String uuid) |
| | | { |
| | | // 验证码校验 |
| | | validateCaptcha(account, code, uuid); |
| | | validateCaptcha(username, code, uuid); |
| | | // 登录前置校验 |
| | | loginPreCheck(account, password); |
| | | loginPreCheck(username, password); |
| | | // 用户验证 |
| | | Authentication authentication = null; |
| | | // 用户验证 |
| | | TbDept dept = tbDeptService.getOne(Wrappers.<TbDept>lambdaQuery().eq(TbDept::getAccount, account)); |
| | | if (StringUtils.isNull(dept)){ |
| | | log.info("登录用户:{} 不存在.", account); |
| | | SysUser user = userService.selectDeptUserByUserName(username); |
| | | if (StringUtils.isNull(user)){ |
| | | log.info("登录用户:{} 不存在.", username); |
| | | throw new ServiceException(MessageUtils.message("user.not.exists")); |
| | | } |
| | | try |
| | | { |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(account, password); |
| | | UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password); |
| | | AuthenticationContextHolder.setContext(authenticationToken); |
| | | // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername |
| | | authentication = authenticationManager.authenticate(authenticationToken); |
| | |
| | | { |
| | | if (e instanceof BadCredentialsException) |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(account, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match"))); |
| | | throw new UserPasswordNotMatchException(); |
| | | } |
| | | else |
| | | { |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(account, Constants.LOGIN_FAIL, e.getMessage())); |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage())); |
| | | throw new ServiceException(e.getMessage()); |
| | | } |
| | | } |
| | |
| | | { |
| | | AuthenticationContextHolder.clearContext(); |
| | | } |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(account, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success"))); |
| | | LoginUser loginUser = (LoginUser) authentication.getPrincipal(); |
| | | recordLoginInfo(loginUser.getUserId()); |
| | | // 生成token |
| | |
| | | sysUser.setLoginDate(DateUtils.getNowDate()); |
| | | userService.updateUserProfile(sysUser); |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | package com.ruoyi.framework.web.service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.stereotype.Component; |
| | | import com.ruoyi.common.constant.CacheConstants; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | |
| | | import io.jsonwebtoken.Claims; |
| | | import io.jsonwebtoken.Jwts; |
| | | import io.jsonwebtoken.SignatureAlgorithm; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * token验证处理 |
| | |
| | | @Excel(name = "角色名称") |
| | | private String roleName; |
| | | @Excel(name = "手机号") |
| | | private String phonenumber; |
| | | private String phoneNumber; |
| | | @Excel(name = "用户id") |
| | | private Long userId; |
| | | @Excel(name = "操作人员名称") |
| | |
| | | this.roleName = roleName; |
| | | } |
| | | |
| | | public String getPhonenumber() { |
| | | return phonenumber; |
| | | public String getPhoneNumber() { |
| | | return phoneNumber; |
| | | } |
| | | |
| | | public void setPhonenumber(String phonenumber) { |
| | | this.phonenumber = phonenumber; |
| | | public void setPhoneNumber(String phoneNumber) { |
| | | this.phoneNumber = phoneNumber; |
| | | } |
| | | |
| | | public Long getUserId() { |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "分类id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "季度") |
| | | @TableField("quarter") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新人") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "基础数据分类id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "基础数据分类名称") |
| | | @TableField("basic_data_category_name") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "基础数据配置id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "基础数据分类id") |
| | | @TableField("basic_data_category_id") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "基础数据配置id") |
| | | @TableField("basic_data_config_id") |
| | | private Integer basicDataConfigId; |
| | | private Long basicDataConfigId; |
| | | |
| | | @ApiModelProperty(value = "键") |
| | | @TableField("key") |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "动态字段id") |
| | | @TableId(value = "id",type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "基础数据id") |
| | | @TableField("basic_data_id") |
| | | private Integer basicDataId; |
| | | private Long basicDataId; |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | @TableField("field_id") |
| | | private Integer fieldId; |
| | | private Long fieldId; |
| | | |
| | | @ApiModelProperty(value = "字段值") |
| | | @TableField("field_value") |
| | | private String fieldValue; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新人") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "大屏数据配置id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "配置类型(1=风险等级设置 2=数据指标设置 3=形式指标设置)") |
| | | @TableField("type") |
| | | private Boolean type; |
| | | |
| | | @ApiModelProperty(value = "得分计算规则(多个规则使用','隔开)") |
| | | @TableField("caculate_formula") |
| | | private String caculateFormula; |
| | | @TableField("calculate_formula") |
| | | private String calculateFormula; |
| | | |
| | | @ApiModelProperty(value = "配置类型子类型(1=数据指标一/形式指标一 2=数据指标二/形式指标二 3=数据指标三/形式指标三 4=数据指标四/形式指标四)") |
| | | @TableField("sub_type") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "部门id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "部门地区") |
| | | @TableField("area_name") |
| | |
| | | private Integer focussed; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | /** |
| | | * 用户唯一标识 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String token; |
| | | |
| | | /** |
| | | * 登录IP地址 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String ipaddr; |
| | | |
| | | /** |
| | | * 登录地点 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String loginLocation; |
| | | |
| | | /** |
| | | * 浏览器类型 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String browser; |
| | | |
| | | /** |
| | | * 操作系统 |
| | | */ |
| | | @TableField(exist = false) |
| | | private String os; |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.domain; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.*; |
| | | import com.ruoyi.common.enums.FieldInputTypeEnum; |
| | | import com.ruoyi.common.enums.FieldTypeEnum; |
| | | import com.ruoyi.common.enums.ShowStatusEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | @TableField("field_name") |
| | |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | @TableField("field_type") |
| | | private Integer fieldType; |
| | | private FieldTypeEnum fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @TableField("level_one_category_id") |
| | | private Integer levelOneCategoryId; |
| | | private Long levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | @TableField("level_two_category_id") |
| | | private Integer levelTwoCategoryId; |
| | | private Long levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | @TableField("level_three_category_id") |
| | | private Integer levelThreeCategoryId; |
| | | private Long levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "一级分类") |
| | | @TableField("level_one_category") |
| | |
| | | |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)") |
| | | @TableField("text_input_type") |
| | | private Integer textInputType; |
| | | private FieldInputTypeEnum textInputType; |
| | | |
| | | @ApiModelProperty(value = "文本最少字数") |
| | | @TableField("text_min_num") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "分类id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "父级id") |
| | | @TableField("parent_id") |
| | | private Integer parentId; |
| | | private Long parentId; |
| | | |
| | | @ApiModelProperty(value = "分类名称") |
| | | @TableField("field_category_name") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建人") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新人") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "问题id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "问题标题") |
| | | @TableField("title") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.io.Serializable; |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "得分id") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "计算类型id") |
| | | @TableField("basic_data_config_id") |
| | | private Integer basicDataConfigId; |
| | | private Long basicDataConfigId; |
| | | |
| | | @ApiModelProperty(value = "所属基础数据id") |
| | | @TableField("basic_data_id") |
| | | private Integer basicDataId; |
| | | private Long basicDataId; |
| | | |
| | | @ApiModelProperty(value = "得分") |
| | | @TableField("score") |
| | |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | @TableField("create_by") |
| | | @TableField(value = "create_by", fill = FieldFill.INSERT) |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | @TableField(value = "create_time", fill = FieldFill.INSERT) |
| | | private LocalDateTime createTime; |
| | | private Date createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | @TableField("update_by") |
| | | @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) |
| | | private LocalDateTime updateTime; |
| | | private Date updateTime; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | @ApiModelProperty(value = "基础数据分类id") |
| | | @NotNull(message = "基础数据分类id不能为空") |
| | | private Integer basicDataCategoryId; |
| | | private Long basicDataCategoryId; |
| | | |
| | | @ApiModelProperty(value = "字段说明") |
| | | @NotBlank(message = "字段说明不能为空") |
| | |
| | | @ApiModel(value = "当前季度基础数据数据传输对象") |
| | | public class BasicDataDTO { |
| | | |
| | | //TODO 登录功能好了之后删掉 |
| | | @ApiModelProperty(value = "区划代码") |
| | | private String deptAreaCode; |
| | | |
| | | @ApiModelProperty(value = "转移支付规模") |
| | | private String transferPaymentScale; |
| | | |
| | |
| | | public class BasicDataFieldDTO { |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | private Integer fieldId; |
| | | private Long fieldId; |
| | | |
| | | @ApiModelProperty(value = "字段值") |
| | | private String fieldValue; |
| | |
| | | package com.ruoyi.system.dto; |
| | | |
| | | import com.ruoyi.common.enums.FieldInputTypeEnum; |
| | | import com.ruoyi.common.enums.FieldTypeEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @NotBlank(message="字段名不能为空") |
| | | private String fieldName; |
| | | |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)") |
| | | @ApiModelProperty(value = "字段类型(1=数字 2=文本 3=百分比)直接传文字") |
| | | @NotNull(message="字段类型不能为空") |
| | | private Integer fieldType; |
| | | private FieldTypeEnum fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @NotNull(message="分类id不能为空") |
| | | private Integer levelOneCategoryId; |
| | | private Long levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | private Long levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | private Long levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | private Integer numMin; |
| | |
| | | @ApiModelProperty(value = "数字最大值") |
| | | private Integer numMax; |
| | | |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)") |
| | | private Integer textInputType; |
| | | @ApiModelProperty(value = "文本输入类型(1=手动输入 2=固定内容)直接传文字") |
| | | private FieldInputTypeEnum textInputType; |
| | | |
| | | @ApiModelProperty(value = "文本最少字数") |
| | | private Integer textMinNum; |
| | |
| | | |
| | | @ApiModelProperty(value = "分类id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "状态 (直接传 展示中 或 已隐藏)") |
| | | @NotNull(message = "status不能为空") |
| | |
| | | @ApiModel(value = "用户修改状态DTO") |
| | | public class SysUserUpdateStatusDTO implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1334686713880506731L; |
| | | |
| | | @ApiModelProperty(value = "用户id") |
| | | private Long userId; |
| | | |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "分类名称") |
| | | @NotBlank(message = "分类名称不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "类型名称") |
| | | @NotBlank(message = "类型名称不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "基础数据分类id") |
| | | @NotNull(message = "基础数据分类id不能为空") |
| | | private Integer basicDataCategoryId; |
| | | private Long basicDataCategoryId; |
| | | |
| | | @ApiModelProperty(value = "字段说明") |
| | | @NotBlank(message = "字段说明不能为空") |
| | |
| | | package com.ruoyi.system.dto.update; |
| | | |
| | | import com.ruoyi.common.enums.DisabledEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | private static final long serialVersionUID = -7322348219193526224L; |
| | | |
| | | @ApiModelProperty(value = "部门id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | @NotNull(message = "userId不能为空") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "是否重点关注(0:否 1:是)") |
| | | @ApiModelProperty(value = "是否重点关注 传 是/否") |
| | | @NotNull(message = "是否重点关注不能为空") |
| | | private Integer focussed; |
| | | private DisabledEnum focussed; |
| | | } |
| | |
| | | private static final long serialVersionUID = -4377907033147587467L; |
| | | |
| | | @ApiModelProperty(value = "部门id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | @NotNull(message = "userId不能为空") |
| | | private Long userId; |
| | | |
| | | @ApiModelProperty(value = "别名") |
| | | @NotBlank(message = "别名不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | @NotBlank(message = "联系电话不能为空") |
| | | private String phone; |
| | | private String phoneNumber; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | @NotBlank(message = "登录账号不能为空") |
| | | private String account; |
| | | private String userName; |
| | | |
| | | @ApiModelProperty(value = "登录密码") |
| | | @NotBlank(message = "登录密码不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "一级分类名称") |
| | | @NotBlank(message = "分类名称不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "id") |
| | | @NotNull(message = "id不能为空") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | @NotBlank(message="字段名不能为空") |
| | |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | @NotNull(message="分类id不能为空") |
| | | private Integer levelOneCategoryId; |
| | | private Long levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | private Long levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | private Long levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "数字最小值") |
| | | private Integer numMin; |
| | |
| | | package com.ruoyi.system.importExcel; |
| | | |
| | | import cn.afterturn.easypoi.excel.annotation.Excel; |
| | | import com.alibaba.excel.annotation.ExcelProperty; |
| | | import com.ruoyi.common.enums.DisabledEnum; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | |
| | | @Excel(name = "县级标志 是/否",enumImportMethod = "getByDesc") |
| | | private DisabledEnum countyFlag; |
| | | |
| | | @ApiModelProperty(value = "负责人") |
| | | @Excel(name = "负责人") |
| | | private String personInCharge; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | @Excel(name = "登录账号") |
| | | private String account; |
| | | |
| | | @ApiModelProperty(value = "负责人姓名") |
| | | private String personInCharge; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | @Excel(name = "联系电话") |
| | | private String phone; |
| | |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Slf4j |
| | |
| | | public TbBasicDataService tbBasicDataService; |
| | | public List<TbField> fieldList; |
| | | public TbFieldService tbFieldService; |
| | | public TbDept dept; |
| | | public String areaCode; |
| | | public TbBasicDataFieldService tbBasicDataFieldService; |
| | | public TbBasicDataConfigService tbBasicDataConfigService; |
| | | public TbBasicDataConfigDetailService tbBasicDataConfigDetailService; |
| | |
| | | } |
| | | |
| | | public BasicDataListener(TbBasicDataService tbBasicDataService, List<TbField> fieldList,TbFieldService tbFieldService, |
| | | TbDept dept,TbBasicDataFieldService tbBasicDataFieldService,TbBasicDataConfigService tbBasicDataConfigService, |
| | | String areaCode,TbBasicDataFieldService tbBasicDataFieldService,TbBasicDataConfigService tbBasicDataConfigService, |
| | | TbBasicDataConfigDetailService tbBasicDataConfigDetailService,TbScoreService tbScoreService ) { |
| | | this.tbBasicDataService = tbBasicDataService; |
| | | this.fieldList = fieldList; |
| | | this.tbFieldService = tbFieldService; |
| | | this.dept = dept; |
| | | this.areaCode = areaCode; |
| | | this.tbBasicDataFieldService = tbBasicDataFieldService; |
| | | this.tbBasicDataConfigService = tbBasicDataConfigService; |
| | | this.tbBasicDataConfigDetailService = tbBasicDataConfigDetailService; |
| | |
| | | @Override |
| | | public void doAfterAllAnalysed(AnalysisContext context) { |
| | | try { |
| | | saveData(); |
| | | TbBasicData tbBasicData = saveData(); |
| | | calculateScore(tbBasicData); |
| | | } catch (Exception e) { |
| | | if (e instanceof ServiceException) { |
| | | throw new ServiceException(e.getMessage()); |
| | |
| | | /** |
| | | * 加上存储数据库 |
| | | */ |
| | | private void saveData() { |
| | | Map<Integer, String> headMap = cachedDataList.get(2); |
| | | Map<Integer, String> quarterMap = cachedDataList.get(4); |
| | | Map<Integer, String> dataMap = cachedDataList.get(5); |
| | | private TbBasicData saveData() { |
| | | Map<Integer, String> headMap = cachedDataList.get(cachedDataList.size()-3); |
| | | Map<Integer, String> dataMap = cachedDataList.get(cachedDataList.size()-1); |
| | | log.info("{}条数据,开始存储数据库!", cachedDataList.size()); |
| | | log.info("表头:{}", JSON.toJSONString(headMap)); |
| | | log.info("填写的数据:{}", JSON.toJSONString(dataMap)); |
| | |
| | | LocalDate now = LocalDate.now(); |
| | | TbBasicData tbBasicData; |
| | | Optional<TbBasicData> tbBasicDataOpt = tbBasicDataService.lambdaQuery(). |
| | | eq(TbBasicData::getQuarter, String.format("%s年%s", now.getYear(), quarterMap.get(1))) |
| | | .eq(TbBasicData::getDeptAreaCode, dept.getAreaCode()).oneOpt(); |
| | | eq(TbBasicData::getQuarter, String.format("%s年%s", now.getYear(), dataMap.get(1))) |
| | | .eq(TbBasicData::getDeptAreaCode, areaCode).oneOpt(); |
| | | tbBasicData = tbBasicDataOpt.orElseGet(TbBasicData::new); |
| | | tbBasicData.setQuarter(String.format("%s年%s", now.getYear(), quarterMap.get(1))); |
| | | tbBasicData.setQuarter(String.format("%s年%s", now.getYear(), dataMap.get(1))); |
| | | tbBasicData.setTransferPaymentScale(dataMap.get(2)); |
| | | tbBasicData.setCurrentGdp(dataMap.get(3)); |
| | | tbBasicData.setDeptAreaCode(dept.getAreaCode()); |
| | | tbBasicData.setDeptAreaCode(areaCode); |
| | | tbBasicData.setRemark(dataMap.get(remarkIndex)); |
| | | tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); |
| | | tbBasicDataService.saveOrUpdate(tbBasicData); |
| | | tbBasicDataFieldService.remove(Wrappers.<TbBasicDataField>lambdaQuery().eq(TbBasicDataField::getBasicDataId, tbBasicData.getId())); |
| | | List<TbBasicDataField> fields = new ArrayList<>(); |
| | | //添加固定字段 转移支付规模、当期GDP |
| | | TbBasicDataField transferPaymentScale = new TbBasicDataField(); |
| | | transferPaymentScale.setBasicDataId(tbBasicData.getId()); |
| | | transferPaymentScale.setFieldId(-1L); |
| | | transferPaymentScale.setFieldValue(tbBasicData.getTransferPaymentScale()); |
| | | fields.add(transferPaymentScale); |
| | | |
| | | TbBasicDataField currentGdp = new TbBasicDataField(); |
| | | currentGdp.setBasicDataId(tbBasicData.getId()); |
| | | currentGdp.setFieldId(-2L); |
| | | currentGdp.setFieldValue(tbBasicData.getCurrentGdp()); |
| | | fields.add(currentGdp); |
| | | //遍历动态字段map |
| | | for (Map.Entry<Integer, String> integerStringEntry : dynamicFieldsMap.entrySet()) { |
| | | Optional<TbField> tbField = tbFieldService.lambdaQuery().eq(TbField::getFieldName, integerStringEntry.getValue()) |
| | |
| | | fields.add(tbBasicDataField); |
| | | } |
| | | } |
| | | //异步执行批量保存 |
| | | CompletableFuture.runAsync(() -> tbBasicDataFieldService.saveBatch(fields)); |
| | | tbBasicDataFieldService.saveBatch(fields); |
| | | tbBasicData.setStatus(ReportingStatusEnum.FILLED); |
| | | tbBasicDataService.updateById(tbBasicData); |
| | | log.info(String.format("%s导入基础数据成功!", quarterMap.get(0))); |
| | | CompletableFuture.runAsync(() -> calculateScore(tbBasicData)); |
| | | log.info(String.format("%s导入基础数据成功!", dataMap.get(0))); |
| | | return tbBasicData; |
| | | } |
| | | |
| | | private static String validateFields(Map.Entry<Integer, String> integerStringEntry, Map<Integer, String> dataMap, TbField field) { |
| | | String value = dataMap.get(integerStringEntry.getKey()); |
| | | if (FieldTypeEnum.NUMBER.equals(field.getFieldType())) { |
| | | Integer numMin = field.getNumMin(); |
| | | Integer numMax = field.getNumMax(); |
| | | if (Objects.nonNull(numMin) && Objects.nonNull(numMax)) { |
| | | if (numMin > Integer.parseInt(value) || numMax < Integer.parseInt(value)) { |
| | | throw new ServiceException(String.format("字段%s的内容不在%d~%d范围内", field.getFieldName(),numMin,numMax)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldInputTypeEnum.MANUAL_INPUT.equals(field.getTextInputType()) && FieldTypeEnum.TEXT.equals(field.getFieldType())) { |
| | | Integer textMinNum = field.getTextMinNum(); |
| | | Integer textMaxNum = field.getTextMaxNum(); |
| | | if (Objects.nonNull(textMinNum) && Objects.nonNull(textMaxNum)) { |
| | | if (textMinNum > value.length() || textMaxNum < value.length()) { |
| | | throw new ServiceException(String.format("字段%s的内容长度超出%d~%d的范围", field.getFieldName(),textMinNum,textMaxNum)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldTypeEnum.PERCENTAGE.equals(field.getFieldType())) { |
| | | if (0 > Double.parseDouble(value) || 100 < Double.parseDouble(value)) { |
| | | throw new ServiceException(String.format("字段%s的内容不在0~100范围内", field.getFieldName())); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | private void calculateScore(TbBasicData tbBasicData) { |
| | | //计算得分 |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery().eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery() |
| | | .eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | throw new ServiceException("计算得分失败,平台未配置得分计算规则"); |
| | | } |
| | |
| | | .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId()) |
| | | .eq(TbBasicDataField::getFieldId, stringIntegerEntry.getValue()) |
| | | .oneOpt(); |
| | | if (tbBasicDataField.isPresent()) { |
| | | valueMap.put(stringIntegerEntry.getKey(), tbBasicDataField.get().getFieldValue()); |
| | | } |
| | | |
| | | tbBasicDataField.ifPresent(basicDataField -> valueMap.put(stringIntegerEntry.getKey(), basicDataField.getFieldValue())); |
| | | } |
| | | double score = CalculateUtil.calculate(numberCalculateFormula, valueMap); |
| | | TbScore tbScore = new TbScore(); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private static String validateFields(Map.Entry<Integer, String> integerStringEntry, Map<Integer, String> dataMap, TbField field) { |
| | | String value = dataMap.get(integerStringEntry.getKey()); |
| | | if (FieldTypeEnum.NUMBER.getCode().equals(field.getFieldType())) { |
| | | Integer numMin = field.getNumMin(); |
| | | Integer numMax = field.getNumMax(); |
| | | if (Objects.nonNull(numMin) && Objects.nonNull(numMax)) { |
| | | if (numMin > Integer.parseInt(value) || numMax < Integer.parseInt(value)) { |
| | | throw new ServiceException(String.format("字段%s的内容不在%d~%d范围内", field.getFieldName(),numMin,numMax)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldInputTypeEnum.MANUAL_INPUT.getCode().equals(field.getTextInputType()) && FieldTypeEnum.TEXT.getCode().equals(field.getFieldType())) { |
| | | Integer textMinNum = field.getTextMinNum(); |
| | | Integer textMaxNum = field.getTextMaxNum(); |
| | | if (Objects.nonNull(textMinNum) && Objects.nonNull(textMaxNum)) { |
| | | if (textMinNum > value.length() || textMaxNum < value.length()) { |
| | | throw new ServiceException(String.format("字段%s的内容长度超出%d~%d的范围", field.getFieldName(),textMinNum,textMaxNum)); |
| | | } |
| | | } |
| | | } |
| | | if (FieldTypeEnum.PERCENTAGE.getCode().equals(field.getFieldType())) { |
| | | if (0 > Double.parseDouble(value) || 100 < Double.parseDouble(value)) { |
| | | throw new ServiceException(String.format("字段%s的内容不在0~100范围内", field.getFieldName())); |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户表 数据层 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Mapper |
| | | public interface SysUserMapper |
| | | public interface SysUserMapper extends BaseMapper<SysUser> |
| | | { |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | |
| | | /** |
| | | * 校验手机号码是否唯一 |
| | | * |
| | | * @param phonenumber 手机号码 |
| | | * @param phoneNumber 手机号码 |
| | | * @return 结果 |
| | | */ |
| | | public SysUser checkPhoneUnique(String phonenumber); |
| | | public SysUser checkPhoneUnique(String phoneNumber); |
| | | |
| | | /** |
| | | * 校验email是否唯一 |
| | |
| | | */ |
| | | List<SysUser> selectUserByIds(@Param("userIds") List<Long> userIds); |
| | | |
| | | List<SysUser> selectList(); |
| | | List<SysUser> queryList(); |
| | | |
| | | Integer selectCount(@Param("status") Integer status); |
| | | |
| | |
| | | List<SysUser> selectUserByUserNameList(@Param("names")List<String> names); |
| | | // UserInfoVo userInfo(@Param("id") Long userId); |
| | | |
| | | SysUser selectByPhone(@Param("phonenumber") String phonenumber); |
| | | SysUser selectByPhone(@Param("phoneNumber") String phoneNumber); |
| | | |
| | | // UserInfoVo getUserInfoBy(@Param("singleNum")String singleNum); |
| | | |
| | |
| | | |
| | | void updatePassword(@Param("id") Long id,@Param("s") String s); |
| | | |
| | | long selectIdByPhone(@Param("phonenumber") String phonenumber); |
| | | long selectIdByPhone(@Param("phoneNumber") String phoneNumber); |
| | | |
| | | SysUser selectDeptUserByUserName(@Param("userName") String userName); |
| | | |
| | | SysUser selectPlatUserByUserName(@Param("userName") String userName); |
| | | } |
| | |
| | | private String areaName; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | private String account; |
| | | private String userName; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phone; |
| | |
| | | private FieldTypeEnum type; |
| | | |
| | | @ApiModelProperty(value = "基础数据Id",hidden = true) |
| | | private Integer basicDataId; |
| | | private Long basicDataId; |
| | | } |
| | |
| | | private Integer roleId; |
| | | |
| | | @ApiModelProperty(value = "手机号") |
| | | private String phonenumber; |
| | | private String phoneNumber; |
| | | |
| | | @ApiModelProperty(value = "状态 0=正常 1=停用") |
| | | private String status; |
| | |
| | | package com.ruoyi.system.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 用户 业务层 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface ISysUserService |
| | | public interface ISysUserService extends IService<SysUser> |
| | | { |
| | | /** |
| | | * 根据条件分页查询用户列表 |
| | |
| | | */ |
| | | public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); |
| | | |
| | | List<SysUser> selectList(); |
| | | List<SysUser> queryList(); |
| | | |
| | | Integer selectCount(Integer status); |
| | | |
| | |
| | | |
| | | // UserInfoVo userInfo(Long userId); |
| | | |
| | | SysUser selectByPhone(String phonenumber); |
| | | SysUser selectByPhone(String phoneNumber); |
| | | /** |
| | | * 通过名字集合查询用户 |
| | | * @param names |
| | |
| | | |
| | | void updatePassword(Long id, String s); |
| | | |
| | | long selectIdByPhone(String phonenumber); |
| | | long selectIdByPhone(String phoneNumber); |
| | | |
| | | SysUser selectDeptUserByUserName(String userName); |
| | | |
| | | SysUser selectPlatUserByUserName(String username); |
| | | |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.dto.update.DeptFocusDTO; |
| | | import com.ruoyi.system.query.DeptQuery; |
| | |
| | | void importExcel(MultipartFile file) throws Exception; |
| | | |
| | | void focus(DeptFocusDTO dto); |
| | | |
| | | R<Void> reportingMessage(); |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | void edit(FieldCategoryUpdateDTO dto); |
| | | |
| | | void deleteChildren(Integer id); |
| | | void deleteChildren(Long id); |
| | | |
| | | void delete(Integer id); |
| | | void delete(Long id); |
| | | |
| | | List<FieldCategoryVO> queryFieldCategories(Integer id); |
| | | List<FieldCategoryVO> queryFieldCategories(Long id); |
| | | |
| | | FieldCategoryDetailVO getDetailsById(Integer id); |
| | | FieldCategoryDetailVO getDetailsById(Long id); |
| | | } |
| | |
| | | |
| | | PageDTO<FieldVO> queryPage(FieldQuery query); |
| | | |
| | | String influencedData(Integer id); |
| | | String influencedData(Long id); |
| | | |
| | | void update(FieldUpdateDTO dto); |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | import javax.validation.Validator; |
| | | |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.constant.UserConstants; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.SysPostMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.mapper.SysUserPostMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.mapper.*; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import javax.validation.Validator; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 用户 业务层处理 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysUserServiceImpl implements ISysUserService |
| | | public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); |
| | | |
| | |
| | | public boolean checkPhoneUnique(SysUser user) |
| | | { |
| | | Long userId = StringUtils.isNull(user.getUserId()) ? -1L : user.getUserId(); |
| | | SysUser info = userMapper.checkPhoneUnique(user.getPhonenumber()); |
| | | SysUser info = userMapper.checkPhoneUnique(user.getPhoneNumber()); |
| | | if (StringUtils.isNotNull(info) && info.getUserId().longValue() != userId.longValue()) |
| | | { |
| | | return UserConstants.NOT_UNIQUE; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SysUser> selectList() { |
| | | return userMapper.selectList(); |
| | | public List<SysUser> queryList() { |
| | | return userMapper.queryList(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public long selectIdByPhone(String phonenumber) { |
| | | return userMapper.selectIdByPhone(phonenumber); |
| | | public long selectIdByPhone(String phoneNumber) { |
| | | return userMapper.selectIdByPhone(phoneNumber); |
| | | } |
| | | |
| | | // @Override |
| | |
| | | // } |
| | | |
| | | @Override |
| | | public SysUser selectByPhone(String phonenumber) { |
| | | return userMapper.selectByPhone(phonenumber); |
| | | public SysUser selectByPhone(String phoneNumber) { |
| | | return userMapper.selectByPhone(phoneNumber); |
| | | } |
| | | |
| | | @Override |
| | | public SysUser selectDeptUserByUserName(String userName) { |
| | | return userMapper.selectDeptUserByUserName(userName); |
| | | } |
| | | |
| | | @Override |
| | | public SysUser selectPlatUserByUserName(String userName) { |
| | | return userMapper.selectPlatUserByUserName(userName); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.system.service.impl; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.google.common.collect.Lists; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.enums.ReportingStatusEnum; |
| | | import com.ruoyi.common.enums.ShowStatusEnum; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.enums.*; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.NumberDisplaceChineseUtil; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.dto.BasicDataDTO; |
| | | import com.ruoyi.system.handler.CustomerHandler; |
| | | import com.ruoyi.system.handler.SelectedSheetWriteHandler; |
| | | import com.ruoyi.system.listener.BasicDataListener; |
| | | import com.ruoyi.system.mapper.TbBasicDataMapper; |
| | | import com.ruoyi.system.mapper.TbDeptMapper; |
| | | import com.ruoyi.system.query.ScoreQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.BasicDataReportingVO; |
| | |
| | | @RequiredArgsConstructor |
| | | public class TbBasicDataServiceImpl extends ServiceImpl<TbBasicDataMapper, TbBasicData> implements TbBasicDataService { |
| | | |
| | | private final TbDeptService tbDeptService; |
| | | private final TbDeptMapper tbDeptMapper; |
| | | private final HttpServletResponse response; |
| | | private final TbFieldService tbFieldService; |
| | | private final TbBasicDataFieldService tbBasicDataFieldService; |
| | | private final TbBasicDataConfigService tbBasicDataConfigService; |
| | | private final TbBasicDataConfigDetailService tbBasicDataConfigDetailService; |
| | | private final TbScoreService scoreService; |
| | | private final TbScoreService tbScoreService; |
| | | |
| | | @Override |
| | | public R<BasicDataReportingVO> getBasicFields(String deptAreaCode) throws Exception { |
| | | BasicDataReportingVO vo = new BasicDataReportingVO(); |
| | | //校验区划代码 |
| | | TbDept dept = tbDeptService.getOne(Wrappers.<TbDept>lambdaQuery().eq(TbDept::getAreaCode, deptAreaCode)); |
| | | TbDept dept = tbDeptMapper.selectOne(Wrappers.<TbDept>lambdaQuery().eq(TbDept::getAreaCode, deptAreaCode)); |
| | | if (Objects.isNull(dept)) { |
| | | throw new ServiceException(String.format("区划代码%s不存在", deptAreaCode)); |
| | | } |
| | |
| | | List<TbBasicDataField> basicDataFields = tbBasicDataFieldService.lambdaQuery() |
| | | .eq(TbBasicDataField::getBasicDataId, basicData.getId()).list(); |
| | | if (CollUtils.isNotEmpty(basicDataFields)) { |
| | | Map<Integer, TbBasicDataField> fieldMap = basicDataFields.stream() |
| | | Map<Long, TbBasicDataField> fieldMap = basicDataFields.stream() |
| | | .collect(Collectors.toMap(TbBasicDataField::getFieldId, Function.identity())); |
| | | vo.getFields().forEach(item -> { |
| | | TbBasicDataField tbBasicDataField = fieldMap.get(item.getId()); |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void saveBasicData(BasicDataDTO dto) { |
| | | //TODO |
| | | //LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String areaCode = loginUser.getUser().getAreaCode(); |
| | | //数据校验 |
| | | if (Objects.isNull(dto) || CollUtils.isEmpty(dto.getFields())) { |
| | | return; |
| | | } |
| | | |
| | | TbBasicData tbBasicData = BeanUtils.copyBean(dto, TbBasicData.class); |
| | | tbBasicData.setDeptAreaCode(areaCode); |
| | | tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); |
| | | this.saveOrUpdate(tbBasicData); |
| | | //保存基础数据动态字段数据 |
| | | List<TbBasicDataField> tbBasicDataFields = BeanUtils.copyList(dto.getFields(), TbBasicDataField.class); |
| | | tbBasicDataFields.forEach(item -> item.setBasicDataId(tbBasicData.getId())); |
| | | //查询需要填写的动态字段 |
| | | List<TbField> fieldList = tbFieldService.lambdaQuery().eq(TbField::getStatus, ShowStatusEnum.SHOW).list(); |
| | | //添加固定字段 转移支付规模、当期GDP |
| | | TbBasicDataField transferPaymentScale = new TbBasicDataField(); |
| | | transferPaymentScale.setBasicDataId(tbBasicData.getId()); |
| | | transferPaymentScale.setFieldId(-1L); |
| | | transferPaymentScale.setFieldValue(tbBasicData.getTransferPaymentScale()); |
| | | tbBasicDataFields.add(transferPaymentScale); |
| | | TbBasicDataField currentGdp = new TbBasicDataField(); |
| | | transferPaymentScale.setBasicDataId(tbBasicData.getId()); |
| | | transferPaymentScale.setFieldId(-2L); |
| | | transferPaymentScale.setFieldValue(tbBasicData.getCurrentGdp()); |
| | | tbBasicDataFields.add(currentGdp); |
| | | //将该基础数据的动态字段数据全部删除 |
| | | tbBasicDataFieldService.remove(null); |
| | | tbBasicDataFieldService.remove(Wrappers.<TbBasicDataField>lambdaQuery().eq(TbBasicDataField::getBasicDataId, tbBasicData.getId())); |
| | | tbBasicDataFieldService.saveBatch(tbBasicDataFields); |
| | | //需要填写的动态字段 |
| | | Set<Long> fieldIds = fieldList.stream().map(TbField::getId).collect(Collectors.toSet()); |
| | | //用户填写的动态字段 |
| | | Set<Long> deptFieldIds = tbBasicDataFields.stream().map(TbBasicDataField::getFieldId).collect(Collectors.toSet()); |
| | | boolean flag = deptFieldIds.containsAll(fieldIds) && (StringUtils.isNotEmpty(dto.getTransferPaymentScale())&& StringUtils.isNotEmpty(dto.getCurrentGdp())); |
| | | if (flag) { |
| | | tbBasicData.setStatus(ReportingStatusEnum.FILLED); |
| | | this.updateById(tbBasicData); |
| | | } |
| | | if (ReportingStatusEnum.FILLED.equals(tbBasicData.getStatus())) { |
| | | calculateScore(tbBasicData); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx"); |
| | | //查询需要填写的动态字段 |
| | | List<TbField> list = tbFieldService.lambdaQuery().eq(TbField::getStatus, ShowStatusEnum.SHOW).list(); |
| | | List<List<String>> head = head(list); |
| | | List<TbField> collect = list.stream() |
| | | .filter(item -> FieldTypeEnum.TEXT.equals(item.getFieldType())) |
| | | .filter(item -> FieldInputTypeEnum.FIXED_CONTENT.equals(item.getTextInputType())) |
| | | .collect(Collectors.toList()); |
| | | Map<Integer, String[]> selectedMap = new HashMap<>(); |
| | | if (CollUtils.isNotEmpty(collect)) { |
| | | selectedMap = new HashMap<>(); |
| | | for (TbField tbField : collect) { |
| | | int outerListIndex = getOuterListIndex(head, tbField.getFieldName()); |
| | | String[] selectStr = tbField.getTextContent().split(","); |
| | | selectedMap.put(outerListIndex, selectStr); |
| | | } |
| | | } |
| | | // 这里需要设置不关闭流 |
| | | EasyExcel.write(response.getOutputStream()).head(head(list)) |
| | | .autoCloseStream(Boolean.FALSE).sheet("模板") |
| | | EasyExcel.write(response.getOutputStream()).head(head) |
| | | .autoCloseStream(Boolean.TRUE).sheet("模板") |
| | | .registerWriteHandler(new SelectedSheetWriteHandler(selectedMap)) |
| | | .registerWriteHandler(new CustomerHandler()) |
| | | .registerWriteHandler(EasyExcelUtil.getStyleStrategy()) |
| | | .doWrite(dataList(list)); |
| | | } |
| | | |
| | | /** |
| | | * 根据字段名获取该字段下标 |
| | | * @param list 表头 |
| | | * @param value 字段名 |
| | | * @return 下标 |
| | | */ |
| | | public int getOuterListIndex(List<List<String>> list, String value) { |
| | | for (int i = 0; i < list.size(); i++) { |
| | | if (list.get(i).contains(value)) { |
| | | return i; |
| | | } |
| | | } |
| | | return -1; // 返回-1表示未找到 |
| | | } |
| | | private List<List<Object>> dataList(List<TbField> list) throws Exception { |
| | | //TODO |
| | | //LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | TbDept dept = tbDeptService.getById(44); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String areaName = loginUser.getUser().getAreaName(); |
| | | |
| | | //当前所在季度 |
| | | int quarterOfYear = DateUtils.getQuarterOfYear(new Date()); |
| | | String quarterOfYearStr = NumberDisplaceChineseUtil.numberToChinese(quarterOfYear); |
| | |
| | | columnNo.add(String.valueOf(i)); |
| | | } |
| | | excellist.add(columnNo); |
| | | excellist.add(Lists.newArrayList(dept.getAreaName(), String.format("%s季度",quarterOfYearStr))); |
| | | excellist.add(Lists.newArrayList(areaName, String.format("%s季度",quarterOfYearStr))); |
| | | return excellist; |
| | | } |
| | | |
| | |
| | | headTitles.add(Lists.newArrayList("转移支付规模")); |
| | | headTitles.add(Lists.newArrayList("当期GDP")); |
| | | list.forEach(item ->{ |
| | | headTitles.add(Lists.newArrayList(item.getLevelOneCategory(), item.getLevelTwoCategory(), item.getLevelThreeCategory(), item.getFieldName())); |
| | | String levelOneCategory = item.getLevelOneCategory(); |
| | | String levelTwoCategory = item.getLevelTwoCategory(); |
| | | String levelThreeCategory = item.getLevelThreeCategory(); |
| | | String fieldName = item.getFieldName(); |
| | | headTitles.add(Lists.newArrayList(levelOneCategory,StringUtils.isBlank(levelTwoCategory) ? fieldName : levelTwoCategory, StringUtils.isBlank(levelThreeCategory) ? fieldName : levelThreeCategory, fieldName)); |
| | | }); |
| | | headTitles.add(Lists.newArrayList("备注")); |
| | | return headTitles; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importBasicData(MultipartFile file) throws Exception { |
| | | //TODO |
| | | //LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | TbDept dept = tbDeptService.getById(44); |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String areaCode = loginUser.getUser().getAreaCode(); |
| | | //查询需要填写的动态字段 |
| | | List<TbField> fieldList = tbFieldService.lambdaQuery().eq(TbField::getStatus, ShowStatusEnum.SHOW).list(); |
| | | EasyExcel.read(file.getInputStream(), new BasicDataListener(this,fieldList, |
| | | tbFieldService,dept,tbBasicDataFieldService,tbBasicDataConfigService, |
| | | tbBasicDataConfigDetailService,scoreService)).sheet().doRead(); |
| | | tbFieldService,areaCode,tbBasicDataFieldService,tbBasicDataConfigService, |
| | | tbBasicDataConfigDetailService,tbScoreService)).sheet().doRead(); |
| | | } |
| | | |
| | | private void calculateScore(TbBasicData tbBasicData) { |
| | | //计算得分 |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery().eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); |
| | | if (CollectionUtils.isEmpty(list)) { |
| | | throw new ServiceException("计算得分失败,平台未配置得分计算规则"); |
| | | } |
| | | List<TbBasicDataConfig> numCalculates = list.stream() |
| | | .filter(item -> CalculateTypeEnum.NUMBER.equals(item.getCalculateType())) |
| | | .collect(Collectors.toList()); |
| | | List<TbBasicDataConfig> textAndPercentages = list.stream() |
| | | .filter(item -> !CalculateTypeEnum.NUMBER.equals(item.getCalculateType())) |
| | | .collect(Collectors.toList()); |
| | | if (CollectionUtils.isNotEmpty(numCalculates)) { |
| | | numCalculates.forEach(item -> { |
| | | Map<String, Object> valueMap = new HashMap<>(); |
| | | String numberCalculateFormula = item.getNumberCalculateFormula(); |
| | | Map<String, Integer> fieldsAndValue = CalculateUtil.getFieldsAndValue(numberCalculateFormula); |
| | | for (Map.Entry<String, Integer> stringIntegerEntry : fieldsAndValue.entrySet()) { |
| | | Optional<TbBasicDataField> tbBasicDataField = tbBasicDataFieldService.lambdaQuery() |
| | | .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId()) |
| | | .eq(TbBasicDataField::getFieldId, stringIntegerEntry.getValue()) |
| | | .oneOpt(); |
| | | tbBasicDataField.ifPresent(basicDataField -> valueMap.put(stringIntegerEntry.getKey(), basicDataField.getFieldValue())); |
| | | } |
| | | double score = CalculateUtil.calculate(numberCalculateFormula, valueMap); |
| | | TbScore tbScore = new TbScore(); |
| | | tbScore.setBasicDataId(tbBasicData.getId()); |
| | | tbScore.setScore(score); |
| | | tbScore.setBasicDataConfigId(item.getId()); |
| | | tbScoreService.save(tbScore); |
| | | }); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(textAndPercentages)) { |
| | | for (TbBasicDataConfig textAndPercentage : textAndPercentages) { |
| | | TbScore tbScore = new TbScore(); |
| | | List<TbBasicDataConfigDetail> details = tbBasicDataConfigDetailService.lambdaQuery() |
| | | .eq(TbBasicDataConfigDetail::getBasicDataConfigId, textAndPercentage.getId()) |
| | | .list(); |
| | | Map<String, String> scoreMap = details.stream().collect(Collectors.toMap(TbBasicDataConfigDetail::getKey, TbBasicDataConfigDetail::getValue)); |
| | | if (CollectionUtils.isNotEmpty(details)) { |
| | | Optional<TbBasicDataField> tbBasicDataFieldOptional = tbBasicDataFieldService.lambdaQuery() |
| | | .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId()) |
| | | .eq(TbBasicDataField::getFieldId, textAndPercentage.getFieldIdStr()) |
| | | .oneOpt(); |
| | | if (tbBasicDataFieldOptional.isPresent()) { |
| | | TbBasicDataField tbBasicDataField = tbBasicDataFieldOptional.get(); |
| | | if (CalculateTypeEnum.TEXT.equals(textAndPercentage.getCalculateType())) { |
| | | String score = scoreMap.get(tbBasicDataField.getFieldValue()); |
| | | tbScore.setBasicDataId(tbBasicData.getId()); |
| | | tbScore.setScore(Double.parseDouble(score)); |
| | | tbScore.setBasicDataConfigId(textAndPercentage.getId()); |
| | | tbScoreService.save(tbScore); |
| | | } |
| | | if (CalculateTypeEnum.PERCENTAGE.equals(textAndPercentage.getCalculateType())) { |
| | | for (Map.Entry<String, String> stringStringEntry : scoreMap.entrySet()) { |
| | | String[] split = stringStringEntry.getKey().split("-"); |
| | | double v = Double.parseDouble(tbBasicDataField.getFieldValue()); |
| | | double min = Double.parseDouble(split[0]); |
| | | double max = Double.parseDouble(split[1]); |
| | | if (v >= min && v <= max) { |
| | | tbScore.setScore(Double.parseDouble(stringStringEntry.getValue())); |
| | | } |
| | | } |
| | | tbScore.setBasicDataId(tbBasicData.getId()); |
| | | tbScore.setBasicDataConfigId(textAndPercentage.getId()); |
| | | tbScoreService.save(tbScore); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public PageDTO<ScoreVO> pageScore(ScoreQuery query) { |
| | | Page<ScoreVO> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | //todo 获取当前登录部门 |
| | | //校验区划代码 |
| | | TbDept dept = tbDeptService.getById(44); |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | String areaCode = user.getAreaCode(); |
| | | Map<String, Date> quarterDate = DateUtils.getQuarterDate(new Date()); |
| | | //当前季度开始 |
| | | Date quarterStart = quarterDate.get("first"); |
| | |
| | | Date quarterEnd = quarterDate.get("last"); |
| | | //查询是否有当前季度的填报记录 |
| | | TbBasicData basicData = this.getOne(Wrappers.<TbBasicData>lambdaQuery() |
| | | .eq(TbBasicData::getDeptAreaCode, dept.getAreaCode()) |
| | | .eq(TbBasicData::getDeptAreaCode, areaCode) |
| | | .between(TbBasicData::getCreateTime, quarterStart,quarterEnd)); |
| | | if (Objects.isNull(basicData)) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | query.setBasicDataId(basicData.getId()); |
| | | //查询对应的基础数据配置 |
| | | List<ScoreVO> vos = scoreService.pageScore(query,page); |
| | | List<ScoreVO> vos = tbScoreService.pageScore(query,page); |
| | | return PageDTO.of(page, vos); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.common.basic.PageDTO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.ReportingStatusEnum; |
| | | import com.ruoyi.common.enums.UserTypeEnum; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.BeanUtils; |
| | | import com.ruoyi.common.utils.CollUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.*; |
| | | import com.ruoyi.system.domain.TbBasicData; |
| | | import com.ruoyi.system.domain.TbDept; |
| | | import com.ruoyi.system.dto.update.DeptFocusDTO; |
| | | import com.ruoyi.system.handler.DeptVerifyHandler; |
| | | import com.ruoyi.system.importExcel.DeptExcel; |
| | | import com.ruoyi.system.mapper.TbDeptMapper; |
| | | import com.ruoyi.system.query.DeptQuery; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.system.service.TbBasicDataService; |
| | | import com.ruoyi.system.service.TbDeptService; |
| | | import com.ruoyi.system.vo.DeptVO; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.InputStream; |
| | | import java.time.Instant; |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | public class TbDeptServiceImpl extends ServiceImpl<TbDeptMapper, TbDept> implements TbDeptService { |
| | | |
| | | private final DeptVerifyHandler deptVerifyHandler; |
| | | private final ISysUserService sysUserService; |
| | | private final TbBasicDataService tbBasicDataService; |
| | | |
| | | @Override |
| | | public PageDTO<DeptVO> queryPage(DeptQuery query) { |
| | | Page<TbDept> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<TbDept> tbDeptPage = this.lambdaQuery().like(StringUtils.isNotEmpty(query.getAreaName()), TbDept::getAreaName, query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getAccount()), TbDept::getAccount, query.getAccount()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), TbDept::getPhone, query.getPhone()) |
| | | .orderByDesc(TbDept::getCreateTime) |
| | | Page<SysUser> page = new Page<>(query.getPageNum(), query.getPageSize()); |
| | | Page<SysUser> userPage = sysUserService.lambdaQuery() |
| | | .eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode()) |
| | | .like(StringUtils.isNotEmpty(query.getAreaName()), SysUser::getAreaName, query.getAreaName()) |
| | | .like(StringUtils.isNotEmpty(query.getUserName()), SysUser::getUserName, query.getUserName()) |
| | | .like(StringUtils.isNotEmpty(query.getPhone()), SysUser::getPhoneNumber, query.getPhone()) |
| | | .orderByDesc(SysUser::getCreateTime) |
| | | .page(page); |
| | | if (CollUtils.isEmpty(tbDeptPage.getRecords())) { |
| | | |
| | | if (CollUtils.isEmpty(userPage.getRecords())) { |
| | | return PageDTO.empty(page); |
| | | } |
| | | return PageDTO.of(tbDeptPage, DeptVO.class); |
| | | return PageDTO.of(userPage, DeptVO.class); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void focus(DeptFocusDTO dto) { |
| | | TbDept dept = this.getById(dto.getId()); |
| | | if (Objects.isNull(dept)) { |
| | | throw new ServiceException("非法参数"); |
| | | Optional<SysUser> sysUser = sysUserService.lambdaQuery().eq(SysUser::getUserId, dto.getUserId()).oneOpt(); |
| | | if (sysUser.isPresent()) { |
| | | sysUserService.lambdaUpdate() |
| | | .eq(SysUser::getUserId, dto.getUserId()) |
| | | .set(SysUser::getFocussed, dto.getFocussed()) |
| | | .update(); |
| | | } |
| | | this.lambdaUpdate() |
| | | .eq(TbDept::getId, dto.getId()) |
| | | .set(TbDept::getFocussed, dto.getFocussed()) |
| | | .update(); |
| | | } |
| | | |
| | | @Override |
| | | public R<Void> reportingMessage() { |
| | | Map<String, Date> quarterDate = DateUtils.getQuarterDate(new Date()); |
| | | //当前季度开始 |
| | | Date quarterStart = quarterDate.get("first"); |
| | | //当前季度结束 |
| | | Date quarterEnd = quarterDate.get("last"); |
| | | //判断当前时间是否在季度初1-15号 |
| | | Instant instant = quarterStart.toInstant(); |
| | | LocalDate quarterStartLocalDate = instant.atZone(ZoneId.systemDefault()).toLocalDate(); |
| | | LocalDate fifteenDaysLimit = quarterStartLocalDate.plusDays(15); |
| | | LocalDate now = LocalDate.now(); |
| | | //如果当前时间不在规定范围内:季度初1-15号 |
| | | if (now.isAfter(quarterStartLocalDate) || now.isBefore(fifteenDaysLimit)) { |
| | | //查询所有的部门 |
| | | List<SysUser> list = sysUserService.lambdaQuery().eq(SysUser::getUserType, UserTypeEnum.DEPARTMENT.getCode()).list(); |
| | | Set<String> deptAreaCodeList = list.stream().map(SysUser::getAreaCode).collect(Collectors.toSet()); |
| | | //查询当前季度填报了数据的部门 |
| | | List<TbBasicData> filledBasicData = tbBasicDataService.lambdaQuery().between(TbBasicData::getCreateTime, quarterStartLocalDate, fifteenDaysLimit) |
| | | .eq(TbBasicData::getStatus, ReportingStatusEnum.FILLED).list(); |
| | | Set<String> filledDeptCodes = filledBasicData.stream().map(TbBasicData::getDeptAreaCode).collect(Collectors.toSet()); |
| | | if (!filledDeptCodes.containsAll(deptAreaCodeList)) { |
| | | return R.fail("有部门未上传季度数据"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |
| | |
| | | updateCategoryAndChildren(dto.getId(), dto.getStatus()); |
| | | } |
| | | |
| | | private void updateCategoryAndChildren(Integer id, ShowStatusEnum status) { |
| | | private void updateCategoryAndChildren(Long id, ShowStatusEnum status) { |
| | | TbFieldCategory category = this.validateParam(id); |
| | | this.lambdaUpdate() |
| | | .eq(TbFieldCategory::getId, id) |
| | |
| | | .update(); |
| | | List<TbFieldCategory> children = this.lambdaQuery().eq(TbFieldCategory::getParentId, category.getId()).list(); |
| | | if (CollUtils.isNotEmpty(children)) { |
| | | List<Integer> childIds = children.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | List<Long> childIds = children.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | childIds.forEach(childId -> updateCategoryAndChildren(childId, status)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void deleteChildren(Integer id) { |
| | | public void deleteChildren(Long id) { |
| | | //认定为二级分类 |
| | | TbFieldCategory category = this.getById(id); |
| | | if (Objects.nonNull(category)) { |
| | | //查询是否有三级分类 |
| | | List<TbFieldCategory> threeCategoryList = this.lambdaQuery().eq(TbFieldCategory::getParentId, id).list(); |
| | | if (CollectionUtils.isNotEmpty(threeCategoryList)) { |
| | | List<Integer> ids = threeCategoryList.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | List<Long> ids = threeCategoryList.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | //删除该二级分类下面的三级分类 |
| | | this.removeByIds(ids); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(Integer id) { |
| | | public void delete(Long id) { |
| | | //一级分类 |
| | | validateParam(id); |
| | | //查询是否有二级分类 |
| | | List<TbFieldCategory> threeCategoryList = this.lambdaQuery().eq(TbFieldCategory::getParentId, id).list(); |
| | | if (CollectionUtils.isNotEmpty(threeCategoryList)) { |
| | | List<Integer> ids = threeCategoryList.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | List<Long> ids = threeCategoryList.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | //查询三级分类 |
| | | List<TbFieldCategory> list = this.lambdaQuery().in(TbFieldCategory::getParentId, ids).list(); |
| | | if (CollectionUtils.isNotEmpty(list)) { |
| | | List<Integer> ids1 = list.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | List<Long> ids1 = list.stream().map(TbFieldCategory::getId).collect(Collectors.toList()); |
| | | //删除三级分类 |
| | | this.removeByIds(ids1); |
| | | } |
| | |
| | | this.removeById(id); |
| | | } |
| | | |
| | | private TbFieldCategory validateParam(Integer id) { |
| | | private TbFieldCategory validateParam(Long id) { |
| | | TbFieldCategory category = this.getById(id); |
| | | if (Objects.isNull(category)) { |
| | | throw new ServiceException("非法参数"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<FieldCategoryVO> queryFieldCategories(Integer id) { |
| | | public List<FieldCategoryVO> queryFieldCategories(Long id) { |
| | | List<TbFieldCategory> list = this.lambdaQuery() |
| | | .select(TbFieldCategory::getId,TbFieldCategory::getFieldCategoryName) |
| | | .eq(TbFieldCategory::getParentId, id) |
| | |
| | | } |
| | | |
| | | @Override |
| | | public FieldCategoryDetailVO getDetailsById(Integer id) { |
| | | public FieldCategoryDetailVO getDetailsById(Long id) { |
| | | TbFieldCategory oneCategory = this.getById(id); |
| | | if (Objects.isNull(oneCategory)) { |
| | | return new FieldCategoryDetailVO(); |
| | |
| | | @Override |
| | | public void add(FieldDTO dto) { |
| | | //参数校验 |
| | | Integer fieldType = dto.getFieldType(); |
| | | FieldTypeEnum fieldType = dto.getFieldType(); |
| | | //1:数字 2:文本 3:百分比 |
| | | if (FieldTypeEnum.TEXT.getCode().equals(fieldType)) { |
| | | if (FieldTypeEnum.TEXT.equals(fieldType)) { |
| | | if (StringUtils.isNull(dto.getTextInputType())) { |
| | | throw new ServiceException("输入类型不能为空"); |
| | | } else if (FieldInputTypeEnum.FIXED_CONTENT.getCode().equals(dto.getTextInputType()) && StringUtils.isBlank(dto.getTextContent())) { |
| | | } else if (FieldInputTypeEnum.FIXED_CONTENT.equals(dto.getTextInputType()) && StringUtils.isBlank(dto.getTextContent())) { |
| | | throw new ServiceException("内容设置不能为空"); |
| | | } |
| | | } |
| | |
| | | log.info("======子线程执行handleDataConfig{}",Thread.currentThread().getName() ); |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery().eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW.getCode()).list(); |
| | | if (CollUtils.isNotEmpty(list)) { |
| | | List<Integer> ids = list.stream().map(config -> { |
| | | List<Long> ids = list.stream().map(config -> { |
| | | String fieldIdStr = config.getFieldIdStr(); |
| | | String[] split = fieldIdStr.split(","); |
| | | //字符串数组转为List |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String influencedData(Integer id) { |
| | | public String influencedData(Long id) { |
| | | List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery().eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); |
| | | if (CollUtils.isEmpty(list)) { |
| | | return ""; |
| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * @author mitao |
| | | * @date 2024/3/13 |
| | |
| | | @Data |
| | | @ApiModel(value="部门VO") |
| | | public class DeptVO { |
| | | |
| | | @ApiModelProperty(value = "部门id") |
| | | private Integer id; |
| | | private Integer userId; |
| | | |
| | | @ApiModelProperty(value = "部门地区") |
| | | private String areaName; |
| | |
| | | private String personInCharge; |
| | | |
| | | @ApiModelProperty(value = "登录账号") |
| | | private String account; |
| | | private String userName; |
| | | |
| | | @ApiModelProperty(value = "联系电话") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "登录密码") |
| | | private String password; |
| | | private String phoneNumber; |
| | | |
| | | @ApiModelProperty(value = "重点关注(0:否 1:是)") |
| | | private Boolean focussed; |
| | | private DisabledEnum focussed; |
| | | |
| | | @ApiModelProperty(value = "删除标志(0代表存在 1代表删除)") |
| | | private String delFlag; |
| | | |
| | | @ApiModelProperty(value = "创建者") |
| | | private String createBy; |
| | | |
| | | @ApiModelProperty(value = "创建时间") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "更新者") |
| | | private String updateBy; |
| | | |
| | | @ApiModelProperty(value = "更新时间") |
| | | private LocalDateTime updateTime; |
| | | } |
| | |
| | | @ApiModel(value="字段分类详情视图对象") |
| | | public class FieldCategoryDetailVO { |
| | | @ApiModelProperty(value = "分类id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "父级id") |
| | | private Integer parentId; |
| | | private Long parentId; |
| | | |
| | | @ApiModelProperty(value = "分类名称") |
| | | private String fieldCategoryName; |
| | |
| | | @ApiModel(value="字段分类视图对象") |
| | | public class FieldCategoryVO { |
| | | @ApiModelProperty(value = "分类id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "状态(0=展示 1=隐藏)") |
| | | private ShowStatusEnum status; |
| | |
| | | private static final long serialVersionUID = -7412686975187928384L; |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | private String fieldName; |
| | |
| | | public class FieldVO { |
| | | |
| | | @ApiModelProperty(value = "字段id") |
| | | private Integer id; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "字段名") |
| | | private String fieldName; |
| | |
| | | private FieldTypeEnum fieldType; |
| | | |
| | | @ApiModelProperty(value = "一级分类id") |
| | | private Integer levelOneCategoryId; |
| | | private Long levelOneCategoryId; |
| | | |
| | | @ApiModelProperty(value = "二级分类id") |
| | | private Integer levelTwoCategoryId; |
| | | private Long levelTwoCategoryId; |
| | | |
| | | @ApiModelProperty(value = "三级分类id") |
| | | private Integer levelThreeCategoryId; |
| | | private Long levelThreeCategoryId; |
| | | |
| | | @ApiModelProperty(value = "一级分类") |
| | | private String levelOneCategory; |
| | |
| | | |
| | | /** 手机号码 */ |
| | | @ApiModelProperty(value = "手机号码") |
| | | private String phonenumber; |
| | | private String phoneNumber; |
| | | |
| | | /** 用户性别 */ |
| | | @ApiModelProperty(value = "用户性别 0=男,1=女,2=未知") |
| | |
| | | <result property="costTime" column="cost_time" /> |
| | | <result property="companyName" column="companyName" /> |
| | | <result property="roleName" column="roleName" /> |
| | | <result property="phonenumber" column="phonenumber" /> |
| | | <result property="phoneNumber" column="phone_number" /> |
| | | <result property="userId" column="userId" /> |
| | | <result property="nickName" column="nickName" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectOperLogVo"> |
| | | select oper_id, title, business_type, `method`, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, |
| | | json_result, status, error_msg, oper_time, cost_time,companyName,roleName,phonenumber,userId,nickName |
| | | json_result, status, error_msg, oper_time, cost_time,companyName,roleName,phoneNumber,userId,nickName |
| | | from sys_oper_log |
| | | </sql> |
| | | |
| | | <insert id="insertOperlog" parameterType="SysOperLog"> |
| | | insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time,companyName,roleName,phonenumber,userId,nickName, oper_time) |
| | | values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime},#{companyName},#{roleName},#{phonenumber},#{userId},#{nickName}, sysdate()) |
| | | insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time,companyName,roleName,phoneNumber,userId,nickName, oper_time) |
| | | values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime},#{companyName},#{roleName},#{phoneNumber},#{userId},#{nickName}, sysdate()) |
| | | </insert> |
| | | |
| | | <select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult"> |
| | |
| | | select sol.oper_id AS operId, sol.title AS title, sol.business_type AS businessType, sol.`method` AS method, sol.request_method AS requestMethod, |
| | | sol.operator_type AS operatorType,sol.oper_name AS operName,sol.dept_name AS deptName, sol.oper_url AS operUrl, sol.oper_ip AS operIp, |
| | | sol.oper_location AS operLocation, sol.oper_param AS operLocation,sol.json_result AS jsonResult, sol.status AS status,sol.error_msg AS errorMsg, |
| | | sol.oper_time AS operTime, sol.cost_time AS costTime,sol.companyName AS companyName,sol.roleName AS roleName,sol.phonenumber AS phonenumber, |
| | | sol.oper_time AS operTime, sol.cost_time AS costTime,sol.companyName AS companyName,sol.roleName AS roleName,sol.phoneNumber AS phoneNumber, |
| | | sol.userId AS userId,sol.nickName AS nickName |
| | | from sys_oper_log sol |
| | | <where> |
| | |
| | | <result property="userName" column="user_name" /> |
| | | <result property="nickName" column="nick_name" /> |
| | | <result property="email" column="email" /> |
| | | <result property="phonenumber" column="phonenumber" /> |
| | | <result property="phoneNumber" column="phone_number" /> |
| | | <result property="sex" column="sex" /> |
| | | <result property="avatar" column="avatar" /> |
| | | <result property="password" column="password" /> |
| | |
| | | <result property="updateTime" column="update_time" /> |
| | | <result property="remark" column="remark" /> |
| | | <result property="ifBlack" column="ifBlack" /> |
| | | <result property="areaName" column="area_name" /> |
| | | <result property="areaAlias" column="area_alias" /> |
| | | <result property="areaCode" column="area_code" /> |
| | | <result property="areaLevel" column="area_level" /> |
| | | <result property="countyFlag" column="county_flag" /> |
| | | <result property="personInCharge" column="person_in_charge" /> |
| | | <result property="focussed" column="focussed" /> |
| | | <association property="dept" javaType="SysDept" resultMap="deptResult" /> |
| | | <collection property="roles" javaType="java.util.List" resultMap="RoleResult" /> |
| | | </resultMap> |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phone_number, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, |
| | | d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status, |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status |
| | | r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,u.area_name,u.area_alias,u.area_code, |
| | | u.area_level,u.county_flag,u.person_in_charge,u.focussed |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | | left join sys_role r on r.role_id = ur.role_id |
| | | </sql> |
| | | |
| | | <sql id="selectDeptUserVo"> |
| | | select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phone_number, u.password, u.sex, u.status, |
| | | u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.area_name,u.area_alias,u.area_code, |
| | | u.area_level,u.county_flag,u.person_in_charge,u.focussed |
| | | from sys_user u |
| | | </sql> |
| | | <select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, |
| | | select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phone_number, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, |
| | | u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | where u.del_flag = '0' |
| | |
| | | <if test="status != null and status != ''"> |
| | | AND u.status = #{status} |
| | | </if> |
| | | <if test="phonenumber != null and phonenumber != ''"> |
| | | AND u.phonenumber like concat('%', #{phonenumber}, '%') |
| | | <if test="phoneNumber != null and phoneNumber != ''"> |
| | | AND u.phone_number like concat('%', #{phoneNumber}, '%') |
| | | </if> |
| | | <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 --> |
| | | AND date_format(u.create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d') |
| | |
| | | </select> |
| | | |
| | | <select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phone_number, u.status, u.create_time |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | |
| | | <if test="userName != null and userName != ''"> |
| | | AND u.user_name like concat('%', #{userName}, '%') |
| | | </if> |
| | | <if test="phonenumber != null and phonenumber != ''"> |
| | | AND u.phonenumber like concat('%', #{phonenumber}, '%') |
| | | <if test="phoneNumber != null and phoneNumber != ''"> |
| | | AND u.phone_number like concat('%', #{phoneNumber}, '%') |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | | </select> |
| | | |
| | | <select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult"> |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time |
| | | select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phone_number, u.status, u.create_time |
| | | from sys_user u |
| | | left join sys_dept d on u.dept_id = d.dept_id |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | |
| | | <if test="userName != null and userName != ''"> |
| | | AND u.user_name like concat('%', #{userName}, '%') |
| | | </if> |
| | | <if test="phonenumber != null and phonenumber != ''"> |
| | | AND u.phonenumber like concat('%', #{phonenumber}, '%') |
| | | <if test="phoneNumber != null and phoneNumber != ''"> |
| | | AND u.phone_number like concat('%', #{phoneNumber}, '%') |
| | | </if> |
| | | <!-- 数据范围过滤 --> |
| | | ${params.dataScope} |
| | |
| | | |
| | | <select id="selectUserById" parameterType="Long" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,u.ifBlack AS ifBlack, u.districtId AS districtId, |
| | | u.phone_number AS phoneNumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,/*u.ifBlack AS ifBlack,u.districtId AS districtId,*/ |
| | | ur.role_id AS roleId,sr.role_name AS roleName,u.deptName as deptName |
| | | from sys_user u |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | |
| | | </select> |
| | | |
| | | <select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1 |
| | | select user_id, phoneNumber from sys_user where phone_number = #{phoneNumber} and del_flag = '0' limit 1 |
| | | </select> |
| | | |
| | | <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> |
| | | select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 |
| | | </select> |
| | | <select id="selectUserByIds" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select user_id AS userId, dept_id AS deptId, user_name AS userName, nick_name AS nickName, email AS email, avatar AS avatar, phonenumber AS phonenumber |
| | | select user_id AS userId, dept_id AS deptId, user_name AS userName, nick_name AS nickName, email AS email, avatar AS avatar, phone_number AS phoneNumber |
| | | from sys_user where user_id in |
| | | <foreach collection="userIds" separator="," item="userId" open="(" close=")"> |
| | | #{userId} |
| | | </foreach> |
| | | </select> |
| | | <select id="selectList" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | <select id="queryList" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,u.ifBlack AS ifBlack, u.districtId AS districtId |
| | | u.phone_number AS phoneNumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark |
| | | from sys_user u |
| | | WHERE u.del_flag = 0 |
| | | </select> |
| | |
| | | </select> |
| | | <select id="selectListByNamePhone" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,u.ifBlack AS ifBlack, u.districtId AS districtId |
| | | u.phone_number AS phoneNumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,/*u.ifBlack AS ifBlack,u.districtId AS districtId*/ |
| | | from sys_user u |
| | | WHERE u.del_flag = 0 |
| | | <if test="name != null and name != ''"> |
| | | AND (u.nick_name LIKE concat('%',#{name},'%') |
| | | OR u.phonenumber LIKE concat('%',#{name},'%')) |
| | | OR u.phone_number LIKE concat('%',#{name},'%')) |
| | | </if> |
| | | </select> |
| | | <select id="selectUserByUserNameList" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber |
| | | u.phone_number AS phoneNumber |
| | | from sys_user u |
| | | WHERE u.del_flag = 0 |
| | | <if test="names != null and names.size()>0"> |
| | |
| | | </select> |
| | | <select id="selectByPhone" resultType="com.ruoyi.common.core.domain.entity.SysUser"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.phone_number AS phoneNumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark |
| | | from sys_user u where u.phonenumber = #{phonenumber} and u.status = 0 and u.del_flag = 0 |
| | | from sys_user u where u.phone_number = #{phoneNumber} and u.status = 0 and u.del_flag = 0 |
| | | </select> |
| | | <select id="getUserInfoBy" resultType="com.ruoyi.system.vo.UserInfoVo"> |
| | | select t1.*,t2.companyName,t2.companyType from sys_user t1 |
| | |
| | | </select> |
| | | <select id="pageList" resultType="com.ruoyi.system.vo.SysUserVO"> |
| | | select u.user_id AS userId, u.dept_id AS deptId, u.user_name AS userName, u.nick_name AS nickName, u.email AS email, u.avatar AS avatar, |
| | | u.phonenumber AS phonenumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,u.ifBlack AS ifBlack, u.districtId AS districtId, |
| | | u.phone_number AS phoneNumber, u.sex AS sex, u.status AS status, u.del_flag AS delFlag, u.login_ip AS loginIp, |
| | | u.login_date AS loginDate, u.create_by AS createBy, u.create_time AS createTime, u.remark AS remark,/*u.ifBlack AS ifBlack, u.districtId AS districtId,*/ |
| | | r.role_id AS roleId, r.role_name AS roleName, r.role_key AS roleKey, r.role_sort AS roleSort, r.data_scope AS dataScope, r.status as role_status,u.deptName as deptName |
| | | from sys_user u |
| | | left join sys_user_role ur on u.user_id = ur.user_id |
| | |
| | | <if test="query.roleId != null"> |
| | | AND r.role_id = #{query.roleId} |
| | | </if> |
| | | <if test="query.phonenumber != null and query.phonenumber != ''"> |
| | | AND u.phonenumber LIKE concat('%',#{query.phonenumber},'%') |
| | | <if test="query.phoneNumber != null and query.phoneNumber != ''"> |
| | | AND u.phone_number LIKE concat('%',#{query.phoneNumber},'%') |
| | | </if> |
| | | <if test="query.status != null and query.status != ''"> |
| | | AND u.status = #{query.status} |
| | |
| | | ORDER BY u.create_time DESC |
| | | </select> |
| | | <select id="selectIdByPhone" resultType="java.lang.Long"> |
| | | select user_id from sys_user where phonenumber = #{phonenumber} and status = 0 and del_flag = 0 |
| | | select user_id from sys_user where phone_number = #{phoneNumber} and status = 0 and del_flag = 0 |
| | | </select> |
| | | <select id="selectDeptUserByUserName" resultType="com.ruoyi.common.core.domain.entity.SysUser" |
| | | parameterType="java.lang.String"> |
| | | <include refid="selectUserVo"/> |
| | | where u.user_name = #{userName} and u.del_flag = '0' and u.user_type = '2' |
| | | </select> |
| | | <select id="selectPlatUserByUserName" resultType="com.ruoyi.common.core.domain.entity.SysUser" |
| | | parameterType="java.lang.String"> |
| | | <include refid="selectUserVo"/> |
| | | where u.user_name = #{userName} and u.del_flag = '0' and u.user_type = '1' |
| | | </select> |
| | | |
| | | <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> |
| | |
| | | <if test="nickName != null and nickName != ''">nick_name,</if> |
| | | <if test="email != null and email != ''">email,</if> |
| | | <if test="avatar != null and avatar != ''">avatar,</if> |
| | | <if test="phonenumber != null and phonenumber != ''">phonenumber,</if> |
| | | <if test="phoneNumber != null and phoneNumber != ''">phone_number,</if> |
| | | <if test="sex != null and sex != ''">sex,</if> |
| | | <if test="password != null and password != ''">password,</if> |
| | | <if test="status != null and status != ''">status,</if> |
| | | <if test="createBy != null and createBy != ''">create_by,</if> |
| | | <if test="remark != null and remark != ''">remark,</if> |
| | | <if test="ifBlack != null">ifBlack,</if> |
| | | <if test="districtId != null">districtId,</if> |
| | | <!-- <if test="ifBlack != null">ifBlack,</if>--> |
| | | <!-- <if test="districtId != null">districtId,</if>--> |
| | | create_time |
| | | )values( |
| | | <if test="userId != null and userId != ''">#{userId},</if> |
| | |
| | | <if test="nickName != null and nickName != ''">#{nickName},</if> |
| | | <if test="email != null and email != ''">#{email},</if> |
| | | <if test="avatar != null and avatar != ''">#{avatar},</if> |
| | | <if test="phonenumber != null and phonenumber != ''">#{phonenumber},</if> |
| | | <if test="phoneNumber != null and phoneNumber != ''">#{phone_number},</if> |
| | | <if test="sex != null and sex != ''">#{sex},</if> |
| | | <if test="password != null and password != ''">#{password},</if> |
| | | <if test="status != null and status != ''">#{status},</if> |
| | | <if test="createBy != null and createBy != ''">#{createBy},</if> |
| | | <if test="remark != null and remark != ''">#{remark},</if> |
| | | <if test="ifBlack != null">#{ifBlack},</if> |
| | | <if test="districtId != null">#{districtId},</if> |
| | | <!-- <if test="ifBlack != null">#{ifBlack},</if>--> |
| | | <!-- <if test="districtId != null">#{districtId},</if>--> |
| | | sysdate() |
| | | ) |
| | | </insert> |
| | |
| | | <if test="nickName != null and nickName != ''">nick_name = #{nickName},</if> |
| | | <if test="deptName != null and deptName != ''">deptName = #{deptName},</if> |
| | | <if test="email != null ">email = #{email},</if> |
| | | <if test="phonenumber != null ">phonenumber = #{phonenumber},</if> |
| | | <if test="phoneNumber != null ">phone_number = #{phoneNumber},</if> |
| | | <if test="sex != null and sex != ''">sex = #{sex},</if> |
| | | <if test="avatar != null and avatar != ''">avatar = #{avatar},</if> |
| | | <if test="password != null and password != ''">password = #{password},</if> |
| | |
| | | <if test="loginDate != null">login_date = #{loginDate},</if> |
| | | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| | | <if test="remark != null">remark = #{remark},</if> |
| | | <if test="ifBlack != null">ifBlack = #{ifBlack},</if> |
| | | update_time = sysdate() |
| | | </set> |
| | | where user_id = #{userId} |
| | |
| | | <if test="query.typeName !=null and query.typeName!=''"> |
| | | AND tbdc.calculate_type = #{query.type} |
| | | </if> |
| | | |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | nick_name varchar(30) not null comment '用户昵称', |
| | | user_type varchar(2) default '00' comment '用户类型(00系统用户)', |
| | | email varchar(50) default '' comment '用户邮箱', |
| | | phonenumber varchar(11) default '' comment '手机号码', |
| | | phone_number varchar(11) default '' comment '手机号码', |
| | | sex char(1) default '0' comment '用户性别(0男 1女 2未知)', |
| | | avatar varchar(100) default '' comment '头像地址', |
| | | password varchar(100) default '' comment '密码', |