From 2da6576ce17cb18f042f561648230736945ec4c1 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期三, 10 四月 2024 19:35:16 +0800 Subject: [PATCH] 大屏数据配置接口 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/CurrentQuarterController.java | 28 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java | 57 + ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataServiceImpl.java | 28 ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 4 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbDataScreenConfigController.java | 91 ++ ruoyi-system/src/main/resources/mapper/system/TbBasicDataMapper.xml | 113 +- ruoyi-common/src/main/java/com/ruoyi/common/enums/SubTypeEnum.java | 28 ruoyi-system/src/main/java/com/ruoyi/system/dto/update/RiskLevelUpdDTO.java | 41 + ruoyi-system/src/main/java/com/ruoyi/system/handler/CustomerHandler.java | 16 ruoyi-system/src/main/java/com/ruoyi/system/service/TbQuestionService.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicData.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicDataConfigDetail.java | 9 ruoyi-system/src/main/java/com/ruoyi/system/service/TbDataScreenConfigService.java | 15 ruoyi-system/src/main/java/com/ruoyi/system/dto/update/DataIndicatorsUpdDTO.java | 35 + ruoyi-system/src/main/java/com/ruoyi/system/dto/update/FormalIndicatorsUpdDTO.java | 28 ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java | 209 ++--- ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml | 447 +++++++------ ruoyi-system/src/main/java/com/ruoyi/system/domain/TbDataScreenConfig.java | 39 + ruoyi-admin-dept/src/main/java/com/ruoyi/RuoYiAdminDeptApplication.java | 18 ruoyi-admin-dept/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java | 30 ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java | 70 + ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java | 30 ruoyi-system/src/main/java/com/ruoyi/system/service/TbBasicDataService.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbQuestionServiceImpl.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/listener/HistoryDataListener.java | 102 ++- ruoyi-system/src/main/resources/mapper/system/TbDataScreenConfigMapper.xml | 42 ruoyi-system/src/main/java/com/ruoyi/system/listener/BasicDataListener.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/dto/update/QuestionUpdDTO.java | 10 /dev/null | 54 - ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/HistoryDataController.java | 2 ruoyi-system/src/main/java/com/ruoyi/system/query/DataScreenConfigQuery.java | 24 ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScreenConfigEnum.java | 27 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java | 223 +++--- ruoyi-system/src/main/java/com/ruoyi/system/vo/DataScreenConfigVO.java | 44 + 34 files changed, 1,155 insertions(+), 727 deletions(-) diff --git a/ruoyi-admin-dept/src/main/java/com/ruoyi/RuoYiAdminDeptApplication.java b/ruoyi-admin-dept/src/main/java/com/ruoyi/RuoYiAdminDeptApplication.java index 040ff61..0d9dabb 100644 --- a/ruoyi-admin-dept/src/main/java/com/ruoyi/RuoYiAdminDeptApplication.java +++ b/ruoyi-admin-dept/src/main/java/com/ruoyi/RuoYiAdminDeptApplication.java @@ -1,5 +1,7 @@ package com.ruoyi; +import java.net.InetAddress; +import java.net.UnknownHostException; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -12,28 +14,26 @@ import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.client.RestTemplate; -import java.net.UnknownHostException; - /** * 启动程序 - * + * * @author ruoyi */ @Slf4j @EnableScheduling//开启定时任务 -@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) -public class RuoYiAdminDeptApplication -{ +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class RuoYiAdminDeptApplication { + public static void main(String[] args) throws UnknownHostException { - ConfigurableApplicationContext application = SpringApplication.run(RuoYiAdminDeptApplication.class, args); + ConfigurableApplicationContext application = SpringApplication.run( + RuoYiAdminDeptApplication.class, args); Environment env = application.getEnvironment(); log.info("\n----------------------------------------------------------\n\t" + "应用 '{}' 运行成功! 访问连接:\n\t" + "Swagger文档: \t\thttp://{}:{}/doc.html\n" + "----------------------------------------------------------", env.getProperty("spring.application.name", "后台"), - //InetAddress.getLocalHost().getHostAddress(), - "localhost", + InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port", "8081")); } diff --git a/ruoyi-admin-dept/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java b/ruoyi-admin-dept/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java index ba30153..7dba0e0 100644 --- a/ruoyi-admin-dept/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java +++ b/ruoyi-admin-dept/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java @@ -1,17 +1,12 @@ package com.ruoyi.web.controller.tool; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.system.service.*; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.time.Instant; -import java.util.*; /** @@ -38,11 +33,12 @@ } } + /** * 每隔一分钟去处理的定时任务 */ @Scheduled(fixedRate = 1000 * 60) - public void taskMinute(){ + public void taskMinute() { try { // List<Message> list = messageService.list(); // Map<Integer,List<Message>> map = new LinkedHashMap<>(); @@ -79,27 +75,15 @@ * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 0 * * *") - public void taskDay(){ - - List<SysRole> sysRoles = roleService.selectListByDelFlag(2); - if(CollectionUtils.isEmpty(sysRoles)){ - return; - } - for (SysRole sysRole : sysRoles) { - if(sysRole.getRemoveDays()>0){ - sysRole.setRemoveDays(sysRole.getRemoveDays()-1); - roleService.updateRole(sysRole); - }else { - roleService.deleteRoleById(sysRole.getRoleId()); - } - } + public void taskDay() { } + /** * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 1 * * ? ") - public void taskDayOne(){ + public void taskDayOne() { } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/CurrentQuarterController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/CurrentQuarterController.java index bb27d80..c010d2b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/CurrentQuarterController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/CurrentQuarterController.java @@ -7,7 +7,7 @@ import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.domain.TbQuestion; import com.ruoyi.system.dto.QuestionDTO; -import com.ruoyi.system.dto.QuestionUpdDto; +import com.ruoyi.system.dto.update.QuestionUpdDTO; import com.ruoyi.system.query.CurrentFieldsQuery; import com.ruoyi.system.query.QuestionQuery; import com.ruoyi.system.query.ScoreCalculateDetailQuery; @@ -15,14 +15,25 @@ import com.ruoyi.system.service.TbBasicDataService; import com.ruoyi.system.service.TbQuestionService; import com.ruoyi.system.service.TbScoreService; -import com.ruoyi.system.vo.*; +import com.ruoyi.system.vo.CurrentFieldsAllVO; +import com.ruoyi.system.vo.CurrentFieldsDetailVO; +import com.ruoyi.system.vo.CurrentFieldsVO; +import com.ruoyi.system.vo.QuestionVO; +import com.ruoyi.system.vo.ScoreCalculateDetailVO; +import com.ruoyi.system.vo.ScoreCalculateVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; /** * @author mitao @@ -46,7 +57,8 @@ */ @ApiOperation(value = "字段统计", notes = "字段统计") @PostMapping("/fields-statics") - public R<PageDTO<CurrentFieldsVO>> fieldsStatics(@Validated @RequestBody CurrentFieldsQuery dto) { + public R<PageDTO<CurrentFieldsVO>> fieldsStatics( + @Validated @RequestBody CurrentFieldsQuery dto) { try { dto.setQuarter(DateUtils.getNowQuarter()); return tbBasicDataService.fieldsStatics(dto); @@ -104,7 +116,8 @@ */ @PostMapping("/score-calculate") @ApiOperation("得分计算") - public R<PageDTO<ScoreCalculateVO>> scoreCalculate(@Validated @RequestBody ScoreCalculateQuery query) { + public R<PageDTO<ScoreCalculateVO>> scoreCalculate( + @Validated @RequestBody ScoreCalculateQuery query) { try { query.setQuarter(DateUtils.getNowQuarter()); return R.ok(tbBasicDataService.scoreCalculatePage(query)); @@ -123,7 +136,8 @@ @PostMapping("/score-calculate-detail") @ApiOperation("得分计算-查看详情") @ApiImplicitParam(name = "areaName", value = "部门名称", required = false, dataType = "string", paramType = "query", dataTypeClass = String.class) - public R<ScoreCalculateDetailVO> scoreCalculateDetail(@Validated @RequestBody ScoreCalculateDetailQuery query) { + public R<ScoreCalculateDetailVO> scoreCalculateDetail( + @Validated @RequestBody ScoreCalculateDetailQuery query) { return R.ok(tbScoreService.scoreCalculateDetail(query)); } @@ -156,7 +170,7 @@ */ @PostMapping("/edit-question") @ApiOperation(value = "发现问题-编辑问题", notes = "发现问题") - public R<Void> editQuestion(@Validated @RequestBody QuestionUpdDto dto) { + public R<Void> editQuestion(@Validated @RequestBody QuestionUpdDTO dto) { try { tbQuestionService.editQuestion(dto); return R.ok(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/HistoryDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/HistoryDataController.java index 9282397..9db3a38 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/HistoryDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/HistoryDataController.java @@ -74,7 +74,7 @@ .eq(TbBasicData::getStatus, ReportingStatusEnum.FILLED) .between(flag, TbBasicData::getCreateTime, startTime, endTime) .groupBy(TbBasicData::getQuarter) - .orderByDesc(TbBasicData::getCreateTime) + .orderByDesc(TbBasicData::getReportingTime) .page(new Page<>(dto.getPageNum(), dto.getPageSize())); return R.ok(PageDTO.of(page, BasicDataVO.class)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbDataScreenConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbDataScreenConfigController.java index b450411..f9a2752 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbDataScreenConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TbDataScreenConfigController.java @@ -1,6 +1,22 @@ package com.ruoyi.web.controller.api; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.exception.ServiceException; +import com.ruoyi.system.dto.update.DataIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.FormalIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.RiskLevelUpdDTO; +import com.ruoyi.system.query.DataScreenConfigQuery; +import com.ruoyi.system.service.TbDataScreenConfigService; +import com.ruoyi.system.vo.DataScreenConfigVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -12,9 +28,82 @@ * @author mitao * @since 2024-03-13 */ +@Slf4j @RestController -@RequestMapping("/tb-data-screen-config") +@RequestMapping("/data-screen-config") +@RequiredArgsConstructor +@Api(tags = {"大屏数据配置相关接口"}) public class TbDataScreenConfigController { + private final TbDataScreenConfigService tbDataScreenConfigService; + + @PostMapping("/get-risk-level") + @ApiOperation("获取风险等级设置") + public R<DataScreenConfigVO> getRiskLevel() { + try { + return R.ok(tbDataScreenConfigService.getRiskLevel()); + } catch (Exception e) { + if (e instanceof ServiceException) { + return R.fail(e.getMessage()); + } + throw new RuntimeException(e); + } + } + + @PostMapping("/edit-risk-level") + @ApiOperation("编辑风险等级设置") + public R<DataScreenConfigVO> editRiskLevel( + @Validated @RequestBody RiskLevelUpdDTO dto) { + try { + return R.ok(tbDataScreenConfigService.editRiskLevel(dto)); + } catch (Exception e) { + if (e instanceof ServiceException) { + return R.fail(e.getMessage()); + } + throw new RuntimeException(e); + } + } + + @PostMapping("/get-indicators") + @ApiOperation("获取数据指标/形式指标级配置") + public R<List<DataScreenConfigVO>> getIndicatorsConfig( + @Validated @RequestBody DataScreenConfigQuery query) { + try { + return R.ok(tbDataScreenConfigService.getIndicatorsConfig(query)); + } catch (Exception e) { + if (e instanceof ServiceException) { + return R.fail(e.getMessage()); + } + throw new RuntimeException(e); + } + } + + @PostMapping("/edit-data-indicators") + @ApiOperation("编辑数据指标标级配置") + public R<DataScreenConfigVO> editDataIndicatorsConfig( + @Validated @RequestBody DataIndicatorsUpdDTO dto) { + try { + return R.ok(tbDataScreenConfigService.editDataIndicatorsConfig(dto)); + } catch (Exception e) { + if (e instanceof ServiceException) { + return R.fail(e.getMessage()); + } + throw new RuntimeException(e); + } + } + + @PostMapping("/edit-formal-indicators") + @ApiOperation("编辑形式指标标级配置") + public R<DataScreenConfigVO> editFormalIndicatorsConfig( + @Validated @RequestBody FormalIndicatorsUpdDTO dto) { + try { + return R.ok(tbDataScreenConfigService.editFormalIndicatorsConfig(dto)); + } catch (Exception e) { + if (e instanceof ServiceException) { + return R.fail(e.getMessage()); + } + throw new RuntimeException(e); + } + } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java index 3f91354..5e0b8cd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TaskUtil.java @@ -1,17 +1,12 @@ package com.ruoyi.web.controller.tool; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.redis.RedisCache; -import com.ruoyi.system.service.*; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.time.Instant; -import java.util.*; /** @@ -37,11 +32,12 @@ } } + /** * 每隔一分钟去处理的定时任务 */ @Scheduled(fixedRate = 1000 * 60) - public void taskMinute(){ + public void taskMinute() { try { // List<Message> list = messageService.list(); // Map<Integer,List<Message>> map = new LinkedHashMap<>(); @@ -78,27 +74,15 @@ * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 0 * * *") - public void taskDay(){ - - List<SysRole> sysRoles = roleService.selectListByDelFlag(2); - if(CollectionUtils.isEmpty(sysRoles)){ - return; - } - for (SysRole sysRole : sysRoles) { - if(sysRole.getRemoveDays()>0){ - sysRole.setRemoveDays(sysRole.getRemoveDays()-1); - roleService.updateRole(sysRole); - }else { - roleService.deleteRoleById(sysRole.getRoleId()); - } - } + public void taskDay() { } + /** * 每天的凌晨执行的任务 */ @Scheduled(cron = "0 0 1 * * ? ") - public void taskDayOne(){ + public void taskDayOne() { } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java index 72abc75..566d017 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java @@ -1,238 +1,217 @@ package com.ruoyi.common.core.domain.entity; import com.ruoyi.common.core.domain.BaseModel; +import java.util.Set; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import java.util.Set; - /** * 角色表 sys_role - * + * * @author ruoyi */ @Data -public class SysRole extends BaseModel -{ +public class SysRole extends BaseModel { + private static final long serialVersionUID = 1L; - /** 角色ID */ + /** + * 角色ID + */ //@Excel(name = "角色序号", cellType = ColumnType.NUMERIC) private Long roleId; - /** 角色名称 */ + /** + * 角色名称 + */ //@Excel(name = "角色名称") private String roleName; - /** 角色权限 */ + /** + * 角色权限 + */ //@Excel(name = "角色权限") private String roleKey; - /** 角色排序 */ + /** + * 角色排序 + */ //@Excel(name = "角色排序") private Integer roleSort; - /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ + /** + * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) + */ //@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") private String dataScope; - /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ + /** + * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) + */ private boolean menuCheckStrictly; - /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ + /** + * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) + */ private boolean deptCheckStrictly; - /** 角色状态(0正常 1停用) */ + /** + * 角色状态(0正常 1停用) + */ //@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") private Integer status; - /** 删除标志(0代表存在 2代表删除) */ + /** + * 删除标志(0代表存在 2代表删除) + */ private Integer delFlag; - /** 用户是否存在此角色标识 默认不存在 */ + /** + * 用户是否存在此角色标识 默认不存在 + */ private boolean flag = false; - /** 菜单组 */ + /** + * 菜单组 + */ private Long[] menuIds; - /** 部门组(数据权限) */ + /** + * 部门组(数据权限) + */ private Long[] deptIds; - /** 角色菜单权限 */ + /** + * 角色菜单权限 + */ private Set<String> permissions; private String remark; - /** - * 删除天数 - */ - private Integer removeDays; - /** - * 岗位类型 1=经理 2=负责人 3=专员 - */ - private Integer postType; - public Integer getPostType() { - return postType; - } - - public void setPostType(Integer postType) { - this.postType = postType; - } - - public SysRole() - { + public SysRole() { } - public SysRole(Long roleId) - { + public SysRole(Long roleId) { this.roleId = roleId; } - public Long getRoleId() - { + public Long getRoleId() { return roleId; } - public void setRoleId(Long roleId) - { + public void setRoleId(Long roleId) { this.roleId = roleId; } - public boolean isAdmin() - { + public boolean isAdmin() { return isAdmin(this.roleId); } - public static boolean isAdmin(Long roleId) - { + public static boolean isAdmin(Long roleId) { return roleId != null && 1L == roleId; } @NotBlank(message = "角色名称不能为空") @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符") - public String getRoleName() - { + public String getRoleName() { return roleName; } - public void setRoleName(String roleName) - { + public void setRoleName(String roleName) { this.roleName = roleName; } @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符") - public String getRoleKey() - { + public String getRoleKey() { return roleKey; } - public void setRoleKey(String roleKey) - { + public void setRoleKey(String roleKey) { this.roleKey = roleKey; } - public Integer getRoleSort() - { + public Integer getRoleSort() { return roleSort; } - public void setRoleSort(Integer roleSort) - { + public void setRoleSort(Integer roleSort) { this.roleSort = roleSort; } - public String getDataScope() - { + public String getDataScope() { return dataScope; } - public void setDataScope(String dataScope) - { + public void setDataScope(String dataScope) { this.dataScope = dataScope; } - public boolean isMenuCheckStrictly() - { + public boolean isMenuCheckStrictly() { return menuCheckStrictly; } - public void setMenuCheckStrictly(boolean menuCheckStrictly) - { + public void setMenuCheckStrictly(boolean menuCheckStrictly) { this.menuCheckStrictly = menuCheckStrictly; } - public boolean isDeptCheckStrictly() - { + public boolean isDeptCheckStrictly() { return deptCheckStrictly; } - public void setDeptCheckStrictly(boolean deptCheckStrictly) - { + public void setDeptCheckStrictly(boolean deptCheckStrictly) { this.deptCheckStrictly = deptCheckStrictly; } - public Integer getStatus() - { + public Integer getStatus() { return status; } - public void setStatus(Integer status) - { + public void setStatus(Integer status) { this.status = status; } - public Integer getDelFlag() - { + public Integer getDelFlag() { return delFlag; } - public void setDelFlag(Integer delFlag) - { + public void setDelFlag(Integer delFlag) { this.delFlag = delFlag; } - public boolean isFlag() - { + public boolean isFlag() { return flag; } - public void setFlag(boolean flag) - { + public void setFlag(boolean flag) { this.flag = flag; } - public Long[] getMenuIds() - { + public Long[] getMenuIds() { return menuIds; } - public void setMenuIds(Long[] menuIds) - { + public void setMenuIds(Long[] menuIds) { this.menuIds = menuIds; } - public Long[] getDeptIds() - { + public Long[] getDeptIds() { return deptIds; } - public void setDeptIds(Long[] deptIds) - { + public void setDeptIds(Long[] deptIds) { this.deptIds = deptIds; } - public Set<String> getPermissions() - { + public Set<String> getPermissions() { return permissions; } - public void setPermissions(Set<String> permissions) - { + public void setPermissions(Set<String> permissions) { this.permissions = permissions; } @@ -244,30 +223,22 @@ this.remark = remark; } - public Integer getRemoveDays() { - return removeDays; - } - - public void setRemoveDays(Integer removeDays) { - this.removeDays = removeDays; - } - @Override public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("roleId", getRoleId()) - .append("roleName", getRoleName()) - .append("roleKey", getRoleKey()) - .append("roleSort", getRoleSort()) - .append("dataScope", getDataScope()) - .append("menuCheckStrictly", isMenuCheckStrictly()) - .append("deptCheckStrictly", isDeptCheckStrictly()) - .append("status", getStatus()) - .append("delFlag", getDelFlag()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .toString(); + return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) + .append("roleId", getRoleId()) + .append("roleName", getRoleName()) + .append("roleKey", getRoleKey()) + .append("roleSort", getRoleSort()) + .append("dataScope", getDataScope()) + .append("menuCheckStrictly", isMenuCheckStrictly()) + .append("deptCheckStrictly", isDeptCheckStrictly()) + .append("status", getStatus()) + .append("delFlag", getDelFlag()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .toString(); } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScreenConfigEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScreenConfigEnum.java new file mode 100644 index 0000000..7e1c3d8 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataScreenConfigEnum.java @@ -0,0 +1,27 @@ +package com.ruoyi.common.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum DataScreenConfigEnum { + RISK_LEVEL(1, "风险等级设置"), + DATA_INDICATORS(2, "数据指标设置"), + FORMAL_INDICATORS(3, "形式指标设置"); + @EnumValue + private final Integer code; + @JsonValue + private final String desc; + + public static DataScreenConfigEnum getEnumByCode(Integer code) { + for (DataScreenConfigEnum e : DataScreenConfigEnum.values()) { + if (e.code.equals(code)) { + return e; + } + } + return null; + } +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/enums/SubTypeEnum.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/SubTypeEnum.java new file mode 100644 index 0000000..18278a9 --- /dev/null +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/SubTypeEnum.java @@ -0,0 +1,28 @@ +package com.ruoyi.common.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum SubTypeEnum { + INDICATOR_ONE(1, "指标一"), + INDICATOR_TWO(2, "指标二"), + INDICATOR_THREE(3, "指标三"), + INDICATOR_FOUR(4, "指标四"); + @EnumValue + private final Integer code; + @JsonValue + private final String desc; + + public static SubTypeEnum getEnumByCode(Integer code) { + for (SubTypeEnum e : SubTypeEnum.values()) { + if (e.code.equals(code)) { + return e; + } + } + return null; + } +} \ No newline at end of file diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java index bee7671..04099af 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java @@ -1,16 +1,21 @@ package com.ruoyi.common.utils; -import org.apache.commons.lang3.time.DateFormatUtils; - +import cn.hutool.core.convert.NumberChineseFormatter; import java.lang.management.ManagementFactory; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.time.*; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Map; +import org.apache.commons.lang3.time.DateFormatUtils; /** * 时间工具类 @@ -18,6 +23,7 @@ * @author ruoyi */ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { + public static String YYYY = "yyyy"; public static String YYYY_MM = "yyyy-MM"; @@ -331,6 +337,18 @@ } /** + * Date转为LocalDateTime + * + * @param date 日期 + * @return LocalDateTime + */ + public static LocalDate dateToLocalDate(Date date) { + Instant instant = date.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + return instant.atZone(zoneId).toLocalDate(); + } + + /** * localdate转为字符串 * * @param time localdate @@ -354,16 +372,52 @@ /** * 获取当前季度字符串 * - * @return - * @throws Exception + * @return 当前季度字符串 + * @throws Exception 异常 */ public static String getNowQuarter() throws Exception { //当前所在季度 Date date = new Date(); - int quarterOfYear = getQuarterOfYear(date); - String quarterOfYearStr = null; - quarterOfYearStr = NumberDisplaceChineseUtil.numberToChinese(quarterOfYear); + char quarterOfYear = String.valueOf(getQuarterOfYear(date)).toCharArray()[0]; + String quarterOfYearStr = NumberChineseFormatter.numberCharToChinese(quarterOfYear, false); LocalDate now = LocalDate.now(); return String.format("%s年%s季度", now.getYear(), quarterOfYearStr); } + + public static Date getQuarterDate(String quarter) { + // 提取年份和季度信息 + int year = Integer.parseInt(quarter.substring(0, 4)); + int quarterNumber = NumberChineseFormatter.chineseToNumber(quarter.substring(5, 6)); // 季度数字 + // 计算季度初的日期 + LocalDate startDate; + switch (quarterNumber) { + case 1: + startDate = LocalDate.of(year, 1, 1); + break; + case 2: + startDate = LocalDate.of(year, 4, 1); + break; + case 3: + startDate = LocalDate.of(year, 7, 1); + break; + case 4: + startDate = LocalDate.of(year, 10, 1); + break; + default: + throw new IllegalArgumentException("Invalid quarter number: " + quarterNumber); + } + return DateUtils.toDate(startDate); + } + + //测试 getNowQuarter + public static void main(String[] args) throws Exception { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String nowQuarter = getNowQuarter(); + System.out.println(nowQuarter); + System.out.println(NumberChineseFormatter.chineseToNumber("一")); + System.out.println(simpleDateFormat.format(getQuarterDate("2024年一季度"))); + System.out.println(simpleDateFormat.format(getQuarterDate("2024年二季度"))); + System.out.println(simpleDateFormat.format(getQuarterDate("2024年三季度"))); + System.out.println(simpleDateFormat.format(getQuarterDate("2024年四季度"))); + } } diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/NumberDisplaceChineseUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/NumberDisplaceChineseUtil.java deleted file mode 100644 index 8bd9405..0000000 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/NumberDisplaceChineseUtil.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.ruoyi.common.utils; - -public class NumberDisplaceChineseUtil { - - final static String[] unitArray= {"","十","百","千","万","十","百","千","亿","十","百","千","万"}; - final static String[] numArray = {"零","一","二","三","四","五","六","七","八","九"}; - - public static String numberToChinese(Integer number) throws Exception{ - if (number == null) { - return ""; - } - if (number == 0) { - return "零"; - } - char[] charArray= String.valueOf(number).toCharArray(); - int arrayLength = charArray.length; - StringBuilder stringBuilder = new StringBuilder(); - - for(int i = 0; i<arrayLength; i++){ - int num = Integer.valueOf(charArray[i] + ""); - boolean isZero = num == 0; - String unit = unitArray[(arrayLength - 1) - i]; - if (isZero) { - continue; - }else { - if(i==0){ - stringBuilder.append(numArray[num]); - stringBuilder.append(unit); - }else{ - if(charArray[i-1]=='0'){ - stringBuilder.append("零"); - stringBuilder.append(numArray[num]); - stringBuilder.append(unit); - }else{ - stringBuilder.append(numArray[num]); - stringBuilder.append(unit); - } - } - } - } - String numString = stringBuilder.toString(); - if(numString.length() > 1){ - if(numString.toCharArray()[0]== '一' && numString.toCharArray()[1] == '十'){ - return numString.substring(1); - } - } - return numString; - } - - public static void main(String[] args) throws Exception { - String s = numberToChinese(1234567890); - System.out.println(s); - } -} \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicData.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicData.java index 1796921..d9f9566 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicData.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicData.java @@ -79,5 +79,7 @@ @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private Date updateTime; - + @ApiModelProperty(value = "上报时间") + @TableField(value = "reporting_time") + private Date reportingTime; } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicDataConfigDetail.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicDataConfigDetail.java index 46215f6..3984628 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicDataConfigDetail.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbBasicDataConfigDetail.java @@ -6,10 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; import lombok.Data; import lombok.EqualsAndHashCode; - -import java.io.Serializable; /** * <p> @@ -22,7 +21,7 @@ @Data @EqualsAndHashCode(callSuper = false) @TableName("tb_basic_data_config_detail") -@ApiModel(value="TbBasicDataConfigDetail对象", description="基础数据配置详情表(存储文本和百分比的配置)") +@ApiModel(value = "TbBasicDataConfigDetail对象", description = "基础数据配置详情表(存储文本和百分比的配置)") public class TbBasicDataConfigDetail implements Serializable { private static final long serialVersionUID = 1L; @@ -36,11 +35,11 @@ private Long basicDataConfigId; @ApiModelProperty(value = "键") - @TableField("key") + @TableField("`key`") private String key; @ApiModelProperty(value = "值") - @TableField("value") + @TableField("`value`") private String value; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbDataScreenConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbDataScreenConfig.java index cd4e1ca..976068a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbDataScreenConfig.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/TbDataScreenConfig.java @@ -1,13 +1,18 @@ package com.ruoyi.system.domain; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; +import com.baomidou.mybatisplus.annotation.TableName; +import com.ruoyi.common.enums.DataScreenConfigEnum; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; - import java.io.Serializable; import java.util.Date; +import lombok.Data; +import lombok.EqualsAndHashCode; /** * <p> @@ -20,7 +25,7 @@ @Data @EqualsAndHashCode(callSuper = false) @TableName("tb_data_screen_config") -@ApiModel(value="TbDataScreenConfig对象", description="大屏数据配置表") +@ApiModel(value = "TbDataScreenConfig对象", description = "大屏数据配置表") public class TbDataScreenConfig implements Serializable { private static final long serialVersionUID = 1L; @@ -31,16 +36,36 @@ @ApiModelProperty(value = "配置类型(1=风险等级设置 2=数据指标设置 3=形式指标设置)") @TableField("type") - private Boolean type; + private DataScreenConfigEnum type; - @ApiModelProperty(value = "得分计算规则(多个规则使用','隔开)") + @ApiModelProperty(value = "得分计算规则") @TableField("calculate_formula") private String calculateFormula; + + @ApiModelProperty(value = "得分率计算规则") + @TableField("calculate_rate_formula") + private String calculateRateFormula; @ApiModelProperty(value = "配置类型子类型(1=数据指标一/形式指标一 2=数据指标二/形式指标二 3=数据指标三/形式指标三 4=数据指标四/形式指标四)") @TableField("sub_type") private Integer subType; + @ApiModelProperty(value = "风险等级范围-高风险得分") + @TableField("high_risk") + private String highRisk; + + @ApiModelProperty(value = "风险等级范围-低风险得分") + @TableField("medium_risk") + private String mediumRisk; + + @ApiModelProperty(value = "风险等级范围-无风险得分") + @TableField("low_risk") + private String lowRisk; + + @ApiModelProperty(value = "得分计算规则(多个规则使用','隔开)") + @TableField("no_risk") + private String noRisk; + @ApiModelProperty(value = "删除标志(0代表存在 1代表删除)") @TableField("del_flag") @TableLogic diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/DataIndicatorsUpdDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/DataIndicatorsUpdDTO.java new file mode 100644 index 0000000..715fed3 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/DataIndicatorsUpdDTO.java @@ -0,0 +1,35 @@ +package com.ruoyi.system.dto.update; + +import com.ruoyi.common.enums.SubTypeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import javax.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author mitao + * @date 2024/4/10 + */ +@Data +@ApiModel(value = "风险等级设置编辑数据传输对象") +public class DataIndicatorsUpdDTO implements Serializable { + + private static final long serialVersionUID = -5866223907037261823L; + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "配置类型子类型(1=指标一 2=指标二 3=指标三 4=指标四)") + @NotNull(message = "配置类型子类型不能为空") + private SubTypeEnum subType; + + @ApiModelProperty(value = "得分计算规则") + @NotNull(message = "得分计算规则不能为空") + private String calculateFormula; + + @ApiModelProperty(value = "得分率计算规则") + @NotNull(message = "得分率计算规则不能为空") + private String calculateRateFormula; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/FormalIndicatorsUpdDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/FormalIndicatorsUpdDTO.java new file mode 100644 index 0000000..5b25393 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/FormalIndicatorsUpdDTO.java @@ -0,0 +1,28 @@ +package com.ruoyi.system.dto.update; + +import com.ruoyi.common.enums.SubTypeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import lombok.Data; + +/** + * @author mitao + * @date 2024/4/10 + */ +@Data +@ApiModel(value = "风险等级设置编辑数据传输对象") +public class FormalIndicatorsUpdDTO implements Serializable { + + private static final long serialVersionUID = -4878457973955230627L; + + @ApiModelProperty(value = "id") + private Long id; + + @ApiModelProperty(value = "配置类型子类型(1=指标一 2=指标二 3=指标三 4=指标四)") + private SubTypeEnum subType; + + @ApiModelProperty(value = "得分计算规则") + private String calculateFormula; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/QuestionUpdDto.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/QuestionUpdDTO.java similarity index 88% rename from ruoyi-system/src/main/java/com/ruoyi/system/dto/QuestionUpdDto.java rename to ruoyi-system/src/main/java/com/ruoyi/system/dto/update/QuestionUpdDTO.java index d22eedd..c141ca4 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/QuestionUpdDto.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/QuestionUpdDTO.java @@ -1,12 +1,11 @@ -package com.ruoyi.system.dto; +package com.ruoyi.system.dto.update; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - +import java.io.Serializable; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.io.Serializable; +import lombok.Data; /** * @author mitao @@ -14,7 +13,8 @@ */ @Data @ApiModel(value = "发现问题编辑数据传输对象") -public class QuestionUpdDto implements Serializable { +public class QuestionUpdDTO implements Serializable { + private static final long serialVersionUID = 6382858207794071957L; @ApiModelProperty(value = "id") @NotNull(message = "id不能为空") diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/RiskLevelUpdDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/RiskLevelUpdDTO.java new file mode 100644 index 0000000..0553e4d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/update/RiskLevelUpdDTO.java @@ -0,0 +1,41 @@ +package com.ruoyi.system.dto.update; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import javax.validation.constraints.NotBlank; +import lombok.Data; + +/** + * @author mitao + * @date 2024/4/10 + */ +@Data +@ApiModel(value = "风险等级设置编辑数据传输对象") +public class RiskLevelUpdDTO implements Serializable { + + private static final long serialVersionUID = -4878457973955230627L; + + @ApiModelProperty(value = "id", notes = "如果返回了id,必传") + private Long id; + + @ApiModelProperty(value = "计算规则", notes = "公式中字段的格式为:field_字段id,e.g:field_1,field_2等。") + @NotBlank(message = "计算规则不能为空") + private String calculateFormula; + + @ApiModelProperty(value = "风险等级范围-高风险得分") + @NotBlank(message = "风险等级范围-高风险得分不能为空") + private String highRisk; + + @ApiModelProperty(value = "风险等级范围-中风险得分") + @NotBlank(message = "风险等级范围-中风险得分不能为空") + private String mediumRisk; + + @ApiModelProperty(value = "风险等级范围-低风险得分") + @NotBlank(message = "风险等级范围-低风险得分不能为空") + private String lowRisk; + + @ApiModelProperty(value = "风险等级范围-无风险得分") + @NotBlank(message = "风险等级范围-无风险得分不能为空") + private String noRisk; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/handler/CustomerHandler.java b/ruoyi-system/src/main/java/com/ruoyi/system/handler/CustomerHandler.java index 6f8b0dd..d063791 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/handler/CustomerHandler.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/handler/CustomerHandler.java @@ -7,11 +7,10 @@ import com.alibaba.excel.write.metadata.holder.WriteSheetHolder; import com.alibaba.excel.write.style.column.AbstractColumnWidthStyleStrategy; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; -import org.apache.poi.ss.usermodel.Cell; - import java.util.HashMap; import java.util.List; import java.util.Map; +import org.apache.poi.ss.usermodel.Cell; public class CustomerHandler extends AbstractColumnWidthStyleStrategy { @@ -24,10 +23,13 @@ } @Override - protected void setColumnWidth(WriteSheetHolder writeSheetHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) { + protected void setColumnWidth(WriteSheetHolder writeSheetHolder, + List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, + Boolean isHead) { boolean needSetWidth = isHead || !CollectionUtils.isEmpty(cellDataList); if (needSetWidth) { - Map<Integer, Integer> maxColumnWidthMap = (Map) CACHE.get(writeSheetHolder.getSheetNo()); + Map<Integer, Integer> maxColumnWidthMap = (Map) CACHE.get( + writeSheetHolder.getSheetNo()); if (maxColumnWidthMap == null) { maxColumnWidthMap = new HashMap(16); CACHE.put(writeSheetHolder.getSheetNo(), maxColumnWidthMap); @@ -43,10 +45,12 @@ } } - Integer maxColumnWidth = (Integer) ((Map) maxColumnWidthMap).get(cell.getColumnIndex()); + Integer maxColumnWidth = (Integer) ((Map) maxColumnWidthMap).get( + cell.getColumnIndex()); if (maxColumnWidth == null || columnWidth > maxColumnWidth) { ((Map) maxColumnWidthMap).put(cell.getColumnIndex(), columnWidth); - writeSheetHolder.getSheet().setColumnWidth(cell.getColumnIndex(), columnWidth * 256); + writeSheetHolder.getSheet() + .setColumnWidth(cell.getColumnIndex(), columnWidth * 256); } } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/listener/BasicDataListener.java b/ruoyi-system/src/main/java/com/ruoyi/system/listener/BasicDataListener.java index ffc2ece..b23a913 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/listener/BasicDataListener.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/listener/BasicDataListener.java @@ -163,8 +163,9 @@ } LocalDate now = LocalDate.now(); TbBasicData tbBasicData; + String quarter = String.format("%s年%s", now.getYear(), dataMap.get(1)); Optional<TbBasicData> tbBasicDataOpt = tbBasicDataService.lambdaQuery(). - eq(TbBasicData::getQuarter, String.format("%s年%s", now.getYear(), dataMap.get(1))) + eq(TbBasicData::getQuarter, quarter) .eq(TbBasicData::getDeptAreaCode, areaCode).oneOpt(); tbBasicData = tbBasicDataOpt.orElseGet(TbBasicData::new); tbBasicData.setQuarter(DateUtils.getNowQuarter()); @@ -173,6 +174,7 @@ tbBasicData.setDeptAreaCode(areaCode); tbBasicData.setRemark(dataMap.get(remarkIndex)); tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); + tbBasicData.setReportingTime(DateUtils.getQuarterDate(quarter)); tbBasicDataService.saveOrUpdate(tbBasicData); tbBasicDataFieldService.remove(Wrappers.<TbBasicDataField>lambdaQuery() .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId())); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/listener/HistoryDataListener.java b/ruoyi-system/src/main/java/com/ruoyi/system/listener/HistoryDataListener.java index f084ed3..4a4ed90 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/listener/HistoryDataListener.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/listener/HistoryDataListener.java @@ -18,6 +18,7 @@ import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.CalculateUtil; import com.ruoyi.common.utils.CollUtils; +import com.ruoyi.common.utils.DateUtils; import com.ruoyi.system.domain.TbBasicData; import com.ruoyi.system.domain.TbBasicDataConfig; import com.ruoyi.system.domain.TbBasicDataConfigDetail; @@ -73,42 +74,6 @@ this.tbScoreService = tbScoreService; this.sysUserService = sysUserService; this.quarter = quarter; - } - - 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; } @Override @@ -190,6 +155,7 @@ tbBasicData.setDeptAreaCode(areaCode); tbBasicData.setRemark(dataMap.get(remarkIndex)); tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); + tbBasicData.setReportingTime(DateUtils.getQuarterDate(quarter)); tbBasicDataService.saveOrUpdate(tbBasicData); tbBasicDataFieldService.remove(Wrappers.<TbBasicDataField>lambdaQuery() .eq(TbBasicDataField::getBasicDataId, tbBasicData.getId())); @@ -233,6 +199,11 @@ return tbBasicDataList; } + /** + * 需要导入的数据 + * + * @return List<Map < Integer, String>> + */ private List<Map<Integer, String>> getMapList() { for (int i = 0; i < cachedDataList.size(); i++) { if (cachedDataList.get(i).get(0).equals("栏号")) { @@ -242,6 +213,11 @@ return null; } + /** + * 表头 + * + * @return Map<Integer, String> + */ private Map<Integer, String> getHeadMap() { for (int i = 0; i < cachedDataList.size(); i++) { if (cachedDataList.get(i).get(0).equals("栏号")) { @@ -251,9 +227,58 @@ return null; } + /** + * 校验字段内容 + * + * @param integerStringEntry 动态字段表头Entry + * @param dataMap 数据map + * @param field 字段 + * @return 值 + */ + 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; + } + + /** + * 计算得分 + * + * @param tbBasicDataList 基础数据集合 + */ private void calculateScore(List<TbBasicData> tbBasicDataList) { + List<TbScore> scoreList = new ArrayList<>(); for (TbBasicData tbBasicData : tbBasicDataList) { - List<TbScore> scoreList = new ArrayList<>(); //计算得分 List<TbBasicDataConfig> list = tbBasicDataConfigService.lambdaQuery() .eq(TbBasicDataConfig::getStatus, ShowStatusEnum.SHOW).list(); @@ -337,7 +362,8 @@ } } } - tbScoreService.saveBatch(scoreList); } + tbScoreService.saveBatch(scoreList); + log.info(String.format("基础数据%s计算得分成功!", JSON.toJSONString(tbBasicDataList))); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/query/DataScreenConfigQuery.java b/ruoyi-system/src/main/java/com/ruoyi/system/query/DataScreenConfigQuery.java new file mode 100644 index 0000000..d5eddab --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/query/DataScreenConfigQuery.java @@ -0,0 +1,24 @@ +package com.ruoyi.system.query; + +import com.ruoyi.common.enums.DataScreenConfigEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import javax.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author mitao + * @date 2024/4/10 + */ +@Data +@ApiModel(value = "数据大屏配置查询数据传输对象") +public class DataScreenConfigQuery implements Serializable { + + private static final long serialVersionUID = -1097028325191820663L; + + @ApiModelProperty(value = "配置类型(2=数据指标设置 3=形式指标设置)") + @NotNull(message = "配置类型不能为空") + private DataScreenConfigEnum type; + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbBasicDataService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbBasicDataService.java index fc350b1..d097254 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbBasicDataService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbBasicDataService.java @@ -28,7 +28,7 @@ R<BasicDataReportingVO> getBasicFields() throws Exception; - void saveBasicData(BasicDataDTO dto); + void saveBasicData(BasicDataDTO dto) throws Exception; void importBasicData(MultipartFile file) throws Exception; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbDataScreenConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbDataScreenConfigService.java index 248891d..0d22795 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbDataScreenConfigService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbDataScreenConfigService.java @@ -2,6 +2,12 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.system.domain.TbDataScreenConfig; +import com.ruoyi.system.dto.update.DataIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.FormalIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.RiskLevelUpdDTO; +import com.ruoyi.system.query.DataScreenConfigQuery; +import com.ruoyi.system.vo.DataScreenConfigVO; +import java.util.List; /** * <p> @@ -13,4 +19,13 @@ */ public interface TbDataScreenConfigService extends IService<TbDataScreenConfig> { + DataScreenConfigVO getRiskLevel(); + + DataScreenConfigVO editRiskLevel(RiskLevelUpdDTO dto); + + List<DataScreenConfigVO> getIndicatorsConfig(DataScreenConfigQuery query); + + DataScreenConfigVO editDataIndicatorsConfig(DataIndicatorsUpdDTO dto); + + DataScreenConfigVO editFormalIndicatorsConfig(FormalIndicatorsUpdDTO dto); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbQuestionService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbQuestionService.java index 1c90d7d..fe03808 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/TbQuestionService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/TbQuestionService.java @@ -4,7 +4,7 @@ import com.ruoyi.common.basic.PageDTO; import com.ruoyi.system.domain.TbQuestion; import com.ruoyi.system.dto.QuestionDTO; -import com.ruoyi.system.dto.QuestionUpdDto; +import com.ruoyi.system.dto.update.QuestionUpdDTO; import com.ruoyi.system.query.QuestionQuery; import com.ruoyi.system.vo.QuestionVO; @@ -20,7 +20,7 @@ void addQuestion(QuestionDTO dto) throws Exception; - void editQuestion(QuestionUpdDto dto); + void editQuestion(QuestionUpdDTO dto); PageDTO<QuestionVO> pageQuestion(QuestionQuery dto); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 389db9f..f265a8a 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,17 +1,8 @@ package com.ruoyi.system.service.impl; -import java.util.*; -import java.util.stream.Collectors; - import com.ruoyi.common.basic.PageInfo; -import com.ruoyi.common.core.domain.entity.SysMenu; -import com.ruoyi.system.dto.SysRoleDTO; -import com.ruoyi.system.mapper.*; -import com.ruoyi.system.query.SysRoleQuery; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.ServiceException; @@ -21,16 +12,33 @@ import com.ruoyi.system.domain.SysRoleDept; import com.ruoyi.system.domain.SysRoleMenu; import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.dto.SysRoleDTO; +import com.ruoyi.system.mapper.SysMenuMapper; +import com.ruoyi.system.mapper.SysRoleDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.query.SysRoleQuery; import com.ruoyi.system.service.ISysRoleService; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * 角色 业务层处理 - * + * * @author ruoyi */ @Service -public class SysRoleServiceImpl implements ISysRoleService -{ +public class SysRoleServiceImpl implements ISysRoleService { + @Autowired private SysRoleMapper roleMapper; @@ -47,33 +55,28 @@ /** * 根据条件分页查询角色数据 - * + * * @param role 角色信息 * @return 角色数据集合信息 */ @Override - public List<SysRole> selectRoleList(SysRole role) - { + public List<SysRole> selectRoleList(SysRole role) { return roleMapper.selectRoleList(role); } /** * 根据用户ID查询角色 - * + * * @param userId 用户ID * @return 角色列表 */ @Override - public List<SysRole> selectRolesByUserId(Long userId) - { + public List<SysRole> selectRolesByUserId(Long userId) { List<SysRole> userRoles = roleMapper.selectRolePermissionByUserId(userId); List<SysRole> roles = selectRoleAll(); - for (SysRole role : roles) - { - for (SysRole userRole : userRoles) - { - if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) - { + for (SysRole role : roles) { + for (SysRole userRole : userRoles) { + if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) { role.setFlag(true); break; } @@ -84,19 +87,16 @@ /** * 根据用户ID查询权限 - * + * * @param userId 用户ID * @return 权限列表 */ @Override - public Set<String> selectRolePermissionByUserId(Long userId) - { + public Set<String> selectRolePermissionByUserId(Long userId) { List<SysRole> perms = roleMapper.selectRolePermissionByUserId(userId); Set<String> permsSet = new HashSet<>(); - for (SysRole perm : perms) - { - if (StringUtils.isNotNull(perm)) - { + for (SysRole perm : perms) { + if (StringUtils.isNotNull(perm)) { permsSet.addAll(Arrays.asList(perm.getRoleKey().trim().split(","))); } } @@ -105,52 +105,47 @@ /** * 查询所有角色 - * + * * @return 角色列表 */ @Override - public List<SysRole> selectRoleAll() - { + public List<SysRole> selectRoleAll() { return this.selectRoleList(new SysRole()); } /** * 根据用户ID获取角色选择框列表 - * + * * @param userId 用户ID * @return 选中角色ID列表 */ @Override - public List<Long> selectRoleListByUserId(Long userId) - { + public List<Long> selectRoleListByUserId(Long userId) { return roleMapper.selectRoleListByUserId(userId); } /** * 通过角色ID查询角色 - * + * * @param roleId 角色ID * @return 角色对象信息 */ @Override - public SysRole selectRoleById(Long roleId) - { + public SysRole selectRoleById(Long roleId) { return roleMapper.selectRoleById(roleId); } /** * 校验角色名称是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public boolean checkRoleNameUnique(SysRole role) - { + public boolean checkRoleNameUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleNameUnique(role.getRoleName()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -158,17 +153,15 @@ /** * 校验角色权限是否唯一 - * + * * @param role 角色信息 * @return 结果 */ @Override - public boolean checkRoleKeyUnique(SysRole role) - { + public boolean checkRoleKeyUnique(SysRole role) { Long roleId = StringUtils.isNull(role.getRoleId()) ? -1L : role.getRoleId(); SysRole info = roleMapper.checkRoleKeyUnique(role.getRoleKey()); - if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) - { + if (StringUtils.isNotNull(info) && info.getRoleId().longValue() != roleId.longValue()) { return UserConstants.NOT_UNIQUE; } return UserConstants.UNIQUE; @@ -176,33 +169,28 @@ /** * 校验角色是否允许操作 - * + * * @param role 角色信息 */ @Override - public void checkRoleAllowed(SysRole role) - { - if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) - { + public void checkRoleAllowed(SysRole role) { + if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin()) { throw new ServiceException("不允许操作超级管理员角色"); } } /** * 校验角色是否有数据权限 - * + * * @param roleId 角色id */ @Override - public void checkRoleDataScope(Long roleId) - { - if (!SysUser.isAdmin(SecurityUtils.getUserId())) - { + public void checkRoleDataScope(Long roleId) { + if (!SysUser.isAdmin(SecurityUtils.getUserId())) { SysRole role = new SysRole(); role.setRoleId(roleId); List<SysRole> roles = SpringUtils.getAopProxy(this).selectRoleList(role); - if (StringUtils.isEmpty(roles)) - { + if (StringUtils.isEmpty(roles)) { throw new ServiceException("没有权限访问角色数据!"); } } @@ -210,26 +198,24 @@ /** * 通过角色ID查询角色使用数量 - * + * * @param roleId 角色ID * @return 结果 */ @Override - public int countUserRoleByRoleId(Long roleId) - { + public int countUserRoleByRoleId(Long roleId) { return userRoleMapper.countUserRoleByRoleId(roleId); } /** * 新增保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int insertRole(SysRole role) - { + public int insertRole(SysRole role) { // 新增角色信息 roleMapper.insertRole(role); return insertRoleMenu(role); @@ -237,14 +223,13 @@ /** * 修改保存角色信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int updateRole(SysRole role) - { + public int updateRole(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与菜单关联 @@ -285,26 +270,24 @@ /** * 修改角色状态 - * + * * @param role 角色信息 * @return 结果 */ @Override - public int updateRoleStatus(SysRole role) - { + public int updateRoleStatus(SysRole role) { return roleMapper.updateRole(role); } /** * 修改数据权限信息 - * + * * @param role 角色信息 * @return 结果 */ @Override @Transactional - public int authDataScope(SysRole role) - { + public int authDataScope(SysRole role) { // 修改角色信息 roleMapper.updateRole(role); // 删除角色与部门关联 @@ -315,23 +298,20 @@ /** * 新增角色菜单信息 - * + * * @param role 角色对象 */ - public int insertRoleMenu(SysRole role) - { + public int insertRoleMenu(SysRole role) { int rows = 1; // 新增用户与角色管理 List<SysRoleMenu> list = new ArrayList<SysRoleMenu>(); - for (Long menuId : role.getMenuIds()) - { + for (Long menuId : role.getMenuIds()) { SysRoleMenu rm = new SysRoleMenu(); rm.setRoleId(role.getRoleId()); rm.setMenuId(menuId); list.add(rm); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleMenuMapper.batchRoleMenu(list); } return rows; @@ -342,20 +322,17 @@ * * @param role 角色对象 */ - public int insertRoleDept(SysRole role) - { + public int insertRoleDept(SysRole role) { int rows = 1; // 新增角色与部门(数据权限)管理 List<SysRoleDept> list = new ArrayList<SysRoleDept>(); - for (Long deptId : role.getDeptIds()) - { + for (Long deptId : role.getDeptIds()) { SysRoleDept rd = new SysRoleDept(); rd.setRoleId(role.getRoleId()); rd.setDeptId(deptId); list.add(rd); } - if (list.size() > 0) - { + if (list.size() > 0) { rows = roleDeptMapper.batchRoleDept(list); } return rows; @@ -363,14 +340,13 @@ /** * 通过角色ID删除角色 - * + * * @param roleId 角色ID * @return 结果 */ @Override @Transactional - public int deleteRoleById(Long roleId) - { + public int deleteRoleById(Long roleId) { // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(roleId); // 删除角色与部门关联 @@ -380,20 +356,18 @@ /** * 批量删除角色信息 - * + * * @param roleIds 需要删除的角色ID * @return 结果 */ @Override @Transactional - public int deleteRoleByIds(List<Long> roleIds) - { - for (Long roleId : roleIds) - { + public int deleteRoleByIds(List<Long> roleIds) { + for (Long roleId : roleIds) { SysRole role = selectRoleById(roleId); - if (countUserRoleByRoleId(roleId) > 0) - { - throw new ServiceException(String.format("%1$s已分配,不能删除", role.getRoleName())); + if (countUserRoleByRoleId(roleId) > 0) { + throw new ServiceException( + String.format("%1$s已分配,不能删除", role.getRoleName())); } } // 删除角色与菜单关联 @@ -403,43 +377,39 @@ /** * 取消授权用户角色 - * + * * @param userRole 用户和角色关联信息 * @return 结果 */ @Override - public int deleteAuthUser(SysUserRole userRole) - { + public int deleteAuthUser(SysUserRole userRole) { return userRoleMapper.deleteUserRoleInfo(userRole); } /** * 批量取消授权用户角色 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param userIds 需要取消授权的用户数据ID * @return 结果 */ @Override - public int deleteAuthUsers(Long roleId, Long[] userIds) - { + public int deleteAuthUsers(Long roleId, Long[] userIds) { return userRoleMapper.deleteUserRoleInfos(roleId, userIds); } /** * 批量选择授权用户角色 - * - * @param roleId 角色ID + * + * @param roleId 角色ID * @param userIds 需要授权的用户数据ID * @return 结果 */ @Override - public int insertAuthUsers(Long roleId, Long[] userIds) - { + public int insertAuthUsers(Long roleId, Long[] userIds) { // 新增用户与角色管理 List<SysUserRole> list = new ArrayList<SysUserRole>(); - for (Long userId : userIds) - { + for (Long userId : userIds) { SysUserRole ur = new SysUserRole(); ur.setUserId(userId); ur.setRoleId(roleId); @@ -517,18 +487,25 @@ //获取当前的权限菜单 List<SysMenu> all = menuMapper.getAllInIds(menusId); // 第三级 - List<SysMenu> s3 = all.stream().filter(e -> e.getMenuType().equals("F")).collect(Collectors.toList()); + List<SysMenu> s3 = all.stream().filter(e -> e.getMenuType().equals("F")) + .collect(Collectors.toList()); // 第二级 - List<SysMenu> s2 = all.stream().filter(e -> e.getMenuType().equals("C")).collect(Collectors.toList()); + List<SysMenu> s2 = all.stream().filter(e -> e.getMenuType().equals("C")) + .collect(Collectors.toList()); // 第一级 - List<SysMenu> s1 = all.stream().filter(e -> e.getMenuType().equals("M")).collect(Collectors.toList()); + List<SysMenu> s1 = all.stream().filter(e -> e.getMenuType().equals("M")) + .collect(Collectors.toList()); for (SysMenu menu : s2) { - List<SysMenu> collect = s3.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); + List<SysMenu> collect = s3.stream() + .filter(e -> e.getParentId().equals(menu.getMenuId())) + .collect(Collectors.toList()); menu.setChildren(collect); } for (SysMenu menu : s1) { - List<SysMenu> collect = s2.stream().filter(e -> e.getParentId().equals(menu.getMenuId())).collect(Collectors.toList()); + List<SysMenu> collect = s2.stream() + .filter(e -> e.getParentId().equals(menu.getMenuId())) + .collect(Collectors.toList()); menu.setChildren(collect); } return s1; @@ -539,7 +516,7 @@ SysRole sysRole = roleMapper.selectRoleByUserId(userId); // 获取当前角色的菜单列表 List<SysMenu> menus = menuMapper.selectListByRoleId(sysRole.getRoleId()); - if(menus.size()==0){ + if (menus.size() == 0) { return new ArrayList<>(); } List<Long> menusId = menus.stream().map(SysMenu::getMenuId).collect(Collectors.toList()); @@ -557,7 +534,6 @@ // 添加角色 SysRole sysRole = new SysRole(); sysRole.setRoleName(dto.getRoleName()); - sysRole.setPostType(dto.getPostType()); roleMapper.insertRole(sysRole); // 添加角色权限中间表 @@ -575,7 +551,7 @@ @Override public PageInfo<SysRole> selectList(SysRoleQuery query) { PageInfo<SysRole> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); - List<SysRole> list = roleMapper.selectList(query,pageInfo); + List<SysRole> list = roleMapper.selectList(query, pageInfo); pageInfo.setRecords(list); return pageInfo; } @@ -586,7 +562,6 @@ SysRole sysRole = new SysRole(); sysRole.setRoleId(dto.getRoleId()); sysRole.setRoleName(dto.getRoleName()); - sysRole.setPostType(dto.getPostType()); roleMapper.updateRole(sysRole); // 删除角色与菜单关联 roleMenuMapper.deleteRoleMenuByRoleId(dto.getRoleId()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataServiceImpl.java index 083b8fd..fd782cb 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbBasicDataServiceImpl.java @@ -32,7 +32,7 @@ import com.ruoyi.system.domain.TbField; import com.ruoyi.system.domain.TbScore; import com.ruoyi.system.dto.BasicDataDTO; -import com.ruoyi.system.handler.CustomerHandler; +import com.ruoyi.system.handler.CustomCellWriteHandler; import com.ruoyi.system.listener.BasicDataListener; import com.ruoyi.system.listener.HistoryDataListener; import com.ruoyi.system.mapper.TbBasicDataMapper; @@ -196,16 +196,19 @@ @Override @Transactional(rollbackFor = Exception.class) - public void saveBasicData(BasicDataDTO dto) { + public void saveBasicData(BasicDataDTO dto) throws Exception { LoginUser loginUser = SecurityUtils.getLoginUser(); String areaCode = loginUser.getUser().getAreaCode(); // 数据校验 if (Objects.isNull(dto) || CollUtils.isEmpty(dto.getFields())) { return; } + String nowQuarter = DateUtils.getNowQuarter(); TbBasicData tbBasicData = BeanUtils.copyBean(dto, TbBasicData.class); tbBasicData.setDeptAreaCode(areaCode); tbBasicData.setStatus(ReportingStatusEnum.MISSING_DATA); + tbBasicData.setQuarter(nowQuarter); + tbBasicData.setReportingTime(DateUtils.getQuarterDate(nowQuarter)); this.saveOrUpdate(tbBasicData); // 保存基础数据动态字段数据 List<TbBasicDataField> tbBasicDataFields = @@ -683,6 +686,16 @@ @Override @Transactional(rollbackFor = Exception.class) public void importData(MultipartFile file, String quarter) throws IOException { + //校验季度 + Date quarterDate = DateUtils.getQuarterDate(quarter); + + Map<String, Date> quarterMap = DateUtils.getQuarterDate(new Date()); + Date date = quarterMap.get("first"); + LocalDate quarterLocalDate = DateUtils.dateToLocalDate(quarterDate); + LocalDate dateLocalDate = DateUtils.dateToLocalDate(date); + if (quarterLocalDate.isAfter(dateLocalDate) || quarterLocalDate.equals(dateLocalDate)) { + throw new ServiceException("请导入过去季度的数据。"); + } EasyExcel.read( file.getInputStream(), new HistoryDataListener( @@ -730,7 +743,7 @@ .list(); //构建Excel写对象 try (ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()) - .registerWriteHandler(new CustomerHandler()) + .registerWriteHandler(new CustomCellWriteHandler()) .registerWriteHandler(EasyExcelUtil.getStyleStrategy()).build()) { WriteSheet writeSheet; //遍历季度基础数据 @@ -787,21 +800,18 @@ TbBasicDataField transferPaymentScale = basicDataFieldMap.get(-1L); valueList.add( Objects.nonNull(transferPaymentScale) - ? FieldBuildUtil.formatNumberWithCommas( - transferPaymentScale.getFieldValue()) + ? transferPaymentScale.getFieldValue() : ""); TbBasicDataField currentGdp = basicDataFieldMap.get(-2L); valueList.add( Objects.nonNull(currentGdp) - ? FieldBuildUtil.formatNumberWithCommas( - currentGdp.getFieldValue()) + ? currentGdp.getFieldValue() : ""); for (TbField tbField : fieldList) { TbBasicDataField tbBasicDataField = basicDataFieldMap.get(tbField.getId()); valueList.add( Objects.nonNull(tbBasicDataField) - ? FieldBuildUtil.formatNumberWithCommas( - tbBasicDataField.getFieldValue()) + ? tbBasicDataField.getFieldValue() : ""); } excellist.add(valueList); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java index 87624d8..8e3ee5c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbDataScreenConfigServiceImpl.java @@ -1,10 +1,19 @@ package com.ruoyi.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.common.enums.DataScreenConfigEnum; +import com.ruoyi.common.utils.BeanUtils; import com.ruoyi.system.domain.TbDataScreenConfig; +import com.ruoyi.system.dto.update.DataIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.FormalIndicatorsUpdDTO; +import com.ruoyi.system.dto.update.RiskLevelUpdDTO; import com.ruoyi.system.mapper.TbDataScreenConfigMapper; +import com.ruoyi.system.query.DataScreenConfigQuery; import com.ruoyi.system.service.TbDataScreenConfigService; +import com.ruoyi.system.vo.DataScreenConfigVO; +import java.util.List; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * <p> @@ -15,6 +24,52 @@ * @since 2024-03-13 */ @Service -public class TbDataScreenConfigServiceImpl extends ServiceImpl<TbDataScreenConfigMapper, TbDataScreenConfig> implements TbDataScreenConfigService { +public class TbDataScreenConfigServiceImpl extends + ServiceImpl<TbDataScreenConfigMapper, TbDataScreenConfig> implements + TbDataScreenConfigService { + @Override + public DataScreenConfigVO getRiskLevel() { + TbDataScreenConfig tbDataScreenConfig = this.lambdaQuery() + .eq(TbDataScreenConfig::getType, DataScreenConfigEnum.RISK_LEVEL) + .one(); + return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public DataScreenConfigVO editRiskLevel(RiskLevelUpdDTO dto) { + TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto, + TbDataScreenConfig.class); + tbDataScreenConfig.setType(DataScreenConfigEnum.RISK_LEVEL); + this.saveOrUpdate(tbDataScreenConfig); + return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class); + } + + @Override + public List<DataScreenConfigVO> getIndicatorsConfig(DataScreenConfigQuery query) { + List<TbDataScreenConfig> list = this.lambdaQuery() + .eq(TbDataScreenConfig::getType, query.getType()).list(); + return BeanUtils.copyList(list, DataScreenConfigVO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public DataScreenConfigVO editDataIndicatorsConfig(DataIndicatorsUpdDTO dto) { + TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto, + TbDataScreenConfig.class); + tbDataScreenConfig.setType(DataScreenConfigEnum.DATA_INDICATORS); + this.saveOrUpdate(tbDataScreenConfig); + return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public DataScreenConfigVO editFormalIndicatorsConfig(FormalIndicatorsUpdDTO dto) { + TbDataScreenConfig tbDataScreenConfig = BeanUtils.copyBean(dto, + TbDataScreenConfig.class); + tbDataScreenConfig.setType(DataScreenConfigEnum.FORMAL_INDICATORS); + this.saveOrUpdate(tbDataScreenConfig); + return BeanUtils.copyBean(tbDataScreenConfig, DataScreenConfigVO.class); + } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbQuestionServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbQuestionServiceImpl.java index 9110645..e469a3e 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbQuestionServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TbQuestionServiceImpl.java @@ -8,7 +8,7 @@ import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.TbQuestion; import com.ruoyi.system.dto.QuestionDTO; -import com.ruoyi.system.dto.QuestionUpdDto; +import com.ruoyi.system.dto.update.QuestionUpdDTO; import com.ruoyi.system.mapper.TbQuestionMapper; import com.ruoyi.system.query.QuestionQuery; import com.ruoyi.system.service.TbQuestionService; @@ -35,7 +35,7 @@ } @Override - public void editQuestion(QuestionUpdDto dto) { + public void editQuestion(QuestionUpdDTO dto) { TbQuestion tbQuestion = BeanUtils.copyBean(dto, TbQuestion.class); this.updateById(tbQuestion); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/DataScreenConfigVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/DataScreenConfigVO.java new file mode 100644 index 0000000..2fc30fa --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/DataScreenConfigVO.java @@ -0,0 +1,44 @@ +package com.ruoyi.system.vo; + +import com.ruoyi.common.enums.DataScreenConfigEnum; +import com.ruoyi.common.enums.SubTypeEnum; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author mitao + * @date 2024/4/10 + */ +@Data +@ApiModel(value = "大屏数据配置视图对象") +public class DataScreenConfigVO { + + @ApiModelProperty(value = "大屏数据配置id") + private Long id; + + @ApiModelProperty(value = "配置类型(1=风险等级设置 2=数据指标设置 3=形式指标设置)") + private DataScreenConfigEnum type; + + @ApiModelProperty(value = "得分计算规则") + private String calculateFormula; + + @ApiModelProperty(value = "得分率计算规则") + private String calculateRateFormula; + + @ApiModelProperty(value = "配置类型子类型(1=指标一 2=指标二 3=指标三 4=指标四)") + private SubTypeEnum subType; + + @ApiModelProperty(value = "风险等级范围-高风险得分") + private String highRisk; + + @ApiModelProperty(value = "风险等级范围-中风险得分") + private String mediumRisk; + + @ApiModelProperty(value = "风险等级范围-低风险得分") + private String lowRisk; + + @ApiModelProperty(value = "风险等级范围-无风险得分") + private String noRisk; + +} diff --git a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index fd75947..6ff08d0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -1,214 +1,249 @@ <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.SysRoleMapper"> - <resultMap type="SysRole" id="SysRoleResult"> - <id property="roleId" column="role_id" /> - <result property="roleName" column="role_name" /> - <result property="roleKey" column="role_key" /> - <result property="roleSort" column="role_sort" /> - <result property="dataScope" column="data_scope" /> - <result property="menuCheckStrictly" column="menu_check_strictly" /> - <result property="deptCheckStrictly" column="dept_check_strictly" /> - <result property="status" column="status" /> - <result property="delFlag" column="del_flag" /> - <result property="createBy" column="create_by" /> - <result property="createTime" column="create_time" /> - <result property="updateBy" column="update_by" /> - <result property="updateTime" column="update_time" /> - <result property="remark" column="remark" /> - <result property="removeDays" column="removeDays" /> - <result property="postType" column="postType" /> - </resultMap> - - <sql id="selectRoleVo"> - select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.menu_check_strictly, r.dept_check_strictly, - r.status, r.del_flag, r.create_time, r.remark,r.postType,r.removeDays - from sys_role r - left join sys_user_role ur on ur.role_id = r.role_id - left join sys_user u on u.user_id = ur.user_id - left join sys_dept d on u.dept_id = d.dept_id - </sql> - - <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - where r.del_flag = '0' - <if test="roleId != null and roleId != 0"> - AND r.role_id = #{roleId} - </if> - <if test="roleName != null and roleName != ''"> - AND r.role_name like concat('%', #{roleName}, '%') - </if> - <if test="status != null and status != ''"> - AND r.status = #{status} - </if> - <if test="roleKey != null and roleKey != ''"> - AND r.role_key like concat('%', #{roleKey}, '%') - </if> - order by r.role_sort - </select> - - <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - WHERE r.del_flag = '0' and ur.user_id = #{userId} - </select> - - <select id="selectRoleAll" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - </select> - - <select id="selectRoleListByUserId" parameterType="Long" resultType="Long"> - select r.role_id - from sys_role r - left join sys_user_role ur on ur.role_id = r.role_id - left join sys_user u on u.user_id = ur.user_id - where u.user_id = #{userId} - </select> - - <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - where r.role_id = #{roleId} - </select> - - <select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - WHERE r.del_flag = '0' and u.user_name = #{userName} - </select> - - <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - where r.role_name=#{roleName} and r.del_flag = '0' limit 1 - </select> - - <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult"> - <include refid="selectRoleVo"/> - where r.role_key=#{roleKey} and r.del_flag = '0' limit 1 - </select> - <select id="selectCountByRoleName" resultType="java.lang.Integer"> - select count(*) from sys_role - <where> - <if test="roleName != null and roleName != ''"> - AND role_name = #{roleName} - </if> - AND del_flag = 0 - </where> - </select> - <select id="selectList" resultType="com.ruoyi.common.core.domain.entity.SysRole"> - select role_id AS roleId, role_name AS roleName, role_key AS roleKey, role_sort AS roleSort, data_scope AS dataScope, - menu_check_strictly AS menuCheckStrictly, dept_check_strictly AS deptCheckStrictly,status AS status, del_flag AS delFlag, - create_time AS createTime,create_by AS createBy,postType AS postType,removeDays AS removeDays - from sys_role - <where> - <if test="query.roleName != null and query.roleName != ''"> - AND role_name LIKE concat('%',#{query.roleName},'%') - </if> - <if test="query.status != null"> - AND status = #{query.status} - </if> - AND del_flag = 0 - </where> - </select> - <select id="selectCount" resultType="java.lang.Integer"> - select count(*) from sys_role - <where> - <if test="status != null"> - AND status = #{status} - </if> - AND del_flag = 0 - </where> - </select> - <select id="selectListByDelFlag" resultType="com.ruoyi.common.core.domain.entity.SysRole"> - select role_id AS roleId, role_name AS roleName, role_key AS roleKey, role_sort AS roleSort, data_scope AS dataScope, - menu_check_strictly AS menuCheckStrictly, dept_check_strictly AS deptCheckStrictly,status AS status, del_flag AS delFlag, - create_time AS createTime,create_by AS createBy,postType AS postType,removeDays AS removeDays - from sys_role where del_flag = 0 - </select> + <resultMap type="SysRole" id="SysRoleResult"> + <id property="roleId" column="role_id"/> + <result property="roleName" column="role_name"/> + <result property="roleKey" column="role_key"/> + <result property="roleSort" column="role_sort"/> + <result property="dataScope" column="data_scope"/> + <result property="menuCheckStrictly" column="menu_check_strictly"/> + <result property="deptCheckStrictly" column="dept_check_strictly"/> + <result property="status" column="status"/> + <result property="delFlag" column="del_flag"/> + <result property="createBy" column="create_by"/> + <result property="createTime" column="create_time"/> + <result property="updateBy" column="update_by"/> + <result property="updateTime" column="update_time"/> + <result property="remark" column="remark"/> + <result property="removeDays" column="removeDays"/> + <result property="postType" column="postType"/> + </resultMap> - <select id="selectRoleByUserId" resultType="com.ruoyi.common.core.domain.entity.SysRole"> - select distinct 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.menu_check_strictly AS menuCheckStrictly, r.dept_check_strictly AS deptCheckStrictly,r.status AS status, - r.del_flag AS delFlag, r.create_time AS createTime,r.create_by AS createBy - from sys_role r - left join sys_user_role ur on ur.role_id = r.role_id - where ur.user_id = #{userId} - </select> - <select id="selectByUserId" resultType="java.lang.String"> - select t2.role_name from sys_user_role t1 - left join sys_role t2 on t1.role_id = t2.role_id - where t1.user_id = #{userId} - </select> + <sql id="selectRoleVo"> + select distinct r.role_id, + r.role_name, + r.role_key, + r.role_sort, + r.data_scope, + r.menu_check_strictly, + r.dept_check_strictly, + r.status, + r.del_flag, + r.create_time, + r.remark, + r.postType, + r.removeDays + from sys_role r + left join sys_user_role ur on ur.role_id = r.role_id + left join sys_user u on u.user_id = ur.user_id + left join sys_dept d on u.dept_id = d.dept_id + </sql> - <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> - insert into sys_role( - <if test="roleId != null and roleId != 0">role_id,</if> - <if test="roleName != null and roleName != ''">role_name,</if> - <if test="roleKey != null and roleKey != ''">role_key,</if> - <if test="roleSort != null">role_sort,</if> - <if test="dataScope != null and dataScope != ''">data_scope,</if> - <if test="menuCheckStrictly != null">menu_check_strictly,</if> - <if test="deptCheckStrictly != null">dept_check_strictly,</if> - <if test="status != null and status != ''">status,</if> - <if test="remark != null and remark != ''">remark,</if> - <if test="createBy != null and createBy != ''">create_by,</if> - <if test="removeDays != null">removeDays,</if> - <if test="postType != null">postType,</if> - create_time - )values( - <if test="roleId != null and roleId != 0">#{roleId},</if> - <if test="roleName != null and roleName != ''">#{roleName},</if> - <if test="roleKey != null and roleKey != ''">#{roleKey},</if> - <if test="roleSort != null">#{roleSort},</if> - <if test="dataScope != null and dataScope != ''">#{dataScope},</if> - <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if> - <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if> - <if test="status != null and status != ''">#{status},</if> - <if test="remark != null and remark != ''">#{remark},</if> - <if test="createBy != null and createBy != ''">#{createBy},</if> - <if test="removeDays != null">#{removeDays},</if> - <if test="postType != null">#{postType},</if> - sysdate() - ) - </insert> - - <update id="updateRole" parameterType="SysRole"> - update sys_role - <set> - <if test="roleName != null and roleName != ''">role_name = #{roleName},</if> - <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if> - <if test="roleSort != null">role_sort = #{roleSort},</if> - <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if> - <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if> - <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if> - <if test="status != null and status != ''">status = #{status},</if> - <if test="remark != null">remark = #{remark},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - <if test="removeDays != null">removeDays = #{removeDays},</if> - <if test="postType != null">postType = #{postType},</if> - update_time = sysdate() - </set> - where role_id = #{roleId} - </update> - <update id="updateStatus" parameterType="SysRole"> - update sys_role - <set> - <if test="status != null">status = #{status},</if> - <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> - update_time = sysdate() - </set> - where role_id = #{roleId} - </update> + <select id="selectRoleList" parameterType="SysRole" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + where r.del_flag = '0' + <if test="roleId != null and roleId != 0"> + AND r.role_id = #{roleId} + </if> + <if test="roleName != null and roleName != ''"> + AND r.role_name like concat('%', #{roleName}, '%') + </if> + <if test="status != null and status != ''"> + AND r.status = #{status} + </if> + <if test="roleKey != null and roleKey != ''"> + AND r.role_key like concat('%', #{roleKey}, '%') + </if> + order by r.role_sort + </select> - <delete id="deleteRoleById" parameterType="Long"> - update sys_role set del_flag = '2' where role_id = #{roleId} - </delete> - - <delete id="deleteRoleByIds" parameterType="Long"> - update sys_role set del_flag = '2' where role_id in - <foreach collection="roleIds" item="roleId" open="(" separator="," close=")"> - #{roleId} - </foreach> - </delete> - + <select id="selectRolePermissionByUserId" parameterType="Long" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + WHERE r.del_flag = '0' and ur.user_id = #{userId} + </select> + + <select id="selectRoleAll" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + </select> + + <select id="selectRoleListByUserId" parameterType="Long" resultType="Long"> + select r.role_id + from sys_role r + left join sys_user_role ur on ur.role_id = r.role_id + left join sys_user u on u.user_id = ur.user_id + where u.user_id = #{userId} + </select> + + <select id="selectRoleById" parameterType="Long" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + where r.role_id = #{roleId} + </select> + + <select id="selectRolesByUserName" parameterType="String" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + WHERE r.del_flag = '0' and u.user_name = #{userName} + </select> + + <select id="checkRoleNameUnique" parameterType="String" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + where r.role_name=#{roleName} and r.del_flag = '0' limit 1 + </select> + + <select id="checkRoleKeyUnique" parameterType="String" resultMap="SysRoleResult"> + <include refid="selectRoleVo"/> + where r.role_key=#{roleKey} and r.del_flag = '0' limit 1 + </select> + <select id="selectCountByRoleName" resultType="java.lang.Integer"> + select count(*) from sys_role + <where> + <if test="roleName != null and roleName != ''"> + AND role_name = #{roleName} + </if> + AND del_flag = 0 + </where> + </select> + <select id="selectList" resultType="com.ruoyi.common.core.domain.entity.SysRole"> + select role_id AS roleId, role_name AS roleName, role_key AS roleKey, role_sort AS roleSort, + data_scope AS dataScope, + menu_check_strictly AS menuCheckStrictly, dept_check_strictly AS deptCheckStrictly,status AS + status, del_flag AS delFlag, + create_time AS createTime,create_by AS createBy + from sys_role + <where> + <if test="query.roleName != null and query.roleName != ''"> + AND role_name LIKE concat('%',#{query.roleName},'%') + </if> + <if test="query.status != null"> + AND status = #{query.status} + </if> + AND del_flag = 0 + </where> + </select> + <select id="selectCount" resultType="java.lang.Integer"> + select count(*) from sys_role + <where> + <if test="status != null"> + AND status = #{status} + </if> + AND del_flag = 0 + </where> + </select> + <select id="selectListByDelFlag" resultType="com.ruoyi.common.core.domain.entity.SysRole"> + select role_id AS roleId, + role_name AS roleName, + role_key AS roleKey, + role_sort AS roleSort, + data_scope AS dataScope, + menu_check_strictly AS menuCheckStrictly, + dept_check_strictly AS deptCheckStrictly, + status AS status, + del_flag AS delFlag, + create_time AS createTime, + create_by AS createBy, + postType AS postType, + removeDays AS removeDays + from sys_role + where del_flag = 0 + </select> + + <select id="selectRoleByUserId" resultType="com.ruoyi.common.core.domain.entity.SysRole"> + select distinct 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.menu_check_strictly AS menuCheckStrictly, + r.dept_check_strictly AS deptCheckStrictly, + r.status AS status, + r.del_flag AS delFlag, + r.create_time AS createTime, + r.create_by AS createBy + from sys_role r + left join sys_user_role ur on ur.role_id = r.role_id + where ur.user_id = #{userId} + </select> + <select id="selectByUserId" resultType="java.lang.String"> + select t2.role_name + from sys_user_role t1 + left join sys_role t2 on t1.role_id = t2.role_id + where t1.user_id = #{userId} + </select> + + <insert id="insertRole" parameterType="SysRole" useGeneratedKeys="true" keyProperty="roleId"> + insert into sys_role( + <if test="roleId != null and roleId != 0">role_id,</if> + <if test="roleName != null and roleName != ''">role_name,</if> + <if test="roleKey != null and roleKey != ''">role_key,</if> + <if test="roleSort != null">role_sort,</if> + <if test="dataScope != null and dataScope != ''">data_scope,</if> + <if test="menuCheckStrictly != null">menu_check_strictly,</if> + <if test="deptCheckStrictly != null">dept_check_strictly,</if> + <if test="status != null and status != ''">status,</if> + <if test="remark != null and remark != ''">remark,</if> + <if test="createBy != null and createBy != ''">create_by,</if> + <if test="removeDays != null">removeDays,</if> + <if test="postType != null">postType,</if> + create_time + )values( + <if test="roleId != null and roleId != 0">#{roleId},</if> + <if test="roleName != null and roleName != ''">#{roleName},</if> + <if test="roleKey != null and roleKey != ''">#{roleKey},</if> + <if test="roleSort != null">#{roleSort},</if> + <if test="dataScope != null and dataScope != ''">#{dataScope},</if> + <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if> + <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if> + <if test="status != null and status != ''">#{status},</if> + <if test="remark != null and remark != ''">#{remark},</if> + <if test="createBy != null and createBy != ''">#{createBy},</if> + <if test="removeDays != null">#{removeDays},</if> + <if test="postType != null">#{postType},</if> + sysdate() + ) + </insert> + + <update id="updateRole" parameterType="SysRole"> + update sys_role + <set> + <if test="roleName != null and roleName != ''">role_name = #{roleName},</if> + <if test="roleKey != null and roleKey != ''">role_key = #{roleKey},</if> + <if test="roleSort != null">role_sort = #{roleSort},</if> + <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if> + <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if> + <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if> + <if test="status != null and status != ''">status = #{status},</if> + <if test="remark != null">remark = #{remark},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + <if test="removeDays != null">removeDays = #{removeDays},</if> + <if test="postType != null">postType = #{postType},</if> + update_time = sysdate() + </set> + where role_id = #{roleId} + </update> + <update id="updateStatus" parameterType="SysRole"> + update sys_role + <set> + <if test="status != null">status = #{status},</if> + <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> + update_time = sysdate() + </set> + where role_id = #{roleId} + </update> + + <delete id="deleteRoleById" parameterType="Long"> + update sys_role + set del_flag = '2' + where role_id = #{roleId} + </delete> + + <delete id="deleteRoleByIds" parameterType="Long"> + update sys_role set del_flag = '2' where role_id in + <foreach collection="roleIds" item="roleId" open="(" separator="," close=")"> + #{roleId} + </foreach> + </delete> + </mapper> \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 211b23f..2b72e1a 100644 --- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -57,8 +57,6 @@ </insert> <resultMap id="SysUserResult" type="SysUser"> - <association javaType="SysDept" property="dept" resultMap="deptResult"/> - <collection javaType="java.util.List" property="roles" resultMap="RoleResult"/> <id column="user_id" property="userId"/> <result column="dept_id" property="deptId"/> <result column="user_name" property="userName"/> @@ -85,6 +83,8 @@ <result column="county_flag" property="countyFlag"/> <result column="person_in_charge" property="personInCharge"/> <result column="focussed" property="focussed"/> + <association javaType="SysDept" property="dept" resultMap="deptResult"/> + <collection javaType="java.util.List" property="roles" resultMap="RoleResult"/> </resultMap> <resultMap id="deptResult" type="SysDept"> <id column="dept_id" property="deptId"/> diff --git a/ruoyi-system/src/main/resources/mapper/system/TbBasicDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TbBasicDataMapper.xml index 3e4e7d0..1958646 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TbBasicDataMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TbBasicDataMapper.xml @@ -1,61 +1,64 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.TbBasicDataMapper"> - <!-- 通用查询映射结果 --> - <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TbBasicData"> - <id column="id" property="id"/> - <result column="quarter" property="quarter"/> - <result column="dept_area_code" property="deptAreaCode"/> - <result column="transfer_payment_scale" property="transferPaymentScale"/> - <result column="current_gdp" property="currentGdp"/> - <result column="remark" property="remark"/> - <result column="status" property="status"/> - <result column="del_flag" property="delFlag"/> - <result column="create_by" property="createBy"/> - <result column="create_time" property="createTime"/> - <result column="update_by" property="updateBy"/> - <result column="update_time" property="updateTime"/> - </resultMap> + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TbBasicData"> + <id column="id" property="id"/> + <result column="quarter" property="quarter"/> + <result column="dept_area_code" property="deptAreaCode"/> + <result column="transfer_payment_scale" property="transferPaymentScale"/> + <result column="current_gdp" property="currentGdp"/> + <result column="remark" property="remark"/> + <result column="status" property="status"/> + <result column="del_flag" property="delFlag"/> + <result column="create_by" property="createBy"/> + <result column="create_time" property="createTime"/> + <result column="update_by" property="updateBy"/> + <result column="update_time" property="updateTime"/> + <result column="reporting_time" property="reportingTime"/> + </resultMap> - <!-- 通用查询结果列 --> - <sql id="Base_Column_List"> - id, quarter, dept_id, transfer_payment_scale, current_gdp, remark, status, del_flag, create_by, create_time, update_by, update_time - </sql> - <select id="fieldsStatics" resultType="com.ruoyi.system.vo.CurrentFieldsVO"> - SELECT - tbd.id, - su.area_name, - IF(tbd.`quarter` IS NULL, CONCAT(YEAR(NOW()), '年', - CASE - WHEN MONTH(NOW()) BETWEEN 1 AND 3 THEN '一季度' - WHEN MONTH(NOW()) BETWEEN 4 AND 6 THEN '二季度' - WHEN MONTH(NOW()) BETWEEN 7 AND 9 THEN '三季度' - ELSE '四季度' - END), tbd.`quarter`) AS `quarter`, - su.person_in_charge, - su.phone_number, - tbd.create_time, - COALESCE(tbd.`status`, 1) AS `status` - FROM - (SELECT * FROM sys_user WHERE user_type = 2) AS su - LEFT JOIN - (SELECT * FROM tb_basic_data WHERE `quarter` = #{dto.quarter}) AS tbd ON su.area_code = tbd.dept_area_code - <where> - tbd.quarter = #{dto.quarter} - <if test="dto.areaName != null and dto.areaName !=''"> - AND su.area_name LIKE CONCAT('%',#{dto.areaName},'%') - </if> - <if test="dto.status != null"> - AND tbd.status = #{dto.status} - </if> - <if test="dto.personInCharge != null and dto.personInCharge !=''"> - AND su.person_in_charge LIKE CONCAT('%',#{dto.personInCharge},'%') - </if> - <if test="dto.phoneNumber != null and dto.phoneNumber != ''"> - AND su.phone_number LIKE CONCAT('%',#{dto.phoneNumber},'%') - </if> - </where> - </select> + <!-- 通用查询结果列 --> + <sql id="Base_Column_List"> + id, quarter, dept_id, transfer_payment_scale, current_gdp, remark, status, del_flag, create_by, create_time, update_by, update_time,reporting_time + </sql> + <select id="fieldsStatics" resultType="com.ruoyi.system.vo.CurrentFieldsVO"> + SELECT + tbd.id, + su.area_name, + IF(tbd.`quarter` IS NULL, CONCAT(YEAR(NOW()), '年', + CASE + WHEN MONTH(NOW()) BETWEEN 1 AND 3 THEN '一季度' + WHEN MONTH(NOW()) BETWEEN 4 AND 6 THEN '二季度' + WHEN MONTH(NOW()) BETWEEN 7 AND 9 THEN '三季度' + ELSE '四季度' + END), tbd.`quarter`) AS `quarter`, + su.person_in_charge, + su.phone_number, + tbd.create_time, + COALESCE(tbd.`status`, 1) AS `status` + FROM + (SELECT * FROM sys_user WHERE user_type = 2) AS su + LEFT JOIN + (SELECT * FROM tb_basic_data WHERE `quarter` = #{dto.quarter}) AS tbd ON su.area_code = + tbd.dept_area_code + <where> + tbd.quarter = #{dto.quarter} + <if test="dto.areaName != null and dto.areaName !=''"> + AND su.area_name LIKE CONCAT('%',#{dto.areaName},'%') + </if> + <if test="dto.status != null"> + AND tbd.status = #{dto.status} + </if> + <if test="dto.personInCharge != null and dto.personInCharge !=''"> + AND su.person_in_charge LIKE CONCAT('%',#{dto.personInCharge},'%') + </if> + <if test="dto.phoneNumber != null and dto.phoneNumber != ''"> + AND su.phone_number LIKE CONCAT('%',#{dto.phoneNumber},'%') + </if> + </where> + </select> </mapper> diff --git a/ruoyi-system/src/main/resources/mapper/system/TbDataScreenConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TbDataScreenConfigMapper.xml index 2b3c178..1130266 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TbDataScreenConfigMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TbDataScreenConfigMapper.xml @@ -1,23 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.ruoyi.system.mapper.TbDataScreenConfigMapper"> - <!-- 通用查询映射结果 --> - <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TbDataScreenConfig"> - <id column="id" property="id" /> - <result column="type" property="type" /> - <result column="caculate_formula" property="caculateFormula" /> - <result column="sub_type" property="subType" /> - <result column="del_flag" property="delFlag" /> - <result column="create_by" property="createBy" /> - <result column="create_time" property="createTime" /> - <result column="update_by" property="updateBy" /> - <result column="update_time" property="updateTime" /> - </resultMap> + <!-- 通用查询映射结果 --> + <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TbDataScreenConfig"> + <id column="id" property="id"/> + <result column="type" property="type"/> + <result column="calculate_formula" property="calculateFormula"/> + <result column="sub_type" property="subType"/> + <result column="calculate_rate_formula" property="calculateRateFormula"/> + <result column="high_risk" property="highRisk"/> + <result column="medium_risk" property="mediumRisk"/> + <result column="low_risk" property="lowRisk"/> + <result column="no_risk" property="noRisk"/> + <result column="del_flag" property="delFlag"/> + <result column="create_by" property="createBy"/> + <result column="create_time" property="createTime"/> + <result column="update_by" property="updateBy"/> + <result column="update_time" property="updateTime"/> + </resultMap> - <!-- 通用查询结果列 --> - <sql id="Base_Column_List"> - id, type, caculate_formula, sub_type, del_flag, create_by, create_time, update_by, update_time - </sql> + <!-- 通用查询结果列 --> + <sql id="Base_Column_List"> + <if test="true"> + id, type, caculate_formula, sub_type, del_flag, create_by, create_time, update_by, update_time + </if> + </sql> </mapper> -- Gitblit v1.7.1