From 7a996751c3e82e35bdd5d5c91575be883178bb11 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Fri, 14 Mar 2025 17:14:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QualityCollectionController.java | 4 +- .../admin/dict/DictDataController.java | 1 - .../enterprise/EnterpriseController.java | 16 +- .../vo/EnterpriseInspectionsCorrectionVO.java | 1 + .../controller/admin/home/HomeController.java | 9 + .../admin/home/vo/HomeSelectVO.java | 3 + .../vo/EnterpriseQualificationPageReqVO.java | 4 +- .../admin/taskinfo/TaskInfoController.java | 20 +- .../admin/user/vo/user/UserPageReqVO.java | 3 + .../admin/user/vo/user/UserSaveReqVO.java | 4 + .../admin/userarea/UserAreaController.java | 95 ++++++ .../admin/userarea/vo/UserAreaPageReqVO.java | 28 ++ .../admin/userarea/vo/UserAreaRespVO.java | 31 ++ .../admin/userarea/vo/UserAreaSaveReqVO.java | 23 ++ .../dal/dataobject/userarea/UserAreaDO.java | 39 +++ .../EnterpriseQualificationMapper.java | 3 +- .../dal/mysql/taskinfo/TaskInfoMapper.java | 1 + .../dal/mysql/user/AdminUserMapper.java | 1 + .../dal/mysql/userarea/UserAreaMapper.java | 28 ++ .../job/InspectionsSendStartMessageJob.java | 2 +- ...alificationTimeOutSendStartMessageJob.java | 1 + .../yudao/module/system/job/TaskEndJob.java | 44 +++ .../system/job/TaskSendStartMessageJob.java | 2 +- .../service/auth/AdminAuthServiceImpl.java | 115 +++++-- .../enterprise/EnterpriseServiceImpl.java | 56 +++- .../system/service/home/HomeService.java | 3 + .../system/service/home/HomeServiceImpl.java | 295 +++++++++++------- .../notify/NotifyMessageServiceImpl.java | 24 +- .../EnterpriseQualificationServiceImpl.java | 20 ++ .../service/taskinfo/TaskInfoService.java | 2 + .../service/taskinfo/TaskInfoServiceImpl.java | 46 ++- .../service/user/AdminUserServiceImpl.java | 7 +- .../service/userarea/UserAreaService.java | 56 ++++ .../service/userarea/UserAreaServiceImpl.java | 71 +++++ .../mapper/enterprise/EnterpriseMapper.xml | 11 +- .../EnterpriseInspections.xml | 2 +- .../EnterpriseQualificationMapper.xml | 2 +- .../mapper/taskinfo/TaskInfoMapper.xml | 45 +-- 38 files changed, 901 insertions(+), 217 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/UserAreaController.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaPageReqVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaRespVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaSaveReqVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/userarea/UserAreaDO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/userarea/UserAreaMapper.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskEndJob.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaService.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaServiceImpl.java diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/QualityCollectionController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/QualityCollectionController.java index 4f45447..a49933b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/QualityCollectionController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/QualityCollectionController.java @@ -40,7 +40,7 @@ public class QualityCollectionController { @PostMapping("/create") @Operation(summary = "创建空气质量采集") - @PreAuthorize("@ss.hasPermission('system:quality-collection:create')") +// @PreAuthorize("@ss.hasPermission('system:quality-collection:create')") public CommonResult createQualityCollection(@Valid @RequestBody QualityCollectionSaveReqVO createReqVO) { return success(qualityCollectionService.createQualityCollection(createReqVO)); } @@ -73,7 +73,7 @@ public class QualityCollectionController { @GetMapping("/page") @Operation(summary = "获得空气质量采集分页") - @PreAuthorize("@ss.hasPermission('system:quality-collection:query')") +// @PreAuthorize("@ss.hasPermission('system:quality-collection:query')") public CommonResult> getQualityCollectionPage(@Valid QualityCollectionPageReqVO pageReqVO) { PageResult pageResult = qualityCollectionService.getQualityCollectionPage(pageReqVO); return success(BeanUtils.toBean(pageResult, QualityCollectionRespVO.class)); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java index 0326343..2d23044 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dict/DictDataController.java @@ -78,7 +78,6 @@ public class DictDataController { @Operation(summary = "获得全部字典数据列表", description = "一般用于管理后台缓存字典数据在本地") // 无需添加权限认证,因为前端全局都需要 public CommonResult>> getListDictType(@Param("type") String[] type) { - Map> list = dictDataService.getDictTypeList(type); return success(list); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java index f1b3262..b2b0703 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/EnterpriseController.java @@ -172,13 +172,15 @@ public class EnterpriseController { if (enterpriseQualificationList != null && enterpriseQualificationList.size() > 0) { enterpriseQualificationList.forEach(item->{ LocalDateTime now = LocalDateTime.now(); - LocalDateTime past = item.getExpiryDate().minus(Period.ofDays(30)); - if (item.getExpiryDate().isBefore(now)) { - item.setStatus(3); - } else if (past.isBefore(now)) { - item.setStatus(2); - } else { - item.setStatus(1); + if (item.getExpiryDate() != null) { + LocalDateTime past = item.getExpiryDate().minus(Period.ofDays(30)); + if (item.getExpiryDate().isBefore(now)) { + item.setStatus(3); + } else if (past.isBefore(now)) { + item.setStatus(2); + } else { + item.setStatus(1); + } } }); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsCorrectionVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsCorrectionVO.java index f6434c5..99f6057 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsCorrectionVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/EnterpriseInspectionsCorrectionVO.java @@ -10,4 +10,5 @@ public class EnterpriseInspectionsCorrectionVO { private Long creator; private Long enterpriseId; private String feedback; + private Long taskId; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java index 7f131a2..1b7c981 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/HomeController.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.controller.admin.home; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; @@ -30,6 +31,14 @@ public class HomeController { @Resource private HomeService homeService; + @GetMapping("/getUserArea") + @Operation(summary = "用户关联区域集合") + @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 + public CommonResult> getUserArea() { + return success(homeService.getUserArea()); + } + + @GetMapping("/appCount1") @Operation(summary = "app首页统计第一块") @DataPermission(enable = false) // 关闭数据权限,避免只查看自己时,查询不到部门。 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java index 490b348..c6e5f65 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeSelectVO.java @@ -14,6 +14,9 @@ public class HomeSelectVO { private Integer selectWeek; //部门 private Long deptId; + + //区域 + private Integer region; //类型 private Integer type; //时间 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationPageReqVO.java index b3c8962..d2f5c9d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationPageReqVO.java @@ -53,4 +53,6 @@ public class EnterpriseQualificationPageReqVO extends PageParam { @Schema(description = "资质编号") private String enterpriseAuth; -} \ No newline at end of file + private List enterpriseIds; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java index 48ec2ac..4d46063 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/TaskInfoController.java @@ -195,9 +195,9 @@ public class TaskInfoController { if (taskInfo != null) { //标签 final List tagLibraryDOS = tagLibraryService.listByTaskId(taskInfo.getId()); - if (CollUtil.isNotEmpty(tagLibraryDOS)) { - taskInfo.setTagList(tagLibraryDOS.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList())); - } + if (CollUtil.isNotEmpty(tagLibraryDOS)) { + taskInfo.setTagList(tagLibraryDOS.stream().map(TagLibraryDO::getTagName).collect(Collectors.toList())); + } //发布部门 final Long userId = Long.valueOf(taskInfo.getCreator()); AdminUserDO user = adminUserMapper.selectById(userId); @@ -218,11 +218,13 @@ public class TaskInfoController { public CommonResult> getTaskInfoPage(@Valid TaskInfoPageReqVO pageReqVO) { PageResult pageResult = taskInfoService.getTaskInfoPage(pageReqVO); AdminUserDO user = adminUserService.getUser(SecurityFrameworkUtils.getLoginUserId()); - DeptDO dep= deptService.getDept( user.getDeptId()); + DeptDO dept= deptService.getDept(user.getDeptId()); EnterpriseInspectionsPageReqVO enterpriseInspectionsPageReqVO=new EnterpriseInspectionsPageReqVO(); pageResult.getList().forEach(item->{ - item.setPublishDep(dep.getName()); + if (dept != null) { + item.setDeptName(dept.getName()); + } final AdminUserDO user1 = adminUserService.getUser(Long.valueOf(item.getCreator())); if (user1 != null) { item.setCreateName(user1.getRealName()); @@ -270,4 +272,12 @@ public class TaskInfoController { BeanUtils.toBean(list, TaskInfoRespVO.class)); } + @GetMapping("/testInsertUserArea") + @Operation(summary = "获得任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。分页") +// @PreAuthorize("@ss.hasPermission('system:task-info:query')") + public CommonResult appPageByEnterpriseId() { + taskInfoService.test(); + return success("成功"); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java index 5b01458..eca4c38 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserPageReqVO.java @@ -22,6 +22,9 @@ public class UserPageReqVO extends PageParam { @Schema(description = "用户账号,模糊匹配", example = "yudao") private String username; + @Schema(description = "真实姓名,模糊匹配", example = "张三") + private String realName; + @Schema(description = "手机号码,模糊匹配", example = "yudao") private String mobile; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java index 4037005..a8a6022 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java @@ -12,6 +12,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.*; +import java.util.List; import java.util.Set; @Schema(description = "管理后台 - 用户创建/修改 Request VO") @@ -37,6 +38,9 @@ public class UserSaveReqVO { @DiffLogField(name = "备注") private String remark; + @Schema(description = "管理区域", example = "1") + private List area; + @Schema(description = "部门编号", example = "我是一个用户") @DiffLogField(name = "部门", function = DeptParseFunction.NAME) private Long deptId; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/UserAreaController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/UserAreaController.java new file mode 100644 index 0000000..532559d --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/UserAreaController.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.system.controller.admin.userarea; + +import org.springframework.web.bind.annotation.*; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.system.controller.admin.userarea.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; +import cn.iocoder.yudao.module.system.service.userarea.UserAreaService; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + +@Tag(name = "管理后台 - 用户区域关联") +@RestController +@RequestMapping("/system/user-area") +@Validated +public class UserAreaController { + + @Resource + private UserAreaService userAreaService; + + @PostMapping("/create") + @Operation(summary = "创建用户区域关联") + @PreAuthorize("@ss.hasPermission('system:user-area:create')") + public CommonResult createUserArea(@Valid @RequestBody UserAreaSaveReqVO createReqVO) { + return success(userAreaService.createUserArea(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新用户区域关联") + @PreAuthorize("@ss.hasPermission('system:user-area:update')") + public CommonResult updateUserArea(@Valid @RequestBody UserAreaSaveReqVO updateReqVO) { + userAreaService.updateUserArea(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除用户区域关联") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('system:user-area:delete')") + public CommonResult deleteUserArea(@RequestParam("id") Long id) { + userAreaService.deleteUserArea(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得用户区域关联") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:user-area:query')") + public CommonResult getUserArea(@RequestParam("id") Long id) { + UserAreaDO userArea = userAreaService.getUserArea(id); + return success(BeanUtils.toBean(userArea, UserAreaRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得用户区域关联分页") + @PreAuthorize("@ss.hasPermission('system:user-area:query')") + public CommonResult> getUserAreaPage(@Valid UserAreaPageReqVO pageReqVO) { + PageResult pageResult = userAreaService.getUserAreaPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, UserAreaRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出用户区域关联 Excel") + @PreAuthorize("@ss.hasPermission('system:user-area:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportUserAreaExcel(@Valid UserAreaPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = userAreaService.getUserAreaPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "用户区域关联.xls", "数据", UserAreaRespVO.class, + BeanUtils.toBean(list, UserAreaRespVO.class)); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaPageReqVO.java new file mode 100644 index 0000000..2aff21e --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaPageReqVO.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.system.controller.admin.userarea.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 用户区域关联分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class UserAreaPageReqVO extends PageParam { + + @Schema(description = "所属区域") + private Integer area; + + @Schema(description = "用户id", example = "29787") + private Long userId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaRespVO.java new file mode 100644 index 0000000..2e9579c --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaRespVO.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.system.controller.admin.userarea.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 用户区域关联 Response VO") +@Data +@ExcelIgnoreUnannotated +public class UserAreaRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25139") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "所属区域") + @ExcelProperty("所属区域") + private Integer area; + + @Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29787") + @ExcelProperty("用户id") + private Long userId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaSaveReqVO.java new file mode 100644 index 0000000..a09c1b7 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/userarea/vo/UserAreaSaveReqVO.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.module.system.controller.admin.userarea.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import javax.validation.constraints.NotNull; +import java.util.*; + +@Schema(description = "管理后台 - 用户区域关联新增/修改 Request VO") +@Data +public class UserAreaSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "25139") + private Long id; + + @Schema(description = "所属区域") + private Integer area; + + @Schema(description = "用户id", requiredMode = Schema.RequiredMode.REQUIRED, example = "29787") + @NotNull(message = "用户id不能为空") + private Long userId; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/userarea/UserAreaDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/userarea/UserAreaDO.java new file mode 100644 index 0000000..7ec2d57 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/userarea/UserAreaDO.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.system.dal.dataobject.userarea; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 用户区域关联 DO + * + * @author 芋道源码 + */ +@TableName("user_area") +@KeySequence("user_area_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class UserAreaDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 所属区域 + */ + private Integer area; + /** + * 用户id + */ + private Long userId; + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/qualification/EnterpriseQualificationMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/qualification/EnterpriseQualificationMapper.java index da0281b..43ba52c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/qualification/EnterpriseQualificationMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/qualification/EnterpriseQualificationMapper.java @@ -21,11 +21,12 @@ public interface EnterpriseQualificationMapper extends BaseMapperX selectPage(EnterpriseQualificationPageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(EnterpriseQualificationDO::getEnterpriseId, reqVO.getEnterpriseId()) - .likeIfPresent(EnterpriseQualificationDO::getQualificationName, reqVO.getQualificationName()) + .eqIfPresent(EnterpriseQualificationDO::getQualificationName, reqVO.getQualificationName()) .betweenIfPresent(EnterpriseQualificationDO::getExpiryDate, reqVO.getExpiryDate()) .eqIfPresent(EnterpriseQualificationDO::getQualificationDescription, reqVO.getQualificationDescription()) .betweenIfPresent(EnterpriseQualificationDO::getCreateTime, reqVO.getCreateTime()) .eqIfPresent(EnterpriseQualificationDO::getUpdater, reqVO.getUpdater()) + .inIfPresent(EnterpriseQualificationDO::getEnterpriseId, reqVO.getEnterpriseIds()) .eqIfPresent(EnterpriseQualificationDO::getCreator, reqVO.getCreator()) .betweenIfPresent(EnterpriseQualificationDO::getHandleDate, reqVO.getHandleDate()) .eqIfPresent(EnterpriseQualificationDO::getEnterpriseAuth, reqVO.getEnterpriseAuth()) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java index 0de30ec..f24f4e3 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/taskinfo/TaskInfoMapper.java @@ -5,6 +5,7 @@ import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeExecFinishVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 950a1a8..c19c5b5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -30,6 +30,7 @@ public interface AdminUserMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) + .likeIfPresent(AdminUserDO::getRealName, reqVO.getRealName()) .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/userarea/UserAreaMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/userarea/UserAreaMapper.java new file mode 100644 index 0000000..81cd840 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/userarea/UserAreaMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.system.dal.mysql.userarea; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.system.controller.admin.userarea.vo.*; + +/** + * 用户区域关联 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface UserAreaMapper extends BaseMapperX { + + default PageResult selectPage(UserAreaPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(UserAreaDO::getArea, reqVO.getArea()) + .eqIfPresent(UserAreaDO::getUserId, reqVO.getUserId()) + .betweenIfPresent(UserAreaDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(UserAreaDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/InspectionsSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/InspectionsSendStartMessageJob.java index af87a4d..f580c65 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/InspectionsSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/InspectionsSendStartMessageJob.java @@ -69,7 +69,7 @@ public class InspectionsSendStartMessageJob implements JobHandler { Map templateParams = new HashMap<>(); templateParams.put("title", enterpriseService.getEnterprise(item.getEnterpriseId()).getEnterprisesName()); templateParams.put("correctionTime", inspectionsLogNew.getCorrectionTime()); - templateParams.put("url", "sub/inspection/detail?id=" + item.getInspectionsId()); + templateParams.put("url", "/sub/task/record?taskId="+item.getTaskId() +"&recordId=" + item.getEnterpriseId() +"&enterpriseId=" + item.getEnterpriseId()); notifyMessage.setTemplateParams(templateParams); notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/QualificationTimeOutSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/QualificationTimeOutSendStartMessageJob.java index f5c5c89..7e8f8e5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/QualificationTimeOutSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/QualificationTimeOutSendStartMessageJob.java @@ -63,6 +63,7 @@ public class QualificationTimeOutSendStartMessageJob implements JobHandler { Map templateParams = new HashMap<>(); templateParams.put("title", item.getEnterpriseName()); templateParams.put("endTime", item.getExpiryDate()); + templateParams.put("url", "/sub/enterprise/detail?id="+ item.getEnterpriseId()); notifyMessage.setTemplateParams(templateParams); notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskEndJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskEndJob.java new file mode 100644 index 0000000..8365921 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskEndJob.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.system.job; + +import cn.hutool.core.date.DateUtil; +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoRespVO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; + +@Component +public class TaskEndJob implements JobHandler { + + @Resource + TaskInfoMapper taskInfoMapper; + + + /** + * 执行任务 + * + * @param param 参数 + * @return 结果 + * @throws Exception 异常 + */ + + @Override + public String execute(String param) throws Exception { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + // 任务结束时间小于当前日期 + wrapper.lt(TaskInfoDO::getEndDate, DateUtil.date()); + wrapper.eq(TaskInfoDO::getStatus, 2); + List list = taskInfoMapper.selectList(wrapper); + list.forEach(x -> { + x.setStatus(3); + taskInfoMapper.updateById(x); + }); + + return "成功"; + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java index 54ed7ed..9c4c4a5 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java @@ -89,7 +89,7 @@ public class TaskSendStartMessageJob implements JobHandler { templateParams.put("title", beforeTaskInfo.getTitle()); templateParams.put("startTime", DateUtil.format(beforeTaskInfo.getStartDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); templateParams.put("endTime", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); - templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); + templateParams.put("url", "sub/task/detail?id="+ enterpriseInspectionsDO.getTaskId()); notifyMessage.setTemplateParams(templateParams); notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index 093b83d..3dc2e97 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -13,10 +13,12 @@ import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; import cn.iocoder.yudao.module.system.convert.auth.AuthConvert; import cn.iocoder.yudao.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserBindDO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.social.SocialClientMapper; import cn.iocoder.yudao.module.system.dal.mysql.social.SocialUserBindMapper; @@ -48,6 +50,7 @@ import javax.annotation.Resource; import javax.validation.Validator; import java.util.List; import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -86,6 +89,8 @@ public class AdminAuthServiceImpl implements AdminAuthService { private SocialUserBindMapper socialUserBindMapper; @Resource private UserRoleMapper userRoleMapper; + @Resource + private RoleMapper roleMapper; /** * 验证码的开关,默认为 true @@ -461,43 +466,101 @@ public class AdminAuthServiceImpl implements AdminAuthService { @Override public RoleNameAndSelectTypeVO roleTypeByUserId() { - Long loginUserId = getLoginUserId(); + final Long loginUserId = getLoginUserId(); + AdminUserDO user = userService.getUser(loginUserId); - RoleNameAndSelectTypeVO roleNameAndSelectTypeVO = new RoleNameAndSelectTypeVO(); - if (user != null) { + if (user == null) { + throw exception(USER_NOT_EXISTS); + } - //如果岗位不存在查询角色 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserRoleDO::getUserId, loginUserId); - List userRoleDO = userRoleMapper.selectList(wrapper); + List roleIds = getUserRoleIds(loginUserId); + if (roleIds.isEmpty()) { + throw exception(ROLE_ERROR); + } - if (userRoleDO == null) { - throw exception(ROLE_ERROR); - } + List roles = getRolesByIds(roleIds); + if (roles.isEmpty()) { + throw exception(ROLE_NOT_EXISTS); + } - List collect = userRoleDO.stream().map(item -> item.getRoleId()).collect(Collectors.toList()); - if (collect.contains(164l) || collect.contains(1l)) { - // 全部权限,不需要设置任何条件 - roleNameAndSelectTypeVO.setRoleName("director"); - } else if (collect.contains(163L)) { - // 本部门权限 - roleNameAndSelectTypeVO.setRoleName("queue"); - roleNameAndSelectTypeVO.setValue(user.getDeptId()); - } else { - // 仅自己权限 - roleNameAndSelectTypeVO.setRoleName("self"); - roleNameAndSelectTypeVO.setValue(loginUserId); - roleNameAndSelectTypeVO.setDeptId(user.getDeptId()); - } + return buildRoleVO(user, loginUserId, roles); + } + + private List getUserRoleIds(Long userId) { + return userRoleMapper.selectList(new LambdaQueryWrapper() + .select(UserRoleDO::getRoleId) + .eq(UserRoleDO::getUserId, userId)) + .stream() + .map(UserRoleDO::getRoleId) + .collect(Collectors.toList()); + } + + private List getRolesByIds(List roleIds) { + return roleMapper.selectList(new LambdaQueryWrapper() + .in(RoleDO::getId, roleIds) + .select(RoleDO::getName)); + } + private RoleNameAndSelectTypeVO buildRoleVO(AdminUserDO user, Long userId, List roles) { + RoleNameAndSelectTypeVO vo = new RoleNameAndSelectTypeVO(); + Set roleNames = roles.stream() + .map(RoleDO::getName) + .collect(Collectors.toSet()); + + if (hasAdminPrivileges(roleNames)) { + buildAdminVO(vo); + } else if (hasDepartmentPrivilege(roleNames)) { + buildDepartmentVO(vo, user); } else { - throw exception(USER_NOT_EXISTS); + buildSelfVO(vo, userId, user); } + return vo; + } + + private boolean hasAdminPrivileges(Set roleNames) { + return roleNames.contains(RoleConstants.ROLE_DIRECTOR) + || roleNames.contains(RoleConstants.SUPER_ADMIN) + || roleNames.contains(RoleConstants.ROLE_DEPUTY_DIRECTOR) + || roleNames.contains(RoleConstants.ROLE_COMPREHENSIVE); + } + + private boolean hasDepartmentPrivilege(Set roleNames) { + return roleNames.contains(RoleConstants.ROLE_QUEUE); + } - return roleNameAndSelectTypeVO; + private void buildAdminVO(RoleNameAndSelectTypeVO vo) { + vo.setRoleName(RoleConstants.ROLE_DIRECTOR); + } + + private void buildDepartmentVO(RoleNameAndSelectTypeVO vo, AdminUserDO user) { + vo.setRoleName(RoleConstants.ROLE_QUEUE); + vo.setValue(user.getDeptId()); + } + private void buildSelfVO(RoleNameAndSelectTypeVO vo, Long userId, AdminUserDO user) { + vo.setRoleName(RoleConstants.ROLE_SELF); + vo.setValue(userId); + vo.setDeptId(user.getDeptId()); } + // 常量类示例 + public class RoleConstants { + //局长 + public static final String ROLE_DIRECTOR = "director"; + //副局长 + public static final String ROLE_DEPUTY_DIRECTOR = "deputy_director"; + //队长 + public static final String ROLE_QUEUE = "queue"; + //专管员 + public static final String ROLE_SELF = "self"; + //超级管理员 + public static final String SUPER_ADMIN = "super_admin"; + //综合部负责人 + public static final String ROLE_COMPREHENSIVE = "comprehensive"; + + } + + @VisibleForTesting void validateCaptcha(AuthRegisterReqVO reqVO) { diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java index f70e77a..377f0de 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterprise/EnterpriseServiceImpl.java @@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; import cn.iocoder.yudao.module.system.dal.mysql.enterpriseauditlog.EnterpriseAuditLogMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterprisesuser.EnterprisesUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; @@ -22,6 +23,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.permission.RoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.qualification.EnterpriseQualificationMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; +import cn.iocoder.yudao.module.system.dal.mysql.userarea.UserAreaMapper; import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.permission.RoleService; @@ -85,6 +87,8 @@ public class EnterpriseServiceImpl implements EnterpriseService { private EnterprisesUserMapper enterprisesUserMapper; @Resource private AdminAuthService authService; + @Resource + private UserAreaMapper userAreaMapper; //企业图片 public final static Long DEFAULT_DICT_DATA_QY = 1L; @@ -155,7 +159,7 @@ public class EnterpriseServiceImpl implements EnterpriseService { enterpriseTagDOList.add(enterpriseTagDO); } enterpriseTagMapper.insertBatch(enterpriseTagDOList); - + } if(!CollectionUtils.isAnyEmpty(createReqVO.getQualis())) @@ -167,6 +171,19 @@ public class EnterpriseServiceImpl implements EnterpriseService { }); } +// //给专管人员 添加区域关联表 +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(UserAreaDO::getUserId, createReqVO.getUserId()); +// wrapper.eq(UserAreaDO::getArea, createReqVO.getRegion()); +// final List userAreaDOS = userAreaMapper.selectList(wrapper); +// if (userAreaDOS.size() == 0 && createReqVO.getRegion() != null) { +// Integer region = Integer.valueOf(createReqVO.getRegion()); +// UserAreaDO userAreaDO = new UserAreaDO(); +// userAreaDO.setArea(region); +// userAreaDO.setUserId(createReqVO.getUserId()); +// userAreaMapper.insert(userAreaDO); +// } + // 返回 return enterprise.getId(); } @@ -201,9 +218,10 @@ public class EnterpriseServiceImpl implements EnterpriseService { @Override + @Transactional public void updateEnterprise(EnterpriseSaveReqVO updateReqVO) { // 校验存在 - validateEnterpriseExists(updateReqVO.getId()); + final EnterpriseDO enterpriseDO = validateEnterpriseExists(updateReqVO.getId()); //如果图片有改变 先删除 在重新添加 if (updateReqVO.getFileIds() != null && updateReqVO.getFileIds().length > 0) { @@ -222,6 +240,33 @@ public class EnterpriseServiceImpl implements EnterpriseService { } } +// //如果专管员发生改变, 先删除关联表中的数据 +// if (!enterpriseDO.getUserId().equals(updateReqVO.getUserId())) { +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(EnterpriseDO::getUserId, enterpriseDO.getUserId()); +// wrapper.eq(EnterpriseDO::getRegion, enterpriseDO.getRegion()); +// final List enterpriseDOS = enterpriseMapper.selectList(wrapper); +// if (enterpriseDOS != null && enterpriseDOS.size() == 1) { +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(UserAreaDO::getUserId, enterpriseDO.getUserId()); +// queryWrapper.eq(UserAreaDO::getArea, enterpriseDO.getRegion()); +// userAreaMapper.delete(queryWrapper); +// } +// +// //给新专管人员 添加区域关联表 +// LambdaQueryWrapper wrapper1 = new LambdaQueryWrapper<>(); +// wrapper1.eq(UserAreaDO::getUserId, updateReqVO.getUserId()); +// wrapper1.eq(UserAreaDO::getArea, updateReqVO.getRegion()); +// final List userAreaDOS = userAreaMapper.selectList(wrapper1); +// if (userAreaDOS == null && updateReqVO.getRegion() != null) { +// Integer region = Integer.valueOf(updateReqVO.getRegion()); +// UserAreaDO userAreaDO = new UserAreaDO(); +// userAreaDO.setArea(region); +// userAreaDO.setUserId(updateReqVO.getUserId()); +// userAreaMapper.insert(userAreaDO); +// } +// } + // 更新 EnterpriseDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseDO.class); enterpriseMapper.updateById(updateObj); @@ -235,9 +280,12 @@ public class EnterpriseServiceImpl implements EnterpriseService { enterpriseMapper.deleteById(id); } - private void validateEnterpriseExists(Long id) { - if (enterpriseMapper.selectById(id) == null) { + private EnterpriseDO validateEnterpriseExists(Long id) { + final EnterpriseDO enterpriseDO = enterpriseMapper.selectById(id); + if (enterpriseDO == null) { throw exception(ENTERPRISE_NOT_EXISTS); + } else { + return enterpriseDO; } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java index 29f2938..c6eccc1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.service.home; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeCountResVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; @@ -10,4 +11,6 @@ public interface HomeService { HomeCountResVO appCount1(HomeSelectVO homeSelectVO); List appCount2(HomeSelectVO homeSelectVO); + + List getUserArea(); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java index d0cbd5f..4ed64c2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/home/HomeServiceImpl.java @@ -2,15 +2,21 @@ package cn.iocoder.yudao.module.system.service.home; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.RoleNameAndSelectTypeVO; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.*; import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoPageReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterprisetag.EnterpriseTagMapper; import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; +import cn.iocoder.yudao.module.system.dal.mysql.userarea.UserAreaMapper; import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; +import cn.iocoder.yudao.module.system.service.auth.AdminAuthServiceImpl; import cn.iocoder.yudao.module.system.service.dept.DeptService; +import cn.iocoder.yudao.module.system.service.dict.DictDataService; import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -19,12 +25,11 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; + @Slf4j @Service public class HomeServiceImpl implements HomeService{ @@ -36,149 +41,153 @@ public class HomeServiceImpl implements HomeService{ private TaskInfoMapper taskInfoMapper; @Resource private AdminAuthService authService; + @Resource + private UserAreaMapper userAreaMapper; + @Resource + private DictDataService dictDataService; @Override public HomeCountResVO appCount1(HomeSelectVO homeSelectVO) { + // 1. 初始化参数处理 + processDeptSelection(homeSelectVO); - //如果不传部门id 上来就是根据用户的所在的部门查询 - RoleNameAndSelectTypeVO typeVO = authService.roleTypeByUserId(); + // 2. 构建结果对象 + HomeCountResVO result = new HomeCountResVO(); - if (homeSelectVO.getDeptId() == null) { - if ("self".equals(typeVO.getRoleName())) { - homeSelectVO.setDeptId(typeVO.getDeptId()); - } - if ("queue".equals(typeVO.getRoleName())) { - homeSelectVO.setDeptId(typeVO.getValue()); - } - } + // 3. 统计企业数量 + result.setEnterpriseCount(getEnterpriseCount(homeSelectVO)); - HomeCountResVO homeCountResVO = new HomeCountResVO(); + // 4. 处理任务统计数据 + processTaskStatistics(result, homeSelectVO); - //查企业 - final Integer enterpriseCount = this.getEnterpriseCount(homeSelectVO); - homeCountResVO.setEnterpriseCount(enterpriseCount); + // 5. 处理分组统计饼图 + processGroupStatistics(result, homeSelectVO); - //查询任务和执法 - final List homeExecFinishVOS = taskInfoMapper.selectHomeExecFinish(homeSelectVO); + return result; + } - List taskExecList = new ArrayList<>(); - List taskFinishList = new ArrayList<>(); - if (homeExecFinishVOS != null && homeExecFinishVOS.size() > 0) { - homeExecFinishVOS.forEach(item->{ - taskExecList.add(item.getExecCount()); - taskFinishList.add(item.getFinishCount()); - }); + + // 参数处理方法 + private void processDeptSelection(HomeSelectVO homeSelectVO) { + if (homeSelectVO.getDeptId() != null) return; + + RoleNameAndSelectTypeVO roleInfo = authService.roleTypeByUserId(); + switch (roleInfo.getRoleName()) { + case AdminAuthServiceImpl.RoleConstants.ROLE_SELF: + homeSelectVO.setDeptId(roleInfo.getDeptId()); + break; + case AdminAuthServiceImpl.RoleConstants.ROLE_QUEUE: + homeSelectVO.setDeptId(roleInfo.getValue()); + break; + default: + // 其他角色不需要设置部门ID + break; } + } - //任务总数 - homeCountResVO.setTaskCount(homeExecFinishVOS.size()); + // 任务统计处理方法 + private void processTaskStatistics(HomeCountResVO result, HomeSelectVO query) { + List taskData = Optional.ofNullable(taskInfoMapper.selectHomeExecFinish(query)) + .orElse(Collections.emptyList()); - //总数 - final Integer taskExec = taskExecList.stream().reduce(Integer::sum).orElse(0); - homeCountResVO.setInspectionsCount(taskExec); + result.setTaskCount(taskData.size()); - //完成数 - final Integer taskFinish = taskFinishList.stream().reduce(Integer::sum).orElse(0); + int totalExec = taskData.stream() + .mapToInt(HomeExecFinishVO::getExecCount) + .sum(); + result.setInspectionsCount(totalExec); - if (taskFinish != null && taskFinish != 0) { - double taskCompletionRate = (double) taskFinish/taskExec*100; - homeCountResVO.setTaskCompletionRate(String.format("%.1f", taskCompletionRate)); - } else { - homeCountResVO.setTaskCompletionRate("0.0"); - } + int totalFinish = taskData.stream() + .mapToInt(HomeExecFinishVO::getFinishCount) + .sum(); + result.setTaskCompletionRate(calculateCompletionRate(totalFinish, totalExec)); + } - //根据不同的身份查询 - final List homeGroupCountVOS = taskInfoMapper.selectHomeGroupCount(homeSelectVO); - List homeGroupCountVOS1 = new ArrayList<>(); - - if (homeGroupCountVOS != null && homeGroupCountVOS.size() > 0) { - homeGroupCountVOS.forEach(item->{ - HomeListVO homeListVO = new HomeListVO(); - homeListVO.setName(item.getName()); - homeListVO.setValue(item.getCompletionRate()); -// double rate = (double) item.getFinishCount() /taskExec * 100; -// homeListVO.setPieValue(String.format("%.1f", rate)); - homeGroupCountVOS1.add(homeListVO); - }); + // 完成率计算方法 + private String calculateCompletionRate(int finish, int total) { + return total > 0 ? String.format(Locale.US, "%.1f", (finish * 100.0) / total) : "0.0"; + } - //循环饼图占比数据 - - final List collect = homeGroupCountVOS1.stream().filter(i -> !i.getValue().equals("0.0")). - map(i -> Double.parseDouble(i.getValue())).collect(Collectors.toList()); - - double total = collect.stream() - .reduce(0.0, Double::sum); - - homeGroupCountVOS1.forEach(item->{ - if (item != null && item.getValue() != null) { - final double value = Double.parseDouble(item.getValue()); - if (total != 0 && value != 0) { - final double pieRate = value / total * 100; - // 如果 TaskCompletionRate 不为空,则乘以该值 - String taskCompletionRateStr = homeCountResVO.getTaskCompletionRate(); - double taskCompletionRate = "0.0".equals(taskCompletionRateStr) ? 0.0 : Double.parseDouble(taskCompletionRateStr); - final double pie = pieRate * taskCompletionRate / 100; - item.setPieValue(String.format("%.1f", pie)); - } else { - item.setPieValue(String.format("%.1f", 0.0)); - } - } else { - item.setPieValue(String.format("%.1f", 0.0)); - } - }); + // 分组统计处理方法 + private void processGroupStatistics(HomeCountResVO result, HomeSelectVO query) { + List groupData = Optional.ofNullable(taskInfoMapper.selectHomeGroupCount(query)) + .orElse(Collections.emptyList()); + List pieData = groupData.stream() + .map(this::convertToPieItem) + .collect(Collectors.toList()); + calculatePieValues(pieData, result.getTaskCompletionRate()); + result.setCompletionRate(pieData); + } + // 数据转换方法 + private HomeListVO convertToPieItem(HomeGroupCountVO item) { + HomeListVO vo = new HomeListVO(); + vo.setName(item.getName()); + + + try { + // 将字符串解析为浮点数 + float rate = Float.parseFloat(item.getCompletionRate()); + // 格式化为保留一位小数的字符串 + String formattedRate = String.format(Locale.US, "%.1f", rate); + // 传递给 VO + vo.setValue(formattedRate); + } catch (NumberFormatException e) { + // 处理无效字符串(例如赋默认值或记录错误) + vo.setValue("0.0"); + e.printStackTrace(); } + return vo; + } - //排序 - final List sortedList = homeGroupCountVOS1.stream() - .filter(item -> item.getValue() != null && !item.getValue().isEmpty()) // 过滤掉 null 或空字符串 - .sorted(Comparator.comparing( - item -> { - try { - return Double.parseDouble(item.getValue()); // 将字符串转为 double - } catch (NumberFormatException e) { - return Double.MIN_VALUE; // 如果解析失败,视为最小值 - } - } - )) // 升序排序 - .collect(Collectors.toList()); + // 饼图数值计算方法 + private void calculatePieValues(List items, String baseRate) { + double baseRateValue = parseDoubleSafely(baseRate); + double total = items.stream() + .mapToDouble(i -> parseDoubleSafely(i.getValue())) + .sum(); + + items.forEach(item -> { + double itemValue = parseDoubleSafely(item.getValue()); + double pieValue = total > 0 ? (itemValue / total) * baseRateValue : 0.0; + item.setPieValue(String.format(Locale.US, "%.1f", pieValue)); + }); + } - if (sortedList != null && sortedList.size() > 0) { - List reversedList = new ArrayList<>(); - for (int i = sortedList.size() - 1; i >= 0; i--) { - reversedList.add(sortedList.get(i)); - } - homeCountResVO.setCompletionRate(reversedList); + // 安全转换方法 + private double parseDoubleSafely(String value) { + try { + return Double.parseDouble(value); + } catch (NumberFormatException e) { + return 0.0; } - - return homeCountResVO; } public LocalDateTime[] getWeekDate(Integer selectWeek) { //按时间查询 - LocalDateTime now = LocalDateTime.now(); - LocalDateTime[] dateList = new LocalDateTime[2]; - - switch (selectWeek) { - case 4: - dateList[0] = now.minusDays(3); // 三天前 - break; - case 3: - dateList[0] = now.minusWeeks(1); // 一周前 - break; - case 2: - dateList[0] = now.minusMonths(1); // 一月前 - break; - case 1: - dateList[0] = now.minusYears(1); // 一年前 - break; - } - dateList[1] = now; + LocalDateTime now = LocalDateTime.now(); + LocalDateTime[] dateList = new LocalDateTime[2]; + + switch (selectWeek) { + case 4: + dateList[0] = now.minusDays(3); // 三天前 + break; + case 3: + dateList[0] = now.minusWeeks(1); // 一周前 + break; + case 2: + dateList[0] = now.minusMonths(1); // 一月前 + break; + case 1: + dateList[0] = now.minusYears(1); // 一年前 + break; + } + dateList[1] = now; - return dateList; + return dateList; } @@ -205,6 +214,53 @@ public class HomeServiceImpl implements HomeService{ } } + @Override + public List getUserArea() { + + List labelValueVOS = new ArrayList<>(); + + RoleNameAndSelectTypeVO typeVO = authService.roleTypeByUserId(); + if ("director".equals(typeVO.getRoleName())) { + //局长返回整个字典 + final List enterprisesArea = dictDataService.getDictDataList(0, "enterprises_area"); + enterprisesArea.forEach(item-> { + LabelValueVO labelValueVO = new LabelValueVO(); + labelValueVO.setLabel(item.getLabel()); + labelValueVO.setValue(Integer.valueOf(item.getValue())); + labelValueVOS.add(labelValueVO); + }); + + } else { +// LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); +// wrapper.eq(UserAreaDO::getUserId, getLoginUserId()); +// final List userAreaDOS = userAreaMapper.selectList(wrapper); +// if (userAreaDOS != null && userAreaDOS.size() > 0) { +// userAreaDOS.forEach(item->{ +// LabelValueVO labelValueVO = new LabelValueVO(); +// final DictDataDO enterprisesArea = dictDataService.getDictData("enterprises_area", item.getArea().toString()); +// labelValueVO.setLabel(enterprisesArea.getLabel()); +// labelValueVO.setValue(Integer.valueOf(item.getArea())); +// labelValueVOS.add(labelValueVO); +// }); +// } + LambdaQueryWrapper enterpriseDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + enterpriseDOLambdaQueryWrapper.eq(EnterpriseDO::getUserId, getLoginUserId()); + final List enterpriseDOS = enterpriseMapper.selectList(enterpriseDOLambdaQueryWrapper); + final List collect = enterpriseDOS.stream().map(item -> item.getRegion()).distinct().collect(Collectors.toList()); + if (collect != null && collect.size() > 0) { + collect.forEach(item->{ + final DictDataDO enterprisesArea = dictDataService.getDictData("enterprises_area", item); + LabelValueVO labelValueVO = new LabelValueVO(); + labelValueVO.setLabel(enterprisesArea.getLabel()); + labelValueVO.setValue(Integer.valueOf(item)); + labelValueVOS.add(labelValueVO); + }); + } + } + return labelValueVOS; + } + + //查企业 public Integer getEnterpriseCount(HomeSelectVO homeSelectVO) { LambdaQueryWrapper enterpriseDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); @@ -213,10 +269,11 @@ public class HomeServiceImpl implements HomeService{ final LocalDateTime[] weekDate = this.getWeekDate(homeSelectVO.getSelectWeek()); enterpriseDOLambdaQueryWrapper.between(EnterpriseDO::getCreateTime, weekDate[0], weekDate[1]); } - enterpriseDOLambdaQueryWrapper.eq(homeSelectVO.getDeptId() != null, EnterpriseDO::getDepartmentId, homeSelectVO.getDeptId()); + enterpriseDOLambdaQueryWrapper.eq(homeSelectVO.getRegion() != null, EnterpriseDO::getRegion, homeSelectVO.getRegion()); final Long enterpriseCount = enterpriseMapper.selectCount(enterpriseDOLambdaQueryWrapper); return enterpriseCount.intValue(); } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java index 89588e5..fae377b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java @@ -5,9 +5,11 @@ import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueV import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageTypeCountVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO; import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO; import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper; +import cn.iocoder.yudao.module.system.service.dict.DictDataService; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -31,6 +33,8 @@ public class NotifyMessageServiceImpl implements NotifyMessageService { @Resource private NotifyMessageMapper notifyMessageMapper; + @Resource + private DictDataService dictDataService; @Override public Long createNotifyMessage(Long userId, Integer userType, @@ -80,7 +84,25 @@ public class NotifyMessageServiceImpl implements NotifyMessageService { @Override public List typeCount() { - return notifyMessageMapper.getTypeList(getLoginUserId()); + List labelValueVOList = new ArrayList<>(); + final List notfyMessageType = dictDataService.getDictDataList(0, "notfy_message_type"); + + notfyMessageType.forEach(item-> { + LabelValueVO labelValueVO = new LabelValueVO(); + labelValueVO.setLabel(item.getValue()); + labelValueVO.setValue(0); + final List typeList = notifyMessageMapper.getTypeList(getLoginUserId()); + if (typeList != null && typeList.size() > 0) { + typeList.forEach(type->{ + if (item.getValue().equals(type.getLabel())){ + labelValueVO.setValue(type.getValue()); + } + }); + } + labelValueVOList.add(labelValueVO); + }); + + return labelValueVOList; } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java index f940e2c..ef2fd84 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/qualification/EnterpriseQualificationServiceImpl.java @@ -1,15 +1,20 @@ package cn.iocoder.yudao.module.system.service.qualification; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; +import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; import cn.iocoder.yudao.module.system.dal.mysql.fileInfo.FileInfoMapper; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseServiceImpl; import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.stream.Collectors; + import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -42,6 +47,8 @@ public class EnterpriseQualificationServiceImpl implements EnterpriseQualificati @Resource private FileInfoService fileInfoService; + @Resource + private EnterpriseMapper enterpriseMapper; @Override public Long createEnterpriseQualification(EnterpriseQualificationSaveReqVO createReqVO) { @@ -96,6 +103,19 @@ public class EnterpriseQualificationServiceImpl implements EnterpriseQualificati @Override public PageResult getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO) { + if (pageReqVO.getEnterpriseName() != null) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.like(EnterpriseDO::getEnterprisesName, pageReqVO.getEnterpriseName()); + List enterpriseDOList = enterpriseMapper.selectList(wrapper); + if (enterpriseDOList != null && enterpriseDOList.size() > 0) { + List enterpriseIdList = enterpriseDOList.stream() + .map(EnterpriseDO::getId) + .collect(Collectors.toList()); + pageReqVO.setEnterpriseIds(enterpriseIdList); + } else { + return PageResult.empty(); + } + } return enterpriseQualificationMapper.selectPage(pageReqVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java index cf8d055..f204f22 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoService.java @@ -68,4 +68,6 @@ public interface TaskInfoService { 任务执行 */ void taskExec(TaskInfoSaveReqVO updateReqVO); + + void test(); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java index 20b683a..2451f76 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java @@ -19,11 +19,13 @@ import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.Enter import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper; import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper; import cn.iocoder.yudao.module.system.dal.mysql.taglibrary.TagLibraryMapper; import cn.iocoder.yudao.module.system.dal.mysql.tasktag.TaskTagMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; +import cn.iocoder.yudao.module.system.dal.mysql.userarea.UserAreaMapper; import cn.iocoder.yudao.module.system.service.auth.AdminAuthService; import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService; @@ -86,6 +88,8 @@ public class TaskInfoServiceImpl implements TaskInfoService { @Resource NotifyMessageSendApi notifyMessageSendApi; + @Resource + private UserAreaMapper userAreaMapper; @Override @Transactional @@ -361,17 +365,18 @@ public class TaskInfoServiceImpl implements TaskInfoService { } //站内信发送通知 -// NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO(); -// notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId())); -// notifyMessage.setTemplateCode("task_messages"); -// Map templateParams = new HashMap<>(); -// templateParams.put("title", taskInfoDO.getTitle()); -// templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); -// templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); -// templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId()); - -// notifyMessage.setTemplateParams(templateParams); -// notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); + NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO(); + notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId())); + notifyMessage.setTemplateCode("task_messages"); + Map templateParams = new HashMap<>(); + templateParams.put("title", taskInfoDO.getTitle()); + templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); + templateParams.put("url", "/sub/task/detail?id="+ enterpriseInspectionsDO.getTaskId()); + + notifyMessage.setTemplateParams(templateParams); + notifyMessageSendApi.sendSingleMessageToMember(notifyMessage); + enterpriseInspectionsDO.setStatus(2); list.add(enterpriseInspectionsDO); @@ -380,4 +385,23 @@ public class TaskInfoServiceImpl implements TaskInfoService { } } + @Override + public void test() { + final List enterpriseDOS = enterpriseMapper.selectList(); + enterpriseDOS.forEach(item->{ + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(UserAreaDO::getArea, item.getRegion()); + wrapper.eq(UserAreaDO::getUserId, item.getUserId()); + final List userAreaDOS = userAreaMapper.selectList(wrapper); + if (userAreaDOS == null || userAreaDOS.size() == 0) { + UserAreaDO userAreaDO = new UserAreaDO(); + final Integer region = Integer.valueOf(item.getRegion()); + userAreaDO.setArea(region); + userAreaDO.setUserId(item.getUserId()); + userAreaMapper.insert(userAreaDO); + } + userAreaMapper.selectList(); + }); + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java index 967e0ba..6197982 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java @@ -185,6 +185,8 @@ public class AdminUserServiceImpl implements AdminUserService { // 2.2 更新岗位 updateUserPost(updateReqVO, updateObj); + //2.3 添加管理区域 todo + // 3. 记录操作日志上下文 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class)); LogRecordContext.putVariable("user", oldUser); @@ -634,6 +636,7 @@ public class AdminUserServiceImpl implements AdminUserService { wrapper.isNotNull(AdminUserDO::getRealName); wrapper.eq(AdminUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus()); wrapper.isNotNull(AdminUserDO::getDeptId); + wrapper.ne(AdminUserDO::getId, 1); final List adminUserDOS = userMapper.selectList(wrapper); adminUserDOS.forEach(item->{ @@ -641,7 +644,9 @@ public class AdminUserServiceImpl implements AdminUserService { deptUserReqVO.setId(item.getId()); deptUserReqVO.setRealName(item.getRealName()); final DeptDO dept = deptService.getDept(item.getDeptId()); - deptUserReqVO.setDeptName(dept.getName()); + if (dept != null) { + deptUserReqVO.setDeptName(dept.getName()); + } list.add(deptUserReqVO); }); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaService.java new file mode 100644 index 0000000..d1bc44c --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaService.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.system.service.userarea; + +import java.util.*; +import cn.iocoder.yudao.module.system.controller.admin.userarea.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +import javax.validation.Valid; + +/** + * 用户区域关联 Service 接口 + * + * @author 芋道源码 + */ +public interface UserAreaService { + + /** + * 创建用户区域关联 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createUserArea(@Valid UserAreaSaveReqVO createReqVO); + + /** + * 更新用户区域关联 + * + * @param updateReqVO 更新信息 + */ + void updateUserArea(@Valid UserAreaSaveReqVO updateReqVO); + + /** + * 删除用户区域关联 + * + * @param id 编号 + */ + void deleteUserArea(Long id); + + /** + * 获得用户区域关联 + * + * @param id 编号 + * @return 用户区域关联 + */ + UserAreaDO getUserArea(Long id); + + /** + * 获得用户区域关联分页 + * + * @param pageReqVO 分页查询 + * @return 用户区域关联分页 + */ + PageResult getUserAreaPage(UserAreaPageReqVO pageReqVO); + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaServiceImpl.java new file mode 100644 index 0000000..489ab7e --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/userarea/UserAreaServiceImpl.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.system.service.userarea; + +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; +import cn.iocoder.yudao.module.system.controller.admin.userarea.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.userarea.UserAreaDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + +import cn.iocoder.yudao.module.system.dal.mysql.userarea.UserAreaMapper; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; + +/** + * 用户区域关联 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class UserAreaServiceImpl implements UserAreaService { + + @Resource + private UserAreaMapper userAreaMapper; + + @Override + public Long createUserArea(UserAreaSaveReqVO createReqVO) { + // 插入 + UserAreaDO userArea = BeanUtils.toBean(createReqVO, UserAreaDO.class); + userAreaMapper.insert(userArea); + // 返回 + return userArea.getId(); + } + + @Override + public void updateUserArea(UserAreaSaveReqVO updateReqVO) { + // 校验存在 + validateUserAreaExists(updateReqVO.getId()); + // 更新 + UserAreaDO updateObj = BeanUtils.toBean(updateReqVO, UserAreaDO.class); + userAreaMapper.updateById(updateObj); + } + + @Override + public void deleteUserArea(Long id) { + // 校验存在 + validateUserAreaExists(id); + // 删除 + userAreaMapper.deleteById(id); + } + + private void validateUserAreaExists(Long id) { + if (userAreaMapper.selectById(id) == null) { + throw exception(USER_NOT_EXISTS); + } + } + + @Override + public UserAreaDO getUserArea(Long id) { + return userAreaMapper.selectById(id); + } + + @Override + public PageResult getUserAreaPage(UserAreaPageReqVO pageReqVO) { + return userAreaMapper.selectPage(pageReqVO); + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml index 521f0e7..35e92ac 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterprise/EnterpriseMapper.xml @@ -19,16 +19,19 @@ where e.deleted = 0 - and region = #{params.region} + and e.region = #{params.region} - and user_id = #{params.userId} + and e.user_id = #{params.userId} + + + and e.is_audit = #{params.isAudit} - and department_id = #{params.departmentId} + and e.department_id = #{params.departmentId} - and enterprises_name like '%${params.enterprisesName}%' + and e.enterprises_name like '%${params.enterprisesName}%' and tl.id in diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterpriseinspections/EnterpriseInspections.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterpriseinspections/EnterpriseInspections.xml index af9ce93..1ed17ad 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterpriseinspections/EnterpriseInspections.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/enterpriseinspections/EnterpriseInspections.xml @@ -13,7 +13,7 @@ diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml index 1d8ddee..3eecfb8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/taskinfo/TaskInfoMapper.xml @@ -56,12 +56,7 @@