From 804779aa14200bbb52ad9ee55ce2b653f723fdd4 Mon Sep 17 00:00:00 2001 From: dx <1242347652@qq.com> Date: Fri, 30 May 2025 10:24:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/api/file/dto/InfraFileInfoDTO.java | 1 + .../controller/admin/file/FileController.java | 25 ++ .../infra/service/file/FileServiceImpl.java | 1 + .../system/enums/DictTypeConstants.java | 27 ++ .../system/enums/ErrorCodeConstants.java | 5 + .../QualityCollectionController.java | 44 ++- .../vo/QualityCollectionExcelVO.java | 5 +- .../vo/QualityCollectionPageReqVO.java | 11 +- .../vo/QualityCollectionRespVO.java | 4 +- .../controller/admin/auth/AuthController.java | 5 + .../bigviewdata/BigViewDataController.java | 26 +- .../bigviewdata/vo/BigViewCenterDataVO.java | 16 + .../admin/bigviewdata/vo/LeftFirstDataVO.java | 10 + .../admin/bigviewdata/vo/LeftThirdDataVO.java | 11 + .../bigviewdata/vo/MonthTaskInspectionVO.java | 13 + .../admin/bigviewdata/vo/ReginCountVO.java | 21 ++ .../bigviewdata/vo/RightThirdDataVO.java | 9 + .../admin/bigviewdata/vo/TaskCountVO.java | 9 + .../enterprise/EnterpriseController.java | 92 ++++- .../enterprise/vo/EnterpriseExportVO.java | 32 ++ .../enterprise/vo/EnterprisePageReqVO.java | 4 +- .../enterprise/vo/EnterpriseSaveReqVO.java | 1 - .../EnterpriseInspectionsController.java | 13 +- .../vo/InspectionByEnterpriseIdRespVO.java | 16 + .../vo/InspectionByEnterpriseIdVO.java | 15 + .../admin/fileInfo/FileInfoController.java | 9 + .../admin/home/vo/HomeCountResVO.java | 1 + .../InspectionsLogController.java | 4 +- .../EnterpriseQualificationController.java | 14 +- .../vo/EnterpriseQualificationPageReqVO.java | 1 - .../vo/EnterpriseQualificationRespVO.java | 3 + .../admin/taskinfo/TaskInfoController.java | 131 +++++-- .../taskinfo/vo/TaskInfoRespExcelVO.java | 44 +++ .../admin/taskinfo/vo/TaskInfoRespVO.java | 10 +- .../admin/taskinfo/vo/TaskInfoSaveReqVO.java | 3 + .../controller/admin/user/UserController.java | 39 +- .../admin/user/vo/user/UserDeptVO.java | 2 +- .../admin/user/vo/user/UserExportVO.java | 49 +++ .../admin/user/vo/user/UserPageReqVO.java | 2 +- .../admin/user/vo/user/UserRespVO.java | 7 + .../admin/user/vo/user/UserSaveReqVO.java | 11 + .../convert/enterprise/EnterpriseConvert.java | 37 ++ .../convert/taskInfo/TaskInfoConvert.java | 34 ++ .../system/convert/user/UserConvert.java | 36 ++ .../QualityCollectionDO.java | 2 + .../dataobject/enterprise/EnterpriseDO.java | 3 + .../dal/dataobject/taskinfo/TaskInfoDO.java | 4 +- .../dal/dataobject/user/AdminUserDO.java | 10 +- .../QualityCollectionMapper.java | 21 +- .../mysql/bigviewdata/BigViewDataMapper.java | 19 +- .../mysql/enterprise/EnterpriseMapper.java | 1 - .../EnterpriseInspectionsMapper.java | 7 + .../dal/mysql/permission/UserRoleMapper.java | 2 + .../dal/mysql/user/AdminUserMapper.java | 2 + .../job/InspectionsSendStartMessageJob.java | 4 +- ...alificationTimeOutSendStartMessageJob.java | 8 +- .../system/job/TaskSendStartMessageJob.java | 6 +- .../QualityCollectionService.java | 4 +- .../QualityCollectionServiceImpl.java | 131 ++++++- .../service/auth/AdminAuthServiceImpl.java | 34 +- .../bigviewdata/BigViewDataService.java | 20 +- .../bigviewdata/BigViewDataServiceImpl.java | 336 +++++++++++++++--- .../system/service/dept/DeptServiceImpl.java | 10 + .../enterprise/EnterpriseServiceImpl.java | 54 +-- .../EnterpriseInspectionsService.java | 2 + .../EnterpriseInspectionsServiceImpl.java | 54 ++- .../service/fileInfo/FileInfoService.java | 3 + .../service/fileInfo/FileInfoServiceImpl.java | 11 + .../service/permission/PermissionService.java | 12 +- .../permission/PermissionServiceImpl.java | 14 + .../service/permission/RoleServiceImpl.java | 15 + .../service/taskinfo/TaskInfoService.java | 4 + .../service/taskinfo/TaskInfoServiceImpl.java | 129 ++++++- .../service/user/AdminUserServiceImpl.java | 5 + .../mapper/bigviewdata/BigViewDataMapper.xml | 226 ++++++++---- .../EnterpriseInspections.xml | 17 + .../mapper/taskinfo/TaskInfoMapper.xml | 3 - .../src/main/resources/application-local.yaml | 4 +- 78 files changed, 1716 insertions(+), 314 deletions(-) create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/BigViewCenterDataVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftFirstDataVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftThirdDataVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/MonthTaskInspectionVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/ReginCountVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/RightThirdDataVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/TaskCountVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseExportVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdRespVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespExcelVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserExportVO.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/enterprise/EnterpriseConvert.java create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/taskInfo/TaskInfoConvert.java diff --git a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java index 5edd6b2..e036f64 100644 --- a/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java +++ b/yudao-module-infra/yudao-module-infra-api/src/main/java/cn/iocoder/yudao/module/infra/api/file/dto/InfraFileInfoDTO.java @@ -6,4 +6,5 @@ import lombok.Data; public class InfraFileInfoDTO { private String url; private Long id; + private String name; } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java index 6e62fb0..6aedd74 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/file/FileController.java @@ -26,6 +26,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -49,6 +52,28 @@ public class FileController { return success(fileService.createFile(file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream()))); } + @PostMapping("/uploads") + @Operation(summary = "多文件上传", description = "模式一:后端上传文件") + public CommonResult> uploadFiles(@RequestPart("files") MultipartFile[] files, + @RequestParam(required = false) String path) throws Exception { + // 参数校验 + if (files == null || files.length == 0) { + throw new IllegalArgumentException("至少需要上传一个文件"); + } + + List result = new ArrayList<>(); + for (MultipartFile file : files) { + if (!file.isEmpty()) { + result.add(fileService.createFile( + file.getOriginalFilename(), + path, + IoUtil.readBytes(file.getInputStream()) + )); + } + } + return success(result); + } + @GetMapping("/presigned-url") @Operation(summary = "获取文件预签名地址", description = "模式二:前端上传文件:用于前端直接上传七牛、阿里云 OSS 等文件存储器") public CommonResult getFilePresignedUrl(@RequestParam("path") String path) throws Exception { diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java index a25883e..928144f 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/file/FileServiceImpl.java @@ -135,6 +135,7 @@ public class FileServiceImpl implements FileService { InfraFileInfoDTO map = new InfraFileInfoDTO(); map.setId(fileDO.getId()); map.setUrl(fileDO.getUrl()); + map.setName(fileDO.getName()); return map; }).collect(Collectors.toList()); } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java index d7592c3..90f90ea 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/DictTypeConstants.java @@ -23,4 +23,31 @@ public interface DictTypeConstants { String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态 String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态 + String TASK_STATE = "task_state"; // 短信接收类型 + + String SYSTEM_USER_SEX = "system_user_sex"; + String SYSTEM_MENU_TYPE = "system_menu_type"; + String SYSTEM_ROLE_TYPE = "system_role_type"; + String SYSTEM_DATA_SCOPE = "system_data_scope"; + String SYSTEM_NOTICE_TYPE = "system_notice_type"; + String SYSTEM_LOGIN_TYPE = "system_login_type"; + String SYSTEM_LOGIN_RESULT = "system_login_result"; + String SYSTEM_SMS_CHANNEL_CODE = "system_sms_channel_code"; + String SYSTEM_SMS_TEMPLATE_TYPE = "system_sms_template_type"; + String SYSTEM_SMS_SEND_STATUS = "system_sms_send_status"; + String SYSTEM_SMS_RECEIVE_STATUS = "system_sms_receive_status"; + String SYSTEM_OAUTH2_GRANT_TYPE = "system_oauth2_grant_type"; + String SYSTEM_MAIL_SEND_STATUS = "system_mail_send_status"; + String SYSTEM_NOTIFY_TEMPLATE_TYPE = "system_notify_template_type"; + String SYSTEM_SOCIAL_TYPE = "system_social_type"; + String USER_AUDIT_TYPE = "user_audit_type"; + String WX_USER_TYPE = "wx_user_type"; + String TAG_TYPE = "tag_type"; + String TASK_TYPE_EXCEL = "task_type_excel"; + String TASK_TYPE_PARENT = "task_type_parent"; + String TASK_PRIORITY = "task_priority"; + String TASK_EXEC_TIME = "task_exec_time"; + String INSPECTIONS_STATUS = "Inspections_status"; + String AIR_COLLECTION_TYPE = "air_collection_type"; + String ENTERPRISE_AREA = "enterprises_area"; } diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 5b63f7e..b4c1901 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -32,6 +32,7 @@ public interface ErrorCodeConstants { ErrorCode ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE = new ErrorCode(1_002_002_003, "不能操作类型为系统内置的角色"); ErrorCode ROLE_IS_DISABLE = new ErrorCode(1_002_002_004, "名字为【{}】的角色已被禁用"); ErrorCode ROLE_ADMIN_CODE_ERROR = new ErrorCode(1_002_002_005, "标识【{}】不能使用"); + ErrorCode ROLE_USER_CODE_ERROR = new ErrorCode(1_002_002_006, "先删除角色下用户"); // ========== 用户模块 1-002-003-000 ========== ErrorCode USER_USERNAME_EXISTS = new ErrorCode(1_002_003_000, "用户账号已经存在"); @@ -43,6 +44,8 @@ public interface ErrorCodeConstants { ErrorCode USER_IS_DISABLE = new ErrorCode(1_002_003_006, "名字为【{}】的用户已被禁用"); ErrorCode USER_COUNT_MAX = new ErrorCode(1_002_003_008, "创建用户失败,原因:超过租户最大租户配额({})!"); ErrorCode USER_IMPORT_INIT_PASSWORD = new ErrorCode(1_002_003_009, "初始密码不能为空"); + ErrorCode DEPT_USER_ERROR = new ErrorCode(1_002_004_008, "不能删除,部门下有用户"); + ErrorCode USER_LOGIN_ERROR = new ErrorCode(1_002_004_009, "不是局内用户,或审核未通过"); // ========== 部门模块 1-002-004-000 ========== ErrorCode DEPT_NAME_DUPLICATE = new ErrorCode(1_002_004_000, "已经存在该名字的部门"); @@ -123,6 +126,8 @@ public interface ErrorCodeConstants { ErrorCode SOCIAL_CLIENT_WEIXIN_MINI_APP_SUBSCRIBE_MESSAGE_ERROR = new ErrorCode(1_002_018_203, "发送小程序订阅消息失败"); ErrorCode SOCIAL_CLIENT_NOT_EXISTS = new ErrorCode(1_002_018_210, "社交客户端不存在"); ErrorCode SOCIAL_CLIENT_UNIQUE = new ErrorCode(1_002_018_211, "社交客户端已存在配置"); + ErrorCode SOCIAL_CLIENT_CODE_EXISTS = new ErrorCode(1_002_018_212, "社交客户端CODE不存在"); + // ========== OAuth2 客户端 1-002-020-000 ========= 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 5ade7f8..4f44a70 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.controller.admin.airqualitycollection; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.exception.ExcelDataConvertException; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; @@ -16,6 +17,8 @@ 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.error; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -33,6 +36,11 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; @Tag(name = "管理后台 - 空气质量采集") + + + + + @RestController @RequestMapping("/system/quality-collection") @Validated @@ -83,6 +91,13 @@ public class QualityCollectionController { return success(BeanUtils.toBean(pageResult, QualityCollectionRespVO.class)); } + @GetMapping("/latest") + @Operation(summary = "最新一条数据") + public CommonResult latest() { + QualityCollectionDO qualityCollectionDO = qualityCollectionService.latest(); + return success(BeanUtils.toBean(qualityCollectionDO, QualityCollectionRespVO.class)); + } + @GetMapping("/export-excel") @Operation(summary = "导出空气质量采集 Excel") @PreAuthorize("@ss.hasPermission('system:quality-collection:export')") @@ -99,15 +114,28 @@ public class QualityCollectionController { @PostMapping("/upload-excel") @Operation(summary = "导入空气质量采集 Excel") // @PreAuthorize("@ss.hasPermission('system:quality-collection:upload')") - public void uploadExcel(@RequestParam("file") MultipartFile file, @RequestParam("type") Long type) throws IOException { + public CommonResult uploadExcel(@RequestParam("file") MultipartFile file) throws IOException { // 2. 使用 EasyExcel 读取(替换 ExcelUtils) - List list = EasyExcel.read(file.getInputStream()) - .head(QualityCollectionExcelVO.class) - .sheet() - .doReadSync(); - - // 3. 打印读取结果 - qualityCollectionService.saveList(list, type); + try { + List list = EasyExcel.read(file.getInputStream()) + .head(QualityCollectionExcelVO.class) + .sheet() + .doReadSync(); + // 3. 打印读取结果 + qualityCollectionService.saveList(list); + } catch (ExcelDataConvertException e) { + System.err.println("数据转换失败:行" + (e.getRowIndex()+1) + + "列" + (e.getColumnIndex()+1) + + " - " + e.getCellData().getStringValue()); + String message = "数据转换失败:行" + (e.getRowIndex()+1) + + "列" + (e.getColumnIndex()+1) + + " - " + e.getCellData().getStringValue(); + return error(0, message); + } + + + + return success("上传成功"); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionExcelVO.java index 94ecd28..81d34be 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionExcelVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionExcelVO.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.system.controller.admin.airqualitycollection.vo; import com.alibaba.excel.annotation.ExcelProperty; -import com.thoughtworks.xstream.converters.time.LocalDateTimeConverter; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.experimental.Accessors; @@ -21,7 +20,7 @@ public class QualityCollectionExcelVO { private String siteName; @ExcelProperty(value = "时间", index = 3) - private LocalDateTime time; + private String time; @ExcelProperty(value = "PM2.s(ugim3)", index = 4) private String pm25; @@ -39,7 +38,7 @@ public class QualityCollectionExcelVO { private String no; @ExcelProperty(value = "NOx(μg/m3)", index = 9) - private String nOx; + private String nox; @ExcelProperty(value = "CO(mg/m3)", index = 10) private String co; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionPageReqVO.java index e0d7e1c..c2543c6 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionPageReqVO.java @@ -21,8 +21,11 @@ public class QualityCollectionPageReqVO extends PageParam { @Schema(description = "城市") private String city; + @Schema(description = "时间") + private String[] times; + @Schema(description = "数据类型", example = "2") - private Long type; + private Integer type; @Schema(description = "PM2.s(ugim3)") private Double pm25; @@ -39,8 +42,8 @@ public class QualityCollectionPageReqVO extends PageParam { @Schema(description = "NO(Hg/m3)") private Double no; - @Schema(description = "NOx(Hg/m3)") - private Double nOx; + @Schema(description = "NOx(μg/m3)") + private Double nox; @Schema(description = "CO(mg/m3)") private Double co; @@ -58,4 +61,4 @@ public class QualityCollectionPageReqVO extends PageParam { @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/airqualitycollection/vo/QualityCollectionRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionRespVO.java index 2b381b0..0c6f59f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/airqualitycollection/vo/QualityCollectionRespVO.java @@ -52,7 +52,7 @@ public class QualityCollectionRespVO { @Schema(description = "NOx(μg/m3)") @ExcelProperty("NOx(μg/m3)") - private Double nOx; + private Double nox; @Schema(description = "CO(mg/m3)") @ExcelProperty("CO(mg/m3)") @@ -64,7 +64,7 @@ public class QualityCollectionRespVO { @Schema(description = "时间") @ExcelProperty("时间") - private LocalDateTime time; + private String time; @Schema(description = "备用1", example = "你猜") private String remark; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java index 0ddec39..1b23d4f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java @@ -252,12 +252,17 @@ public class AuthController { //判断是否为对象空 if(StrUtil.isNotEmpty(json)){ SocialUserDO socialUserDO = JsonUtils.parseObject(json, SocialUserDO.class); + AuthSocialLoginReqVO authSocialLoginReqVO=new AuthSocialLoginReqVO(); authSocialLoginReqVO.setCode(socialUserDO.getCode()); authSocialLoginReqVO.setType(socialUserDO.getType()); authSocialLoginReqVO.setState(socialUserDO.getState()); authSocialLoginReqVO.setOpenid(socialUserDO.getOpenid()); AuthLoginRespVO authLoginRespVO = authService.socialLogin(authSocialLoginReqVO); + + //TODO 判断用户类型和审核状态 内部用户并且已经审核通过的用户才能登录 + + if(ObjUtil.isNotEmpty(authLoginRespVO)){ stringRedisTemplate.delete(reqVO.getCode()); return success(authLoginRespVO); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/BigViewDataController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/BigViewDataController.java index 419e0da..63125eb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/BigViewDataController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/BigViewDataController.java @@ -1,7 +1,8 @@ package cn.iocoder.yudao.module.system.controller.admin.bigviewdata; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewGroupCountCompareVO; +import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.*; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueLongVO; 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; @@ -19,9 +20,6 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewEnterpriseCountGroup; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.StatusCountVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeGroupCountVO; import cn.iocoder.yudao.module.system.service.bigviewdata.BigViewDataService; @@ -37,31 +35,37 @@ public class BigViewDataController { @GetMapping("/getLeftFirst") @Operation(summary = "大屏左一数据") - public CommonResult> leftFirst(HomeSelectVO homeSelectVO) { + public CommonResult> leftFirst(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getLeftFirst(homeSelectVO)); } @GetMapping("/getLeftSecond") @Operation(summary = "大屏左二数据") - public CommonResult getLeftSecond(HomeSelectVO homeSelectVO) { + public CommonResult> getLeftSecond(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getLeftSecond(homeSelectVO)); } @GetMapping("/getLeftThird") @Operation(summary = "大屏左三数据") - public CommonResult> getLeftThird(HomeSelectVO homeSelectVO) { + public CommonResult> getLeftThird(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getLeftThird(homeSelectVO)); } @GetMapping("/getCenter") @Operation(summary = "大屏中间总数统计") - public CommonResult getCenter(HomeSelectVO homeSelectVO) { + public CommonResult getCenter(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getCenter(homeSelectVO)); } + @GetMapping("/getMapData") + @Operation(summary = "大屏中间总数统计") + public CommonResult> getMapData(HomeSelectVO homeSelectVO) { + return success(bigViewDataService.getMapData(homeSelectVO)); + } + @GetMapping("/getRightFirst") @Operation(summary = "大屏右一数据") - public CommonResult> getRightFist(HomeSelectVO homeSelectVO) { + public CommonResult> getRightFist(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getRightFist(homeSelectVO)); } @@ -73,7 +77,7 @@ public class BigViewDataController { @GetMapping("/getRightThird") @Operation(summary = "大屏右三数据") - public CommonResult> getRightThird(HomeSelectVO homeSelectVO) { + public CommonResult> getRightThird(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getRightThird(homeSelectVO)); } @@ -82,5 +86,5 @@ public class BigViewDataController { public CommonResult> getRightFourth(HomeSelectVO homeSelectVO) { return success(bigViewDataService.getRightFourth(homeSelectVO)); } - + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/BigViewCenterDataVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/BigViewCenterDataVO.java new file mode 100644 index 0000000..da6c640 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/BigViewCenterDataVO.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeListVO; +import lombok.Data; + +import java.util.List; + +@Data +public class BigViewCenterDataVO { + + private Long taskCount; + private Long inspectionsCount; + private Long enterpriseCount; + + List reginCountVOList; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftFirstDataVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftFirstDataVO.java new file mode 100644 index 0000000..3978f54 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftFirstDataVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class LeftFirstDataVO { + private String name; + private Long taskCount; + private Long enterpriseCount; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftThirdDataVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftThirdDataVO.java new file mode 100644 index 0000000..875375f --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/LeftThirdDataVO.java @@ -0,0 +1,11 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class LeftThirdDataVO { + private String name; + private double value; + private Long taskCount; + private Long enterpriseCount; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/MonthTaskInspectionVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/MonthTaskInspectionVO.java new file mode 100644 index 0000000..74b13da --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/MonthTaskInspectionVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class MonthTaskInspectionVO { + //月份 + private String name; + //任务数量 + private Long taskCount; + //执法数量 + private Long inspectionsCount; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/ReginCountVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/ReginCountVO.java new file mode 100644 index 0000000..b9c29c6 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/ReginCountVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class ReginCountVO { + //区域名称 + private String name; + //区域经纬度 + private String location; + //企业数量占比 + private Long enterpriseRate; + //任务数量占比 + private Long taskRate; + //企业数量 + private Long enterpriseCount; + //任务数量 + private Long taskCount; + + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/RightThirdDataVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/RightThirdDataVO.java new file mode 100644 index 0000000..3b56fee --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/RightThirdDataVO.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class RightThirdDataVO { + private String name; + private String expiryDate; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/TaskCountVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/TaskCountVO.java new file mode 100644 index 0000000..3fdce07 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/bigviewdata/vo/TaskCountVO.java @@ -0,0 +1,9 @@ +package cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo; + +import lombok.Data; + +@Data +public class TaskCountVO { + private Integer region; + private Long taskCount; +} 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 fa0c432..3d2c185 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 @@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.controller.admin.qualification.vo.EnterpriseQualificationRespVO; import cn.iocoder.yudao.module.system.controller.admin.taglibrary.vo.TagLibraryPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.taglibrary.vo.TagLibraryRespVO; +import cn.iocoder.yudao.module.system.convert.enterprise.EnterpriseConvert; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseauditlog.EnterpriseAuditLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprisetag.EnterpriseTagDO; @@ -78,8 +79,6 @@ public class EnterpriseController { @Resource private EnterpriseQualificationMapper enterpriseQualificationMapper; @Resource - private EnterpriseAuditLogMapper enterpriseAuditLogMapper; - @Resource private AdminUserService adminUserService; @Resource private TagLibraryService tagLibraryService; @@ -90,21 +89,18 @@ public class EnterpriseController { @PostMapping("/create") @Operation(summary = "创建企业") -// @PreAuthorize("@ss.hasPermission('system:enterprise:create')") public CommonResult createEnterprise(@RequestBody EnterpriseSaveReqVO createReqVO) { return success(enterpriseService.createEnterprise(createReqVO)); } @PostMapping("/pccreate") @Operation(summary = "PC端创建企业") -// @PreAuthorize("@ss.hasPermission('system:enterprise:create')") public CommonResult pccreateEnterprise(@RequestBody EnterpriseSaveReqVO createReqVO) { return success(enterpriseService.pccreateEnterprise(createReqVO)); } @PutMapping("/update") @Operation(summary = "更新企业") -// @PreAuthorize("@ss.hasPermission('system:enterprise:update')") public CommonResult updateEnterprise(@Valid @RequestBody EnterpriseSaveReqVO updateReqVO) { enterpriseService.updateEnterprise(updateReqVO); return success(true); @@ -112,7 +108,6 @@ public class EnterpriseController { @PutMapping("/audit") @Operation(summary = "企业审核") -// @PreAuthorize("@ss.hasPermission('system:enterprise:update')") public CommonResult audit(@RequestParam("id") Long id) { enterpriseService.auditEnterprise(id); return success(true); @@ -127,10 +122,49 @@ public class EnterpriseController { return success(true); } + @GetMapping("/pcget") + @Operation(summary = "获得企业") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public CommonResult getEnterpriseofPC(@RequestParam("id") Long id) { + EnterpriseDO bean = enterpriseService.getEnterprise(id); + EnterpriseRespVO enterprise= BeanUtils.toBean(bean, EnterpriseRespVO.class); + if (enterprise != null) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(FileInfoDO::getDictType, EnterpriseServiceImpl.DEFAULT_DICT_TYPE); + wrapper.eq(FileInfoDO::getDictData, EnterpriseServiceImpl.DEFAULT_DICT_DATA_QY); + wrapper.eq(FileInfoDO::getUnitId, enterprise.getId()); + final List collect = fileInfoMapper.selectList(wrapper).stream().map(res -> res.getInfraFileId()).collect(Collectors.toList()); + + if (!collect.isEmpty()) { + final List list = fileApi.listFile(collect); + enterprise.setFiles(list); + } + + // 获取标签 + List tagLibraryDOS = tagLibraryService.listByEnterpriseId(enterprise.getId()); + if (tagLibraryDOS != null) { + List tagLibraryDOS1 = tagLibraryService.listSetParentId(tagLibraryDOS); + enterprise.setTagObjList(tagLibraryDOS1); + } else { + // 处理 tagLibraryDOS 为 null 的情况,这里可以设置一个空列表 + enterprise.setTagObjList(Collections.emptyList()); + } + + //通过userID获取专管人 + if (enterprise.getUserId() != null) { + final AdminUserDO user = adminUserService.getUser(Long.valueOf(enterprise.getUserId())); + if (user != null) { + enterprise.setInviterName(user.getRealName()); + } + } + } + + return success(enterprise); + } + @GetMapping("/get") @Operation(summary = "获得企业") @Parameter(name = "id", description = "编号", required = true, example = "1024") -// @PreAuthorize("@ss.hasPermission('system:enterprise:query')") public CommonResult getEnterprise(@RequestParam("id") Long id) { EnterpriseDO bean = enterpriseService.getEnterprise(id); EnterpriseRespVO enterprise= BeanUtils.toBean(bean, EnterpriseRespVO.class); @@ -299,7 +333,6 @@ public class EnterpriseController { labelValueVO.setLabel(tag.getTagName()); labelValueVO.setValue(tag.getParentId()); labelValueVOList.add(labelValueVO); - }); item.setTagListName(labelValueVOList); @@ -319,10 +352,47 @@ public class EnterpriseController { public void exportEnterpriseExcel(@Valid EnterprisePageReqVO pageReqVO, HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = enterpriseService.getEnterprisePage(pageReqVO).getList(); + PageResult pageResult = enterpriseService.getEnterprisePage(pageReqVO); + pageResult.getList().forEach(item->{ + final AdminUserDO user = adminUserService.getUser(Long.valueOf(item.getUserId())); + if (user != null) { + item.setInviterName(user.getRealName()); + if (user.getDeptId() != null) { + final DeptDO dept = deptService.getDept(user.getDeptId()); + if (dept!= null) { + item.setInviterNameDept(dept.getName()); + } + } + } + + final List tagLibraryDOS = tagLibraryService.listByEnterpriseId(item.getId()); + if (tagLibraryDOS != null) { + List labelValueVOList = new ArrayList<>(); + tagLibraryDOS.forEach(tag->{ + LabelValueVO labelValueVO = new LabelValueVO(); + labelValueVO.setLabel(tag.getTagName()); + labelValueVO.setValue(tag.getParentId()); + labelValueVOList.add(labelValueVO); + }); + + item.setTagListName(labelValueVOList); + } + + }); + + if (pageReqVO.getCreateDeptId() != null) { + //查出改部门下所有用户 + List deptIds = new ArrayList<>(); + deptIds.add(pageReqVO.getCreateDeptId()); + final List userList = adminUserService.getUserListByDeptIds(deptIds); + if (userList!= null && userList.size() > 0) { + List collect = userList.stream().map(item1 -> item1.getId()).collect(Collectors.toList()); + final List collect1 = pageResult.getList().stream().filter(item -> collect.contains(item.getCreator())).collect(Collectors.toList()); + } + } // 导出 Excel - ExcelUtils.write(response, "企业.xls", "数据", EnterpriseRespVO.class, - BeanUtils.toBean(list, EnterpriseRespVO.class)); + ExcelUtils.write(response, "企业.xls", "数据", EnterpriseExportVO.class, + EnterpriseConvert.INSTANCE.convertList(pageResult.getList())); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseExportVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseExportVO.java new file mode 100644 index 0000000..daedb3d --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseExportVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterprise.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class EnterpriseExportVO { + @Schema(description = "企业名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三") + @ExcelProperty("企业名称") + private String enterprisesName; + + @Schema(description = "企业所属区域", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "企业所属区域", converter = DictConvert.class) + @DictFormat(DictTypeConstants.ENTERPRISE_AREA) + private String region; + + @ExcelProperty(value = "行业类型") + private String type; + + @Schema(description = "执法人员") + @ExcelProperty("执法人员") + private String inviterDeptAndName; + + @Schema(description = "入驻时间") + @ExcelProperty("入驻时间") + private String time; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java index 13eafec..cdb9c3f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterprisePageReqVO.java @@ -27,8 +27,8 @@ public class EnterprisePageReqVO extends PageParam { @Schema(description = "管辖人员ID", example = "30445") private Long userId; - @Schema(description = "企业类型:1.大型、2.中型、3.小型、4.环保重点", example = "2") - private String type; + @Schema(description = "企业类型", example = "2") + private Long[] type; @Schema(description = "是否已审核") private Boolean isAudit; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java index f803cbd..10c5f42 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterprise/vo/EnterpriseSaveReqVO.java @@ -43,7 +43,6 @@ public class EnterpriseSaveReqVO { @Schema(description = "企业状态") private Long enterprisesStatus; - @Schema(description = "环保负责人姓名", example = "张三") private String contactName; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java index 83c6645..f50d3f8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/EnterpriseInspectionsController.java @@ -81,7 +81,7 @@ public class EnterpriseInspectionsController { @GetMapping("/get") @Operation(summary = "获得企业检查记录表,用于记录与企业相关的环保检查信息。") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") +// @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") public CommonResult getEnterpriseInspections(@RequestParam("id") Long id) { return success(enterpriseInspectionsService.getEnterpriseInspections(id)); } @@ -89,7 +89,7 @@ public class EnterpriseInspectionsController { @GetMapping("/getEnterpriseInspectionsByTaskId") @Operation(summary = "根据任务id查询自己偶发") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") +// @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") public CommonResult getEnterpriseInspectionsByTaskId(@RequestParam("id") Long id) { return success(enterpriseInspectionsService.getEnterpriseInspections(id)); } @@ -102,6 +102,15 @@ public class EnterpriseInspectionsController { return success(BeanUtils.toBean(pageResult, EnterpriseInspectionsRespVO.class)); } + + @GetMapping("/inspectionsByEnterpriseId") + @Operation(summary = "获得企业检查记录表,用于记录与企业相关的环保检查信息。分页") +// @PreAuthorize("@ss.hasPermission('system:enterprise-inspections:query')") + public CommonResult> inspectionsByEnterpriseId(@Valid EnterpriseInspectionsPageReqVO pageReqVO) { + return success(enterpriseInspectionsService.inspectionsByEnterpriseId(pageReqVO)); + } + + //listByUserIdAndTaskName @GetMapping("/getListByUserIdAndTaskName") @Operation(summary = "PC端获得企业检查记录表,用于记录与企业相关的环保检查信息。分页") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdRespVO.java new file mode 100644 index 0000000..1aa7bd8 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdRespVO.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class InspectionByEnterpriseIdRespVO { + private Long taskId; + private String title; + private String inspectNames; + private Integer status; + private LocalDateTime time; + private Long inspectionsId; +} + diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdVO.java new file mode 100644 index 0000000..7eb15e4 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/enterpriseinspections/vo/InspectionByEnterpriseIdVO.java @@ -0,0 +1,15 @@ +package cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo; + +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class InspectionByEnterpriseIdVO { + private Long taskId; + private String title; + private Long inspectionsId; + private Long logId; + private Integer status; + private LocalDateTime createTime; +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java index 075c8c2..c49f758 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/fileInfo/FileInfoController.java @@ -62,6 +62,15 @@ public class FileInfoController { return success(true); } + @DeleteMapping("/deleteByInfraId") + @Operation(summary = "删除附件信息") + @Parameter(name = "id", description = "编号", required = true) +// @PreAuthorize("@ss.hasPermission('system:file-info:delete')") + public CommonResult deleteByInfraId(@RequestParam("id") Long id) throws Exception { + fileInfoService.deleteByInfraId(id); + return success(true); + } + @GetMapping("/get") @Operation(summary = "获得附件信息") @Parameter(name = "id", description = "编号", required = true, example = "1024") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java index 4a8374c..374f5d9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/home/vo/HomeCountResVO.java @@ -11,6 +11,7 @@ public class HomeCountResVO { private Integer taskCount; //执法总数 private Integer inspectionsCount; + //企业总数 private Integer enterpriseCount; //总任务完成率 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java index a3fb588..9f937e6 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/inspectionslog/InspectionsLogController.java @@ -101,7 +101,7 @@ public class InspectionsLogController { @PostMapping("/inspectionsAudit") @Operation(summary = "审核") - @PreAuthorize("@ss.hasPermission('system:enterpriseinspections:index')") +// @PreAuthorize("@ss.hasPermission('system:enterpriseinspections:index')") public CommonResult inspectionsAudit(@Valid @RequestBody InspectionsLogSaveReqVO createReqVO) { log.info("createReqVO:{}", createReqVO); inspectionsLogService.inspectionsAudit(createReqVO); @@ -125,7 +125,7 @@ public class InspectionsLogController { @GetMapping("/list") @Operation(summary = "pc端获得检查状态列表") - @PreAuthorize("@ss.hasPermission('system:inspections-log:query')") +// @PreAuthorize("@ss.hasPermission('system:inspections-log:query')") public CommonResult> getInspectionsLogList(@Valid InspectionsLogPageReqVO pageReqVO) { List list = inspectionsLogService.list(pageReqVO); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java index 7524bf2..b1f50a4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/EnterpriseQualificationController.java @@ -84,6 +84,12 @@ public class EnterpriseQualificationController { public CommonResult getEnterpriseQualification(@RequestParam("id") Long id) { EnterpriseQualificationDO enterpriseQualification = enterpriseQualificationService.getEnterpriseQualification(id); EnterpriseQualificationRespVO bean = BeanUtils.toBean(enterpriseQualification, EnterpriseQualificationRespVO.class); + if(enterpriseQualification.getEnterpriseId()!= null){ + EnterpriseDO enterprise = enterpriseService.getEnterprise(Long.valueOf(enterpriseQualification.getEnterpriseId())); + if(enterprise!=null){ + bean.setEnterpriseName(enterprise.getEnterprisesName()); + } + } List fileList = fileInfoService.getFileList(EnterpriseServiceImpl.DEFAULT_DICT_TYPE, EnterpriseQualificationServiceImpl.DEFAULT_DICT_DATA_QYZZ, bean.getId().toString()); bean.setFiles(fileList); return success(bean); @@ -94,16 +100,20 @@ public class EnterpriseQualificationController { // @PreAuthorize("@ss.hasPermission('system:enterprise-qualification:query')") public CommonResult> getEnterpriseQualificationPage(EnterpriseQualificationPageReqVO pageReqVO) { PageResult pageResult = enterpriseQualificationService.getEnterpriseQualificationPage(pageReqVO); - pageResult.getList().forEach(item->{ + PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + bean.getList().forEach(item->{ if(item.getEnterpriseId()!= null){ EnterpriseDO enterprise = enterpriseService.getEnterprise(Long.valueOf(item.getEnterpriseId())); if(enterprise!=null){ item.setEnterpriseName(enterprise.getEnterprisesName()); } + final List fileList = fileInfoService.getFileList(644l, 3l, item.getId().toString()); + item.setQualificationFiles(fileList); + } }); - PageResult bean = BeanUtils.toBean(pageResult, EnterpriseQualificationRespVO.class); + return success(bean); } 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 d2f5c9d..42150e5 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 @@ -25,7 +25,6 @@ public class EnterpriseQualificationPageReqVO extends PageParam { @Schema(description = "企业名称", example = "28564") private String enterpriseName; - @Schema(description = "资质名称,例如:排污许可证、环保合格证", example = "张三") private String qualificationName; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java index 76e9ff7..f220ba7 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/qualification/vo/EnterpriseQualificationRespVO.java @@ -64,6 +64,9 @@ public class EnterpriseQualificationRespVO { @Schema(description = "企业图片", example = "26433") private List files; + @Schema(description = "资质图片", example = "26433") + private List qualificationFiles; + //资质状态 @TableField(exist = false) private Integer status; 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 33ab217..780e39c 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 @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.controller.admin.taskinfo; import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.infra.api.job.JobApi; import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.EnterprisePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueLongVO; @@ -10,6 +11,8 @@ import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueV import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.EnterpriseInspectionsSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReqVO; +import cn.iocoder.yudao.module.system.convert.taskInfo.TaskInfoConvert; +import cn.iocoder.yudao.module.system.convert.user.UserConvert; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; @@ -20,6 +23,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.service.dept.DeptService; import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; import cn.iocoder.yudao.module.system.service.enterpriseinspections.EnterpriseInspectionsService; +import cn.iocoder.yudao.module.system.service.fileInfo.FileInfoService; import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService; import cn.iocoder.yudao.module.system.service.tasktag.TaskTagService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; @@ -78,6 +82,13 @@ public class TaskInfoController { private TagLibraryService tagLibraryService; @Resource private AdminUserMapper adminUserMapper; + @Resource + private FileInfoService fileInfoService; + + //企业红头文件 + public final static Long DEFAULT_DICT_DATA_QY = 4L; + + public final static Long DEFAULT_DICT_TYPE = 644L; @PostMapping("/create") @Operation(summary = "创建任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") @@ -94,6 +105,14 @@ public class TaskInfoController { return success("执行成功"); } + @PutMapping("/audit") + @Operation(summary = "审核任务") + @PreAuthorize("@ss.hasPermission('system:task-info:audit')") + public CommonResult audit(@RequestParam("id") Long id) { + taskInfoService.audit(id); + return success("审核成功"); + } + @PutMapping("/update") @Operation(summary = "更新任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。") @PreAuthorize("@ss.hasPermission('system:task-info:update')") @@ -137,6 +156,24 @@ public class TaskInfoController { @PreAuthorize("@ss.hasPermission('system:task-info:query')") public CommonResult getTaskInfo(@RequestParam("id") Long id) { TaskInfoDO taskInfo = taskInfoService.getTaskInfo(id); + //获取任务类型名称 + if (taskInfo.getTaskType() != null) { + final TagLibraryDO tagLibrary = tagLibraryService.getTagLibrary(taskInfo.getTaskType()); + if (tagLibrary != null) { + taskInfo.setTaskTypeName(tagLibrary.getTagName()); + } + } + + //发布部门 + if (taskInfo.getCreator() != null) { + final Long userId = Long.valueOf(taskInfo.getCreator()); + final DeptDO dept = deptService.getByUserId(userId); + if (dept != null) { + taskInfo.setDeptName(dept.getName()); + } + + } + //获取任务包含企业 EnterpriseInspectionsPageReqVO enterpriseInspectionsPageReqVO=new EnterpriseInspectionsPageReqVO(); enterpriseInspectionsPageReqVO.setTaskId(taskInfo.getId()); @@ -146,6 +183,13 @@ public class TaskInfoController { enterprisePageReqVO.setIds(longs); List enterpriseIdes=enterpriseService.getEnterpriseList(enterprisePageReqVO); TaskInfoRespVO bean = BeanUtils.toBean(taskInfo, TaskInfoRespVO.class); + + //获取任务红头文件 + final List fileList = fileInfoService.getFileList(DEFAULT_DICT_TYPE, DEFAULT_DICT_DATA_QY, taskInfo.getId().toString()); + if (!fileList.isEmpty()) { + bean.setFileList(fileList); + } + if (enterpriseIdes != null && enterpriseIdes.size() > 0) { enterpriseIdes.forEach(item->{ // 企业标签 @@ -159,25 +203,23 @@ public class TaskInfoController { labelValueVO.setLabel(tag.getTagName()); labelValueVO.setValue(tag.getParentId()); labelValueVOList.add(labelValueVO); - }); - - //执法人员 执法人员所在部门 - final Long userId = item.getUserId(); - final AdminUserDO user = adminUserService.getUser(userId); - if (user != null) { - item.setInviterName(user.getRealName()); - final Long deptId = user.getDeptId(); - final DeptDO dept = deptService.getDept(deptId); - if (dept != null) { - item.setInviterNameDept(dept.getName()); - } - } - item.setTagListName(labelValueVOList); } + //执法人员 执法人员所在部门 + final Long userId = item.getUserId(); + final AdminUserDO user = adminUserService.getUser(userId); + if (user != null) { + item.setInviterName(user.getRealName()); + final Long deptId = user.getDeptId(); + final DeptDO dept = deptService.getDept(deptId); + if (dept != null) { + item.setInviterNameDept(dept.getName()); + } + } + }); } bean.setEnterpriseIdes(enterpriseIdes); @@ -188,9 +230,7 @@ public class TaskInfoController { List taskTagides=taskTagService.getTaskTagList(taskTagPageReqVO); //企业标签 - - List taglongs = CollectionUtils.convertList(enterpriseInspectionsides, EnterpriseInspectionsDO::getEnterpriseId); - +// List taglongs = CollectionUtils.convertList(enterpriseInspectionsides, EnterpriseInspectionsDO::getEnterpriseId); bean.setTaskTagIdes(taskTagides); @@ -217,10 +257,17 @@ public class TaskInfoController { final DeptDO dept = deptService.getDept(user.getDeptId()); taskInfo.setDeptName(dept.getName()); } + } + + final TaskInfoRespVO bean = BeanUtils.toBean(taskInfo, TaskInfoRespVO.class); + //获取任务红头文件 + final List fileList = fileInfoService.getFileList(DEFAULT_DICT_TYPE, DEFAULT_DICT_DATA_QY, taskInfo.getId().toString()); + if (!fileList.isEmpty()) { + bean.setFileList(fileList); } - return success(BeanUtils.toBean(taskInfo, TaskInfoRespVO.class)); + return success(bean); } @@ -268,8 +315,6 @@ public class TaskInfoController { } } - - return success(BeanUtils.toBean(pageResult, TaskInfoRespVO.class)); } @@ -298,19 +343,57 @@ public class TaskInfoController { } @GetMapping("/export-excel") - @Operation(summary = "导出任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。 Excel") + @Operation(summary = "任务表. Excel") @PreAuthorize("@ss.hasPermission('system:task-info:export')") @ApiAccessLog(operateType = EXPORT) public void exportTaskInfoExcel(@Valid TaskInfoPageReqVO pageReqVO, HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = taskInfoService.getTaskInfoPage(pageReqVO).getList(); + + EnterpriseInspectionsPageReqVO enterpriseInspectionsPageReqVO=new EnterpriseInspectionsPageReqVO(); + list.forEach(item->{ + final Long creator = Long.valueOf(item.getCreator()); + AdminUserDO user = adminUserService.getUser(creator); + DeptDO dept= deptService.getDept(user.getDeptId()); + + if (dept != null) { + item.setDeptName(dept.getName()); + } + final AdminUserDO user1 = adminUserService.getUser(Long.valueOf(item.getCreator())); + if (user1 != null) { + item.setCreateName(user1.getRealName()); + } + enterpriseInspectionsPageReqVO.setTaskId(item.getId()); + List enterpriseInspectionsides=enterpriseInspectionsService.getEnterpriseInspectionsList(enterpriseInspectionsPageReqVO); + EnterprisePageReqVO enterprisePageReqVO=new EnterprisePageReqVO(); + List longs = CollectionUtils.convertList(enterpriseInspectionsides, EnterpriseInspectionsDO::getEnterpriseId); + enterprisePageReqVO.setIds(longs); + List enterpriseIdes=enterpriseService.getEnterpriseList(enterprisePageReqVO); + item.setEnterpriseIdes(enterpriseIdes); + item.setTaskTypeName(tagLibraryService.getTagLibrary(Integer.valueOf(item.getTaskType())).getTagName()); + + }); + + //按发布部门查询 + if (pageReqVO.getDeptId()!= null) { + List deptIds = new ArrayList<>(); + deptIds.add(pageReqVO.getDeptId()); + final List userListByDeptIds = adminUserService.getUserListByDeptIds(deptIds); + + if (!userListByDeptIds.isEmpty()) { + List longs = CollectionUtils.convertList(userListByDeptIds, AdminUserDO::getId); + list = list.stream().filter(item -> longs.contains(Long.valueOf(item.getCreator()))).collect(Collectors.toList()); + } + + } + final List taskInfoRespExcelVOS = TaskInfoConvert.INSTANCE.convertList(list); // 导出 Excel - ExcelUtils.write(response, "任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。.xls", "数据", TaskInfoRespVO.class, - BeanUtils.toBean(list, TaskInfoRespVO.class)); + ExcelUtils.write(response, "任务列表.xls", "数据", TaskInfoRespExcelVO.class, + taskInfoRespExcelVOS); } - +// UserConvert.INSTANCE.convertList(list, deptMap) @GetMapping("/testInsertUserArea") @Operation(summary = "获得任务表,用于存储所有的任务信息,任务可由不同用户创建并管理。分页") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespExcelVO.java new file mode 100644 index 0000000..4cf849e --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespExcelVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class TaskInfoRespExcelVO { + @Schema(description = "任务标题", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("任务标题") + private String title; + + @Schema(description = "任务类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty(value = "任务类型", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TASK_TYPE_EXCEL) + private Integer taskType; + + @Schema(description = "发布部门") + @ExcelProperty("发布部门") + private String deptName; + // @Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1") +// @ExcelProperty(value = "用户性别", converter = DictConvert.class) +// @DictFormat(DictTypeConstants.USER_SEX) +// private Integer sex; + + @Schema(description = "任务状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty(value = "任务状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.TASK_STATE) + private String status; + + + + @Schema(description = "执法对象", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty("执法对象") + private String inspectionsObject; + + @Schema(description = "执行时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") + @ExcelProperty("执行时间") + private String time; + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java index 71c16b1..b273105 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoRespVO.java @@ -1,10 +1,11 @@ package cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo; +import cn.iocoder.yudao.module.infra.api.file.dto.InfraFileInfoDTO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; import cn.iocoder.yudao.module.system.dal.dataobject.tasktag.TaskTagDO; -import com.baomidou.mybatisplus.annotation.TableField; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; @@ -15,7 +16,6 @@ import lombok.*; import java.time.LocalDate; import java.util.*; -import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import com.alibaba.excel.annotation.*; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; @@ -27,14 +27,12 @@ import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; public class TaskInfoRespVO { @Schema(description = "任务ID,主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "4541") - @ExcelProperty("任务ID,主键") private Long id; private Integer reverseStauts; //任务编号 @Schema(description = "任务编号", example = "你猜") - @ExcelProperty("任务编号") private String taskNumber; @Schema(description = "任务标题", requiredMode = Schema.RequiredMode.REQUIRED) @@ -54,7 +52,6 @@ public class TaskInfoRespVO { @DictFormat("task_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 private Integer taskType; - @Schema(description = "任务优先级", requiredMode = Schema.RequiredMode.REQUIRED) @ExcelProperty("任务优先级") private Integer priority; @@ -146,4 +143,7 @@ public class TaskInfoRespVO { //任务类型名称 private String taskTypeName; + //文件列表 + private List fileList; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java index ecef9b3..77b19de 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/taskinfo/vo/TaskInfoSaveReqVO.java @@ -84,4 +84,7 @@ public class TaskInfoSaveReqVO { @Schema(defaultValue = "企业集合") private List enterpriseIds; + @Schema(description = "文件id", example = "26433") + private Long[] fileIds; + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java index ab45215..13713f4 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java @@ -13,9 +13,13 @@ import cn.iocoder.yudao.module.system.convert.user.UserConvert; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.userAuditlog.UserAuditLogDO; +import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.userAuditlog.UserAuditLogMapper; import cn.iocoder.yudao.module.system.enums.common.SexEnum; import cn.iocoder.yudao.module.system.service.dept.DeptService; +import cn.iocoder.yudao.module.system.service.permission.PermissionService; +import cn.iocoder.yudao.module.system.service.permission.RoleService; +import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.v3.oas.annotations.Operation; @@ -34,6 +38,7 @@ import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.Set; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -49,8 +54,11 @@ public class UserController { private AdminUserService userService; @Resource private DeptService deptService; + + @Resource + private PermissionService permissionService; @Resource - private UserAuditLogMapper userAuditLogMapper; + private TagLibraryService tagLibraryService; @PostMapping("/create") @Operation(summary = "新增用户") @@ -107,23 +115,19 @@ public class UserController { @PreAuthorize("@ss.hasPermission('system:user:query')") public CommonResult> getUserPage(@Valid UserPageReqVO pageReqVO) { // 获得用户分页列表 + PageResult pageResult = userService.getUserPage(pageReqVO); if (CollUtil.isEmpty(pageResult.getList())) { return success(new PageResult<>(pageResult.getTotal())); } pageResult.getList().forEach(item->{ - if (item.getAudit() == 3) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(UserAuditLogDO::getUserId, item.getId()); - wrapper.orderByDesc(UserAuditLogDO::getCreateTime); - wrapper.last("limit 1"); - UserAuditLogDO userAuditLogDO = userAuditLogMapper.selectOne(wrapper); - item.setContent(userAuditLogDO.getContent()); + final List roleListByUserId = permissionService.getRoleListByUserId(item.getId()); + if (!roleListByUserId.isEmpty()) { + item.setRoleList(String.join(",", roleListByUserId)); } }); - // 拼接数据 Map deptMap = deptService.getDeptMap( convertList(pageResult.getList(), AdminUserDO::getDeptId)); @@ -180,7 +184,8 @@ public class UserController { } // 拼接数据 DeptDO dept = deptService.getDept(user.getDeptId()); - return success(UserConvert.INSTANCE.convert(user, dept)); + final List roleIdListByUserId = permissionService.getRoleIdListByUserId(user.getId()); + return success(UserConvert.INSTANCE.convert(user, dept, roleIdListByUserId)); } @GetMapping("/export") @@ -194,8 +199,16 @@ public class UserController { // 输出 Excel Map deptMap = deptService.getDeptMap( convertList(list, AdminUserDO::getDeptId)); - ExcelUtils.write(response, "用户数据.xls", "数据", UserRespVO.class, - UserConvert.INSTANCE.convertList(list, deptMap)); + + list.stream().forEach(item-> { + final List roleListByUserId = permissionService.getRoleListByUserId(item.getId()); + if (!roleListByUserId.isEmpty()) { + item.setRoleList(String.join(",", roleListByUserId)); + } + }); + + ExcelUtils.write(response, "用户数据.xls", "数据", UserExportVO.class, + UserConvert.INSTANCE.convertList2(list, deptMap)); } @GetMapping("/get-import-template") @@ -233,7 +246,7 @@ public class UserController { return success(true); } - @PutMapping("/enterprise_manager_list") + @GetMapping("/enterprise_manager_list") @Operation(summary = "专管员列表,邀请过企业的都是专管员") public CommonResult> enterpriseManagerList() { return success(userService.enterpriseManagerList()); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserDeptVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserDeptVO.java index e852cb7..1991294 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserDeptVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserDeptVO.java @@ -6,5 +6,5 @@ import lombok.Data; public class UserDeptVO { private Long userId; private String realName; - private Long deptName; + private String deptName; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserExportVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserExportVO.java new file mode 100644 index 0000000..59973c5 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserExportVO.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.system.controller.admin.user.vo.user; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import cn.iocoder.yudao.module.system.enums.DictTypeConstants; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Data +public class UserExportVO { + + @Schema(description = "真实姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("真实姓名") + private String realName; + + @Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1") + @ExcelProperty(value = "用户性别", converter = DictConvert.class) + @DictFormat(DictTypeConstants.USER_SEX) + private Integer sex; + + @Schema(description = "手机号码", example = "15601691300") + @ExcelProperty("手机号码") + private String mobile; + + @Schema(description = "部门名称", example = "IT 部") + @ExcelProperty("部门名称") + private String deptName; + + @Schema(description = "职位权限", example = "IT 部") + @ExcelProperty("职位权限") + private String roleList; + + @Schema(description = "状态,参见 CommonStatusEnum 枚举类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty(value = "帐号状态", converter = DictConvert.class) + @DictFormat(DictTypeConstants.USER_AUDIT_TYPE) + private Integer audit; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @Schema(description = "最后登录时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式") + @ExcelProperty("最后登录时间") + private LocalDateTime loginDate; + +} 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 eca4c38..fb6d2ba 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 @@ -19,7 +19,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @EqualsAndHashCode(callSuper = true) public class UserPageReqVO extends PageParam { - @Schema(description = "用户账号,模糊匹配", example = "yudao") + @Schema(description = "真实姓名,模糊匹配", example = "yudao") private String username; @Schema(description = "真实姓名,模糊匹配", example = "张三") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserRespVO.java index a9b9c6e..cef0c0a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserRespVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserRespVO.java @@ -9,6 +9,7 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import java.time.LocalDateTime; +import java.util.List; import java.util.Set; @Schema(description = "管理后台 - 用户信息 Response VO") @@ -84,4 +85,10 @@ public class UserRespVO{ @Schema(description = "用户类型", example = "1") private Integer userType; + @Schema(description = "职位", example = "1") + private String roleList; + + @Schema(description = "职位id列表", example = "1") + private List roleIds; + } 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 a8a6022..829fdea 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 @@ -34,6 +34,11 @@ public class UserSaveReqVO { @DiffLogField(name = "用户昵称") private String nickname; + @Schema(description = "真实姓名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @Size(max = 30, message = "用户昵称长度不能超过30个字符") + @DiffLogField(name = "真实姓名") + private String realName; + @Schema(description = "备注", example = "我是一个用户") @DiffLogField(name = "备注") private String remark; @@ -49,6 +54,12 @@ public class UserSaveReqVO { @DiffLogField(name = "岗位", function = PostParseFunction.NAME) private Set postIds; + @Schema(description = "职位id列表", example = "1") + private Set roleIds; + + @Schema(description = "审核", example = "1") + private Integer audit; + @Schema(description = "用户邮箱", example = "yudao@iocoder.cn") @Email(message = "邮箱格式不正确") @Size(max = 50, message = "邮箱长度不能超过 50 个字符") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/enterprise/EnterpriseConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/enterprise/EnterpriseConvert.java new file mode 100644 index 0000000..a22df44 --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/enterprise/EnterpriseConvert.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.system.convert.enterprise; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.EnterpriseExportVO; +import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +@Mapper +public interface EnterpriseConvert { + EnterpriseConvert INSTANCE = Mappers.getMapper(EnterpriseConvert.class); + + default List convertList(List list) { + List enterpriseExportVOS = new ArrayList<>(); + + if (!list.isEmpty()) { + list.forEach(item-> { + EnterpriseExportVO enterpriseExportVO = new EnterpriseExportVO(); + BeanUtils.copyProperties(item,enterpriseExportVO); + if (item.getTagListName() != null) { + final Set collect = item.getTagListName().stream().map(tag -> tag.getLabel()).collect(Collectors.toSet()); + enterpriseExportVO.setType(String.join("," , collect)); + } + enterpriseExportVO.setInviterDeptAndName(item.getInviterName() +" | "+ item.getInviterNameDept()); + enterpriseExportVO.setTime(item.getCreateTime().toString()); + enterpriseExportVOS.add(enterpriseExportVO); + }); + } + + return enterpriseExportVOS; + } + +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/taskInfo/TaskInfoConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/taskInfo/TaskInfoConvert.java new file mode 100644 index 0000000..d8bb2ad --- /dev/null +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/taskInfo/TaskInfoConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.system.convert.taskInfo; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoRespExcelVO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.ArrayList; +import java.util.List; + +@Mapper +public interface TaskInfoConvert { + + TaskInfoConvert INSTANCE = Mappers.getMapper(TaskInfoConvert.class); + + default List convertList(List list) { + + List taskInfoRespExcelVOS = new ArrayList<>(); + + if (!list.isEmpty()) { + list.forEach(item->{ + TaskInfoRespExcelVO taskInfoRespExcelVO = new TaskInfoRespExcelVO(); + BeanUtils.copyProperties(item,taskInfoRespExcelVO); + final long count = item.getEnterpriseIdes().stream().map(enterpriseDO -> enterpriseDO.getType()).distinct().count(); + taskInfoRespExcelVO.setInspectionsObject(count + " 个区域, " + item.getEnterpriseIdes().size() + " 家企业"); + taskInfoRespExcelVO.setTime(item.getStartDate().toString() + item.getExecCycle()); + taskInfoRespExcelVOS.add(taskInfoRespExcelVO); + + }); + } + + return taskInfoRespExcelVOS; + } +} diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java index b58be21..8d5e75c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/user/UserConvert.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.convert.user; +import cn.hutool.core.bean.BeanUtil; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; import cn.iocoder.yudao.framework.common.util.collection.MapUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -7,6 +8,7 @@ import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSimpleRe import cn.iocoder.yudao.module.system.controller.admin.dept.vo.post.PostSimpleRespVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSimpleRespVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileRespVO; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserExportVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserRespVO; import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSimpleRespVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; @@ -14,9 +16,12 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; 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.service.permission.PermissionService; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -25,10 +30,27 @@ public interface UserConvert { UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); + default List convertList(List list, Map deptMap) { return CollectionUtils.convertList(list, user -> convert(user, deptMap.get(user.getDeptId()))); } + default List convertList2(List list, Map deptMap) { + List userRespVOS = CollectionUtils.convertList(list, user -> { + DeptDO dept = deptMap.get(user.getDeptId()); + return convert(user, dept); // 确保convert能处理dept为null的情况 + }); + + List userExportVOs = new ArrayList<>(); + for (UserRespVO respVO : userRespVOS) { + UserExportVO exportVO = new UserExportVO(); + BeanUtil.copyProperties(respVO, exportVO); + userExportVOs.add(exportVO); + + } + return userExportVOs; + } + default UserRespVO convert(AdminUserDO user, DeptDO dept) { UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class); if (dept != null) { @@ -37,6 +59,20 @@ public interface UserConvert { return userVO; } + default UserRespVO convert(AdminUserDO user, DeptDO dept, List roleIds) { + UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class); + if (dept != null) { + userVO.setDeptName(dept.getName()); + } + + if (roleIds != null) { + userVO.setRoleIds(roleIds); + } + + return userVO; + } + + default List convertSimpleList(List list, Map deptMap) { return CollectionUtils.convertList(list, user -> { UserSimpleRespVO userVO = BeanUtils.toBean(user, UserSimpleRespVO.class); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/airqualitycollection/QualityCollectionDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/airqualitycollection/QualityCollectionDO.java index d7ff002..3121b35 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/airqualitycollection/QualityCollectionDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/airqualitycollection/QualityCollectionDO.java @@ -36,6 +36,8 @@ public class QualityCollectionDO extends BaseDO { * 城市 */ private String city; + + private String time; /** * 数据类型 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java index b634d54..0f72e6a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/enterprise/EnterpriseDO.java @@ -110,4 +110,7 @@ public class EnterpriseDO extends BaseDO { @TableField(exist = false) private List tagListName; + + @TableField(exist = false) + private Long count; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java index 0e96010..4ff9eec 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/taskinfo/TaskInfoDO.java @@ -58,7 +58,6 @@ public class TaskInfoDO extends BaseDO { */ private Integer taskType; - /** * 任务优先级 */ @@ -126,4 +125,7 @@ public class TaskInfoDO extends BaseDO { @TableField(exist = false) private Long inspectionsId; + + @TableField(exist = false) + private Long count; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java index 12f0983..ae1157f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java @@ -112,8 +112,14 @@ public class AdminUserDO extends TenantBaseDO { //审核状态 private Integer audit; - //审核状态 + //角色名称合集 + @TableField(exist = false) + private String roleList; + + //审核名称 @TableField(exist = false) - private String content; + private String auditName; + + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/airqualitycollection/QualityCollectionMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/airqualitycollection/QualityCollectionMapper.java index 044473a..1d0fc36 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/airqualitycollection/QualityCollectionMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/airqualitycollection/QualityCollectionMapper.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.dal.mysql.airqualitycollection; +import java.text.SimpleDateFormat; import java.util.*; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -18,21 +19,37 @@ import cn.iocoder.yudao.module.system.controller.admin.airqualitycollection.vo.* public interface QualityCollectionMapper extends BaseMapperX { default PageResult selectPage(QualityCollectionPageReqVO reqVO) { + + if (reqVO.getTimes() == null) { + String[] times = new String[2]; + // 获取当前日期 + Calendar calendar = Calendar.getInstance(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + times[1] = sdf.format(calendar.getTime()); + calendar.set(Calendar.MONTH, Calendar.JANUARY); + calendar.set(Calendar.DAY_OF_MONTH, 1); + times[0] = sdf.format(calendar.getTime()); + + reqVO.setTimes(times); + } + return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(QualityCollectionDO::getSiteName, reqVO.getSiteName()) .eqIfPresent(QualityCollectionDO::getCity, reqVO.getCity()) - .eqIfPresent(QualityCollectionDO::getType, reqVO.getType()) .eqIfPresent(QualityCollectionDO::getPm25, reqVO.getPm25()) .eqIfPresent(QualityCollectionDO::getPm10, reqVO.getPm10()) .eqIfPresent(QualityCollectionDO::getSo2, reqVO.getSo2()) .eqIfPresent(QualityCollectionDO::getNo2, reqVO.getNo2()) .eqIfPresent(QualityCollectionDO::getNo, reqVO.getNo()) - .eqIfPresent(QualityCollectionDO::getNox, reqVO.getNOx()) + .eqIfPresent(QualityCollectionDO::getNox, reqVO.getNox()) .eqIfPresent(QualityCollectionDO::getCo, reqVO.getCo()) .eqIfPresent(QualityCollectionDO::getO3, reqVO.getO3()) .eqIfPresent(QualityCollectionDO::getRemark, reqVO.getRemark()) .eqIfPresent(QualityCollectionDO::getRemark2, reqVO.getRemark2()) .betweenIfPresent(QualityCollectionDO::getCreateTime, reqVO.getCreateTime()) + .apply(reqVO.getType() == 2, "DATE_FORMAT(time, '%i') = '00'") + .apply(reqVO.getTimes() != null && reqVO.getTimes().length >= 2, "DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') >= {0}", reqVO.getTimes()[0]) + .apply(reqVO.getTimes() != null && reqVO.getTimes().length >= 2,"DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') <= {0}", reqVO.getTimes()[1]) .orderByDesc(QualityCollectionDO::getId)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/bigviewdata/BigViewDataMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/bigviewdata/BigViewDataMapper.java index ecd5315..fa20314 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/bigviewdata/BigViewDataMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/bigviewdata/BigViewDataMapper.java @@ -1,9 +1,7 @@ package cn.iocoder.yudao.module.system.dal.mysql.bigviewdata; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewGroupCountCompareVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewQOQVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.StatusCountVO; +import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.*; +import cn.iocoder.yudao.module.system.controller.admin.home.vo.EnterpriseNumVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Options; @@ -25,16 +23,21 @@ public interface BigViewDataMapper { /* 根据任务类型分组 */ - List selectTaskTypeGroupCount(HomeSelectVO homeSelectVO); + List selectTaskTypeGroupCount(HomeSelectVO homeSelectVO); /* - 执法和任务分组统计 + 执法和任务分组统计` */ - List getInspectionsTaskGroupCount(HomeSelectVO homeSelectVO); + List getInspectionsTaskGroupCount(HomeSelectVO homeSelectVO); /* 执法和任务分组统计同比 */ - List getInspectionsTaskGroupCountCompare(BigViewQOQVO bigViewQOQVO); + List getInspectionsTaskGroupCountCompare(); + //区域内任务统计 + List getTaskCount(HomeSelectVO homeSelectVO); + + + List getRightThird(HomeSelectVO homeSelectVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java index dc94601..fb0ecb2 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterprise/EnterpriseMapper.java @@ -28,7 +28,6 @@ public interface EnterpriseMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .eqIfPresent(EnterpriseDO::getDepartmentId, reqVO.getDepartmentId()) .eqIfPresent(EnterpriseDO::getUserId, reqVO.getUserId()) - .eqIfPresent(EnterpriseDO::getType, reqVO.getType()) .eqIfPresent(EnterpriseDO::getRegion, reqVO.getRegion()) .likeIfPresent(EnterpriseDO::getEnterprisesName, reqVO.getEnterprisesName()) .eqIfPresent(EnterpriseDO::getAddress, reqVO.getAddress()) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java index 8a87e64..8498e47 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/enterpriseinspections/EnterpriseInspectionsMapper.java @@ -6,8 +6,13 @@ 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.enterpriseinspections.EnterpriseInspectionsDO; +import cn.iocoder.yudao.module.system.dal.dataobject.inspectionslog.InspectionsLogDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import cn.iocoder.yudao.module.system.controller.admin.enterpriseinspections.vo.*; +import org.apache.ibatis.annotations.Param; /** * 企业检查记录表,用于记录与企业相关的环保检查信息。 Mapper @@ -52,5 +57,7 @@ public interface EnterpriseInspectionsMapper extends BaseMapperX inspectionsCorrectionList(); + //整改数据 + IPage inspectionsByEnterpriseId(Page page, @Param("params") EnterpriseInspectionsPageReqVO pageReqVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java index 12ff88a..24b3e72 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/permission/UserRoleMapper.java @@ -4,9 +4,11 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Select; import java.util.Collection; import java.util.List; +import java.util.Set; @Mapper public interface UserRoleMapper extends BaseMapperX { 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 4c2d944..efef6dc 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 @@ -39,6 +39,8 @@ public interface AdminUserMapper extends BaseMapperX { .inIfPresent(AdminUserDO::getId, userIds) .inIfPresent(AdminUserDO::getAudit, reqVO.getAudit()) .inIfPresent(AdminUserDO::getUserType, reqVO.getUserType()) + .isNotNull(AdminUserDO::getAudit) + .isNotNull(AdminUserDO::getRealName) .orderByDesc(AdminUserDO::getId)); } 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 af739af..b9fe645 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 @@ -67,7 +67,7 @@ public class InspectionsSendStartMessageJob implements JobHandler { Map templateParams = new HashMap<>(); templateParams.put("title", enterpriseService.getEnterprise(item.getEnterpriseId()).getEnterprisesName()); templateParams.put("endTime", DateUtil.format(inspectionsLogNew.getCorrectionTime(), DateUtils.FORMAT_YEAR_MONTH_DAY)); - templateParams.put("url", "/sub/task/record?taskId="+item.getTaskId() +"&recordId=" + item.getEnterpriseId() +"&enterpriseId=" + item.getEnterpriseId()); + templateParams.put("url", "sub/task/record?taskId="+item.getTaskId() +"&recordId=" + item.getEnterpriseId() +"&enterpriseId=" + item.getEnterpriseId()); notifyMessage.setTemplateParams(templateParams); notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); @@ -77,7 +77,7 @@ public class InspectionsSendStartMessageJob implements JobHandler { SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); reqDTO.setUserType(1); reqDTO.setTemplateTitle("问题整改通知"); - reqDTO.setPage("sub/inspection/detail?id=" + item.getInspectionsId()); + reqDTO.setPage("/sub/inspection/detail?id=" + item.getInspectionsId()); reqDTO.setUserId(Long.valueOf(item.getCreator())); Map message = new HashMap<>(); message.put("thing5", enterprise.getEnterprisesName()); 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 3e459d9..89d6731 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 @@ -53,18 +53,19 @@ public class QualificationTimeOutSendStartMessageJob implements JobHandler { if (item.getEnterpriseName() != null && item.getExpiryDate() != null) { SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); reqDTO.setUserType(1); - reqDTO.setTemplateTitle("证书到期通知"); + reqDTO.setTemplateTitle("资质临期提醒"); reqDTO.setPage("sub/enterprise/detail?id="+item.getEnterpriseId()); reqDTO.setUserId(item.getUserId()); Map message = new HashMap<>(); message.put("thing1", StringUtil.truncateString(enterpriseQua.getLabel(), 15)); message.put("thing2", StringUtil.truncateString(item.getEnterpriseName(), 15)); - message.put("time4", DateUtil.format(item.getExpiryDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); - message.put("phrase3", "到期"); + message.put("time3", DateUtil.format(item.getExpiryDate(), DateUtils.FORMAT_YEAR_MONTH_DAY)); reqDTO.setMessages(message); socialClientApi.sendWxaSubscribeMessage(reqDTO); } + //TODO 给企业用户发送消息 + } catch (Exception e){ log.error("任务发送通知错误:",e.toString()); @@ -82,7 +83,6 @@ public class QualificationTimeOutSendStartMessageJob implements JobHandler { notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); }); } - 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 5019b2c..e73b27a 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 @@ -59,9 +59,9 @@ public class TaskSendStartMessageJob implements JobHandler { reqDTO.setUserId(x.getUserId()); Map message = new HashMap<>(); message.put("thing2", StringUtil.truncateString(beforeTaskInfo.getTitle(), 15)); - message.put("time3", DateUtil.format(beforeTaskInfo.getStartDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + message.put("time5", DateUtil.format(beforeTaskInfo.getStartDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); message.put("thing4", StringUtil.truncateString(beforeTaskInfo.getDescription(), 15)); - message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + message.put("time3", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); reqDTO.setMessages(message); socialClientApi.sendWxaSubscribeMessage(reqDTO); } @@ -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?id="+ enterpriseInspectionsDO.getTaskId()); + templateParams.put("url", "/sub/task/detail?id="+ enterpriseInspectionsDO.getTaskId()); notifyMessage.setTemplateParams(templateParams); notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionService.java index da66a96..812252b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionService.java @@ -53,5 +53,7 @@ public interface QualityCollectionService { */ PageResult getQualityCollectionPage(QualityCollectionPageReqVO pageReqVO); - void saveList(List list, Long type); + void saveList(List list); + + QualityCollectionDO latest(); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionServiceImpl.java index b57e7fc..7ef2129 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/airqualitycollection/QualityCollectionServiceImpl.java @@ -1,10 +1,19 @@ package cn.iocoder.yudao.module.system.service.airqualitycollection; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import org.springframework.transaction.annotation.Transactional; import java.util.*; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + import cn.iocoder.yudao.module.system.controller.admin.airqualitycollection.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.airqualitycollection.QualityCollectionDO; import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -69,22 +78,120 @@ public class QualityCollectionServiceImpl implements QualityCollectionService { @Override public PageResult getQualityCollectionPage(QualityCollectionPageReqVO pageReqVO) { - return qualityCollectionMapper.selectPage(pageReqVO); + if (pageReqVO.getType() == 1 || pageReqVO.getType() == 2) { + return qualityCollectionMapper.selectPage(pageReqVO); + } + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.select( + getTimeExpression(pageReqVO.getType()) + " as time", + "ROUND(AVG(pm25), 1) as pm25", + "ROUND(AVG(pm10), 1) as pm10", + "ROUND(AVG(so2), 1) as so2", + "ROUND(AVG(no2), 1) as no2", + "ROUND(AVG(no), 1) as no", + "ROUND(AVG(nox), 1) as nox", + "ROUND(AVG(co), 1) as co", + "ROUND(AVG(03), 1) as o3", + "site_name as siteName" + ); + wrapper.like(pageReqVO.getSiteName() != null,"site_name", pageReqVO.getSiteName()); + wrapper.groupBy(getTimeExpression(pageReqVO.getType()), "site_name"); + + if (pageReqVO.getTimes() != null && pageReqVO.getTimes().length >= 2) { + wrapper.apply("DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') >= {0}", pageReqVO.getTimes()[0]); + wrapper.apply("DATE_FORMAT(time, '%Y-%m-%d %H:%i:%s') <= {0}", pageReqVO.getTimes()[1]); + } + + wrapper.orderByAsc("time"); + + // 执行分页查询(关键变更点) + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + IPage iPage = qualityCollectionMapper.selectPage(page, wrapper); + + return new PageResult<>(iPage.getRecords(), iPage.getTotal()); + } + + private String getTimeExpression(Integer type) { + switch (type) { + case 3: + return "DATE(time)"; + case 4: + return "DATE_SUB(\n" + + " STR_TO_DATE(CONCAT(YEARWEEK(time, 3), ' Monday'), '%X%V %W'), \n" + + " INTERVAL WEEKDAY(STR_TO_DATE(CONCAT(YEARWEEK(time, 3), ' Monday'), '%X%V %W')) DAY\n" + + " )"; + case 5: + return "DATE_FORMAT(time, '%Y-%m')"; + case 6: + return "CONCAT(YEAR(time), '-', QUARTER(time))"; + case 7: + return "YEAR(time)"; + default: + throw new IllegalArgumentException("无效的时间粒度"); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) // 添加事务控制 + public void saveList(List list) { + if (CollectionUtils.isEmpty(list)) return; + + // 1. 提取所有待校验的 (siteName + time) 组合 + Set uniqueKeys = list.stream() + .map(vo -> vo.getSiteName() + "|" + vo.getTime()) + .collect(Collectors.toSet()); + + // 2. 批量查询已存在的记录 (一次查询代替N次查询) + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.select("site_name", "time"); + wrapper.in( + "CONCAT(site_name, '|', time)", + uniqueKeys.stream().collect(Collectors.toList()) + ); + List existList = qualityCollectionMapper.selectList(wrapper); + // 3. 构建已存在的唯一键缓存 + Set existKeys = existList.stream().map(item -> item.getSiteName() + "|" + item.getTime()).collect(Collectors.toSet()); + + //数据清洗 + final List collect = list.stream() + .filter(vo -> isValidNumber(vo.getPm25()) && isValidNumber(vo.getPm10()) && isValidNumber(vo.getSo2()) && isValidNumber(vo.getNo2()) && isValidNumber(vo.getNo()) && isValidNumber(vo.getNox()) && isValidNumber(vo.getCo()) && isValidNumber(vo.getO3())) + .collect(Collectors.toList()); + + // 4. 过滤出需要插入的新数据 + List newDataList = collect.stream() + .filter(vo -> !existKeys.contains(vo.getSiteName() + "|" + vo.getTime()) ) + .map(vo -> { + + QualityCollectionDO entity = new QualityCollectionDO(); + BeanUtils.copyProperties(vo, entity); + return entity; + }) + .collect(Collectors.toList()); + + // 5. 批量插入新数据 + if (!CollectionUtils.isEmpty(newDataList)) { + qualityCollectionMapper.insertBatch(newDataList); + } } @Override - public void saveList(List list, Long type) { - List collectionDOS = new ArrayList<>(); - if (!list.isEmpty()) { - list.forEach(item->{ - QualityCollectionDO collectionDO = new QualityCollectionDO(); - collectionDO.setType(type); - BeanUtils.copyProperties(item, collectionDO); - - collectionDOS.add(collectionDO); - }); - qualityCollectionMapper.insertBatch(collectionDOS); + public QualityCollectionDO latest() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + // 按时间降序排序后,限制只取第一条 + wrapper.orderByDesc(QualityCollectionDO::getTime) + .last("LIMIT 1"); // 关键:强制只返回一条数据 + return qualityCollectionMapper.selectOne(wrapper); // 使用 selectOne() + } + + private final Pattern NUMBER_PATTERN = + Pattern.compile("^-?\\d+(\\.\\d+)?$"); + + public boolean isValidNumber(String str) { + if (str == null || str.trim().isEmpty()) { + return false; } + return NUMBER_PATTERN.matcher(str).matches(); } } 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 b8c50ad..a05c75a 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 @@ -136,7 +136,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { // 如果 socialType 非空,说明需要绑定社交用户 if (reqVO.getSocialType() != null) { socialUserService.bindSocialUser(new SocialUserBindReqDTO(user.getId(), getUserType().getValue(), - reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); + reqVO.getSocialType(), reqVO.getSocialCode(), reqVO.getSocialState())); } // 创建 Token 令牌,记录登录日志 return createTokenAfterLoginSuccess(user.getId(), reqVO.getUsername(), LoginLogTypeEnum.LOGIN_USERNAME); @@ -190,7 +190,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { public AuthLoginRespVO socialLogin(AuthSocialLoginReqVO reqVO) { // 使用 code 授权码,进行登录。然后,获得到绑定的用户编号 SocialUserRespDTO socialUser = socialUserService.getSocialUserByCode(UserTypeEnum.MEMBER.getValue(), reqVO.getType(), - reqVO.getCode(), reqVO.getState()); + reqVO.getCode(), reqVO.getState()); if (socialUser == null || socialUser.getUserId() == null) { throw exception(AUTH_THIRD_LOGIN_NOT_BIND); } @@ -201,6 +201,11 @@ public class AdminAuthServiceImpl implements AdminAuthService { throw exception(USER_NOT_EXISTS); } + if (user.getUserType() != 3 || user.getAudit() != 2) { + throw exception(USER_LOGIN_ERROR); + } + + // 创建 Token 令牌,记录登录日志 return createTokenAfterLoginSuccess(user.getId(), user.getUsername(), LoginLogTypeEnum.LOGIN_SOCIAL); } @@ -229,7 +234,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { createLoginLog(userId, username, logType, LoginResultEnum.SUCCESS); // 创建访问令牌 OAuth2AccessTokenDO accessTokenDO = oauth2TokenService.createAccessToken(userId, getUserType().getValue(), - OAuth2ClientConstants.CLIENT_ID_DEFAULT, null); + OAuth2ClientConstants.CLIENT_ID_DEFAULT, null); // 构建返回结果 return AuthConvert.INSTANCE.convert(accessTokenDO); } @@ -325,15 +330,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { AdminUserDO user = null; if (socialUserDO == null ) { - -// String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo" + -// "?access_token=" + authUser.getToken() + -// "&openid=" + authUser.getUuid() + -// "&lang=zh_CN"; -// String userInfoResponse = HttpUtil.get(userInfoUrl); -// JSONObject userInfoJson = JSONUtil.parseObj(userInfoResponse); -// String nickname = userInfoJson.getStr("nickname"); - // 未找到社交用户,插入记录 SocialUserDO socialUser = new SocialUserDO(); socialUser.setType(reqVO.getType()); @@ -368,9 +364,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { if (user == null) { throw exception(USER_NOT_EXISTS); } - user.setIsBand(true); - } return user; @@ -394,10 +388,10 @@ public class AdminAuthServiceImpl implements AdminAuthService { AuthUser authUser = socialClientService.getAuthUser( - SocialTypeEnum.WECHAT_MINI_APP.getType(), - UserTypeEnum.MEMBER.getValue(), // 假设用户类型为会员 - reqVO.getCode(), - reqVO.getState() + SocialTypeEnum.WECHAT_MINI_APP.getType(), + UserTypeEnum.MEMBER.getValue(), // 假设用户类型为会员 + reqVO.getCode(), + reqVO.getState() ); @@ -422,8 +416,8 @@ public class AdminAuthServiceImpl implements AdminAuthService { // 根据授权码获取 access_token 和 openid // - String baseUrl = "https://api.weixin.qq.com/sns/oauth2/access_token"; - String urlStr = baseUrl + "?appid=" + APPID + "&secret=" + APPSECRET + "&code=" + reqVO.getCode()+ "&grant_type=authorization_code"; + String baseUrl = "https://api.weixin.qq.com/sns/oauth2/access_token"; + String urlStr = baseUrl + "?appid=" + APPID + "&secret=" + APPSECRET + "&code=" + reqVO.getCode()+ "&grant_type=authorization_code"; System.out.println("-----------urlStr:"+urlStr); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataService.java index bdf1532..05be99a 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataService.java @@ -1,9 +1,7 @@ package cn.iocoder.yudao.module.system.service.bigviewdata; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewEnterpriseCountGroup; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.BigViewGroupCountCompareVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.NameCountVO; -import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.StatusCountVO; +import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.*; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueLongVO; 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.HomeGroupCountVO; @@ -13,19 +11,21 @@ import java.util.List; public interface BigViewDataService { - BigViewEnterpriseCountGroup getLeftSecond(HomeSelectVO homeSelectVO); + List getLeftSecond(HomeSelectVO homeSelectVO); - List getLeftThird(HomeSelectVO homeSelectVO); + List getLeftThird(HomeSelectVO homeSelectVO); - List getRightFist(HomeSelectVO homeSelectVO); + List getRightFist(HomeSelectVO homeSelectVO); List getRightSecond(HomeSelectVO homeSelectVO); - List getRightThird(HomeSelectVO homeSelectVO); + List getRightThird(HomeSelectVO homeSelectVO); - List getLeftFirst(HomeSelectVO homeSelectVO); + List getLeftFirst(HomeSelectVO homeSelectVO); List getRightFourth(HomeSelectVO homeSelectVO); - HomeCountResVO getCenter(HomeSelectVO homeSelectVO); + BigViewCenterDataVO getCenter(HomeSelectVO homeSelectVO); + + List getMapData(HomeSelectVO homeSelectVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataServiceImpl.java index 07171bf..f32bf65 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/bigviewdata/BigViewDataServiceImpl.java @@ -1,20 +1,44 @@ package cn.iocoder.yudao.module.system.service.bigviewdata; import cn.iocoder.yudao.module.system.controller.admin.bigviewdata.vo.*; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.EnterprisePageReqVO; +import cn.iocoder.yudao.module.system.controller.admin.enterprise.vo.LabelValueLongVO; 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.HomeGroupCountVO; import cn.iocoder.yudao.module.system.controller.admin.home.vo.HomeSelectVO; +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.enterpriseinspections.EnterpriseInspectionsDO; +import cn.iocoder.yudao.module.system.dal.dataobject.qualification.EnterpriseQualificationDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taglibrary.TagLibraryDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; import cn.iocoder.yudao.module.system.dal.mysql.bigviewdata.BigViewDataMapper; +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.qualification.EnterpriseQualificationMapper; import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper; +import cn.iocoder.yudao.module.system.service.dict.DictDataService; +import cn.iocoder.yudao.module.system.service.enterprise.EnterpriseService; +import cn.iocoder.yudao.module.system.service.enterpriseinspections.EnterpriseInspectionsService; import cn.iocoder.yudao.module.system.service.home.HomeService; +import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService; +import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.DayOfWeek; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; +import java.time.LocalTime; +import java.time.temporal.TemporalAdjusters; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; @Service @Slf4j @@ -26,80 +50,281 @@ public class BigViewDataServiceImpl implements BigViewDataService { private TaskInfoMapper taskInfoMapper; @Resource private HomeService homeService; + @Resource + private DictDataService dictDataService; + @Resource + private EnterpriseMapper enterpriseMapper; + @Resource + private EnterpriseInspectionsMapper enterpriseInspectionsMapper; + @Resource + private TagLibraryService tagLibraryService; @Override - public List getLeftFirst(HomeSelectVO homeSelectVO) { + public List getLeftFirst(HomeSelectVO homeSelectVO) { return bigViewDataMapper.selectTaskTypeGroupCount(homeSelectVO); } @Override public List getRightFourth(HomeSelectVO homeSelectVO) { - //时间范围 -// LocalDateTime startTime = LocalDateTime.now().minusMonths(1); -// LocalDateTime endTime = LocalDateTime.now(); -// homeSelectVO.setStartTime(startTime); -// homeSelectVO.setEndTime(endTime); -// - BigViewQOQVO bigViewQOQVO = new BigViewQOQVO(); - LocalDate today = LocalDate.now(); - bigViewQOQVO.setCurrentStartTime(today.withDayOfMonth(1).toString()); - bigViewQOQVO.setCurrentEndTime(today.toString()); - bigViewQOQVO.setPreviousStartTime(today.withDayOfMonth(1).minusMonths(1).toString()); - bigViewQOQVO.setPreviousEndTime(today.minusMonths(1).toString()); - - return bigViewDataMapper.getInspectionsTaskGroupCountCompare(bigViewQOQVO); + return bigViewDataMapper.getInspectionsTaskGroupCountCompare(); + } + + //企业数量 + public Long getEnterpriseCount(HomeSelectVO homeSelectVO) { + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.gt("status", 1); + if (homeSelectVO.getSelectWeek() != null) { + final LocalDateTime[] week = this.getWeek(homeSelectVO); + wrapper.between("create_time", week[0], week[1]); + } + return enterpriseMapper.selectCount(); + } + + //任务数量 + public Long getTaskCount(HomeSelectVO homeSelectVO) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.gt("status", 1); + if (homeSelectVO.getSelectWeek() != null) { + final LocalDateTime[] week = this.getWeek(homeSelectVO); + wrapper.between("start_date", week[0], week[1]); + } + return taskInfoMapper.selectCount(wrapper); + } + //执法数量 + public Long getTaskInspection(HomeSelectVO homeSelectVO) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.gt("status", 1); + if (homeSelectVO.getSelectWeek() != null) { + final LocalDateTime[] week = this.getWeek(homeSelectVO); + wrapper.between("create_time", week[0], week[1]); + } + return enterpriseInspectionsMapper.selectCount(); } @Override - public HomeCountResVO getCenter(HomeSelectVO homeSelectVO) { - return homeService.appCount1(homeSelectVO); + public BigViewCenterDataVO getCenter(HomeSelectVO homeSelectVO) { + BigViewCenterDataVO result = new BigViewCenterDataVO(); + result.setEnterpriseCount(this.getEnterpriseCount(homeSelectVO)); + result.setTaskCount(this.getTaskCount(homeSelectVO)); + result.setInspectionsCount(this.getTaskInspection(homeSelectVO)); + return result; } @Override - public BigViewEnterpriseCountGroup getLeftSecond(HomeSelectVO homeSelectVO) { - BigViewEnterpriseCountGroup enterpriseCountGroup = new BigViewEnterpriseCountGroup(); - final List nameCountVOS = bigViewDataMapper.enterpriseCountGroup(homeSelectVO); - enterpriseCountGroup.setEnterpriseCountGroup(nameCountVOS); - List countList = new ArrayList<>(); - if (nameCountVOS != null) { - nameCountVOS.forEach(item->{ - countList.add(item.getValue()); - }); + public List getMapData(HomeSelectVO homeSelectVO) { + BigViewCenterDataVO result = new BigViewCenterDataVO(); + // 1. 并行获取基础统计数据 + final BigViewCenterDataVO center = this.getCenter(homeSelectVO); + + // 2. 获取字典数据和区域统计 + List regions = dictDataService.getDictDataListByDictType("enterprises_area"); + + + + + + // 3. 获取企业区域分布 + + QueryWrapper enterpriseDOQueryWrapper = new QueryWrapper<>(); + enterpriseDOQueryWrapper.select("region", "count(id) as count"); + + enterpriseDOQueryWrapper.groupBy("region"); + + if (homeSelectVO.getSelectWeek() != null) { + final LocalDateTime[] week = this.getWeek(homeSelectVO); + homeSelectVO.setTime(week); + enterpriseDOQueryWrapper.between("create_time", week[0], week[1]); } - final Integer count = countList.stream().reduce(Integer::sum).orElse(0); - enterpriseCountGroup.setEnterpriseCount(count); - return enterpriseCountGroup; + Map enterpriseRegionMap = enterpriseMapper.selectList(enterpriseDOQueryWrapper).stream().collect(Collectors.toMap( + EnterpriseDO::getRegion, + EnterpriseDO::getCount, + (v1, v2) -> v1 + )); + + List taskCounts = bigViewDataMapper.getTaskCount(homeSelectVO); + + try { + // 4. 设置基础数据 + Long enterpriseCount = center.getEnterpriseCount(); + Long taskCount = center.getTaskCount(); + Long inspectionsCount = center.getInspectionsCount(); + + result.setEnterpriseCount(enterpriseCount); + result.setTaskCount(taskCount); + result.setInspectionsCount(inspectionsCount); + + // 5. 计算区域比率 + List regionStats = regions.stream().map(region -> { + ReginCountVO vo = new ReginCountVO(); + vo.setName(region.getLabel()); + vo.setLocation(region.getRemark()); + vo.setEnterpriseRate(0l); + vo.setTaskRate(0l); + vo.setTaskCount(0l); + vo.setEnterpriseCount(0l); + // 计算任务比率 + taskCounts.stream() + .filter(t -> region.getValue().equals(t.getRegion().toString())) + .findFirst() + .ifPresent(t -> { + if (t.getTaskCount() > 0 && taskCount > 0) { + // 计算原始比率(如 45.6) + double rawRate = (double) t.getTaskCount() / taskCount * 100; + // 四舍五入到整数 + long roundedRate = Math.round(rawRate); + vo.setTaskRate(roundedRate); + vo.setTaskCount(t.getTaskCount()); + } else { + // 处理无效值(根据业务需求设置默认值) + vo.setTaskRate(0l); + vo.setTaskCount(0l); + } + + + }); + + // 计算企业比率 + Optional.ofNullable(enterpriseRegionMap.get(region.getValue())) + .ifPresent(count -> { + if (count > 0 && enterpriseCount > 0) { + // 计算原始比率(如 45.6) + double rawRate = (double) count / enterpriseCount * 100; + // 四舍五入到整数 + long roundedRate = Math.round(rawRate); + vo.setEnterpriseRate(roundedRate); + vo.setEnterpriseCount(count); + } else { + // 处理无效值(根据业务需求设置默认值) + vo.setEnterpriseRate(0l); + vo.setEnterpriseCount(0L); + } + }); + + return vo; + }).collect(Collectors.toList()); + + result.setReginCountVOList(regionStats); + + } catch (Exception e) { + Thread.currentThread().interrupt(); + throw new RuntimeException("数据获取失败", e); + } + + return result.getReginCountVOList(); + } + +// @Override +// public BigViewEnterpriseCountGroup getLeftSecond(HomeSelectVO homeSelectVO) { +// BigViewEnterpriseCountGroup enterpriseCountGroup = new BigViewEnterpriseCountGroup(); +// final List nameCountVOS = bigViewDataMapper.enterpriseCountGroup(homeSelectVO); +// enterpriseCountGroup.setEnterpriseCountGroup(nameCountVOS); +// List countList = new ArrayList<>(); +// if (nameCountVOS != null) { +// nameCountVOS.forEach(item->{ +// countList.add(item.getValue()); +// }); +// } +// final Integer count = countList.stream().reduce(Integer::sum).orElse(0); +// enterpriseCountGroup.setEnterpriseCount(count); +// +// return enterpriseCountGroup; +// } + + @Override + public List getLeftSecond(HomeSelectVO homeSelectVO) { + // 1. 获取标签库子项(父ID硬编码可改为动态参数) + List tagLibraries = tagLibraryService.childrenList(26L); + + // 2. 查询任务统计结果并转换为Map: taskType -> count + Map taskTypeCountMap = taskInfoMapper.selectList( + new QueryWrapper() + .select("task_type AS taskType", "COUNT(*) AS count") // 优化COUNT(id)为COUNT(*) + .gt("status", 1) + .groupBy("task_type") + ).stream() + .collect(Collectors.toMap( + TaskInfoDO::getTaskType, + task -> task.getCount() != null ? task.getCount() : 0L, // 处理空值 + (oldVal, newVal) -> oldVal // 合并冲突策略(按需调整) + )); + + // 3. 合并标签与统计结果生成VO + List resultList = new ArrayList<>(); + for (TagLibraryDO tag : tagLibraries) { + LabelValueLongVO vo = new LabelValueLongVO(); + vo.setLabel(tag.getTagName()); + // 直接通过Map获取统计值,避免双重循环(O(1)查找) + vo.setValue(taskTypeCountMap.getOrDefault(tag.getId(), 0L)); + resultList.add(vo); + } + + return resultList; } @Override - public List getLeftThird(HomeSelectVO homeSelectVO) { - return taskInfoMapper.selectHomeGroupCount(homeSelectVO); + public List getLeftThird(HomeSelectVO homeSelectVO) { + List thirdDataVOS = new ArrayList<>(); + final List mapData = this.getMapData(homeSelectVO); + mapData.forEach(item->{ + LeftThirdDataVO leftThirdDataVO = new LeftThirdDataVO(); + leftThirdDataVO.setName(item.getName()); + if (item.getTaskCount() == 0 || item.getEnterpriseCount() == 0 ) { + leftThirdDataVO.setValue(0.0); + } else { + final double value = (double)item.getTaskCount() / item.getEnterpriseCount() * 100; + leftThirdDataVO.setValue(Math.round(value * 10) / 10.0); + } + + leftThirdDataVO.setEnterpriseCount(item.getEnterpriseCount()); + leftThirdDataVO.setTaskCount(item.getTaskCount()); + thirdDataVOS.add(leftThirdDataVO); + }); + + List top5 = thirdDataVOS.stream() + .sorted(Comparator.comparingDouble(LeftThirdDataVO::getTaskCount).reversed()) // 降序排序 + .limit(5) // 取前五 + .collect(Collectors.toList()); + + + return top5; } @Override - public List getRightFist(HomeSelectVO homeSelectVO) { + public List getRightFist(HomeSelectVO homeSelectVO) { return bigViewDataMapper.getInspectionsTaskGroupCount(homeSelectVO); } public LocalDateTime[] getWeek(HomeSelectVO homeSelectVO) { - if (homeSelectVO.getSelectWeek() != null) { - LocalDateTime[] time = new LocalDateTime[2]; - switch (homeSelectVO.getSelectWeek()) { - case 1: - time[0] = LocalDateTime.now().minusDays(7); - break; - case 2: - time[0] = LocalDateTime.now().minusMonths(1); - break; - case 3: - time[0] = LocalDateTime.now().minusYears(1); - break; - } - time[1] = LocalDateTime.now(); - homeSelectVO.setTime(time); - } + if (homeSelectVO.getSelectWeek() != null) { + LocalDateTime[] range = new LocalDateTime[2]; + LocalDateTime now = LocalDateTime.now(); + switch (homeSelectVO.getSelectWeek()) { + case 3: // 本周 + range[0] = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY)) + .with(LocalTime.MIN); // 本周一 00:00 + range[1] = now.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY)) + .with(LocalTime.MAX); // 本周日 23:59:59.999999999 + break; + case 2: // 本月 + range[0] = now.withDayOfMonth(1) + .with(LocalTime.MIN); // 本月第一天 00:00 + range[1] = now.with(TemporalAdjusters.lastDayOfMonth()) + .with(LocalTime.MAX); // 本月最后一天 23:59:59.999999999 + break; + case 1: // 本年 + range[0] = now.withDayOfYear(1) + .with(LocalTime.MIN); // 本年第一天 00:00 + range[1] = now.with(TemporalAdjusters.lastDayOfYear()) + .with(LocalTime.MAX); // 本年最后一天 23:59:59.999999999 + break; + default: + throw new IllegalArgumentException("无效的时间范围类型"); + } + homeSelectVO.setTime(range); + } return homeSelectVO.getTime(); } @@ -127,8 +352,13 @@ public class BigViewDataServiceImpl implements BigViewDataService { } @Override - public List getRightThird(HomeSelectVO homeSelectVO) { - homeSelectVO.setType(1); - return homeService.appCount2(homeSelectVO); + public List getRightThird(HomeSelectVO homeSelectVO) { + if (homeSelectVO.getSelectWeek() != null) { + final LocalDateTime[] week = this.getWeek(homeSelectVO); + homeSelectVO.setTime(week); + } + return bigViewDataMapper.getRightThird(homeSelectVO); } + + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java index 8983b76..5e4cacc 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; import cn.iocoder.yudao.module.system.service.user.AdminUserService; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; import lombok.extern.slf4j.Slf4j; import org.springframework.cache.annotation.CacheEvict; @@ -102,6 +103,15 @@ public class DeptServiceImpl implements DeptService { if (dept == null) { throw exception(DEPT_NOT_FOUND); } + //检查是否由用户在这个部门,有则不能删除 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("dept_id", id); + final List adminUserDOS = adminUserMapper.selectList(wrapper); + if (!adminUserDOS.isEmpty()) { + throw exception(DEPT_USER_ERROR); + } + + } @VisibleForTesting 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 aa6c78f..1224df5 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 @@ -121,7 +121,6 @@ public class EnterpriseServiceImpl implements EnterpriseService { //修改企业用户的审核状态为 审核中 新增企业审核表 EnterpriseAuditLogDO enterpriseAuditLogDO = new EnterpriseAuditLogDO(); enterpriseAuditLogDO.setEnterpriseId(enterprise.getId()); - enterpriseAuditLogDO.setAudit(1); enterpriseAuditLogMapper.insert(enterpriseAuditLogDO); //用户表修改用户真实姓名和手机号 @@ -203,6 +202,7 @@ public class EnterpriseServiceImpl implements EnterpriseService { createReqVO.setDeptId(user.getDeptId()); EnterpriseDO enterprise = BeanUtils.toBean(createReqVO, EnterpriseDO.class); enterprise.setDepartmentId(createReqVO.getDeptId()); + enterprise.setIsAudit(true); enterpriseMapper.insert(enterprise); if (createReqVO.getFileIds() != null && createReqVO.getFileIds().length > 0) { for (Long fileId : createReqVO.getFileIds()) { @@ -231,6 +231,7 @@ public class EnterpriseServiceImpl implements EnterpriseService { wrapper.eq(FileInfoDO::getUnitId, updateReqVO.getId().toString()); fileInfoMapper.delete(wrapper); } + if (updateReqVO.getFileIds() != null && updateReqVO.getFileIds().length > 0) { for (Long fileId : updateReqVO.getFileIds()) { FileInfoDO fileInfoDO = new FileInfoDO(); @@ -241,33 +242,23 @@ public class EnterpriseServiceImpl implements EnterpriseService { fileInfoMapper.insert(fileInfoDO); } } + //插入企业标签 + if(!CollectionUtils.isAnyEmpty(updateReqVO.getTagIds())) { + //先删除原有数据 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseTagDO::getEnterpriseId, updateReqVO.getId()); + enterpriseTagMapper.delete(wrapper); -// //如果专管员发生改变, 先删除关联表中的数据 -// 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); -// } -// } + List enterpriseTagDOList = new ArrayList<>(); + for (Long tagId : updateReqVO.getTagIds()) { + EnterpriseTagDO enterpriseTagDO = new EnterpriseTagDO(); + enterpriseTagDO.setEnterpriseId(updateReqVO.getId()); + enterpriseTagDO.setTagId(tagId); + enterpriseTagDOList.add(enterpriseTagDO); + } + enterpriseTagMapper.insertBatch(enterpriseTagDOList); + + } // 更新 EnterpriseDO updateObj = BeanUtils.toBean(updateReqVO, EnterpriseDO.class); @@ -311,6 +302,15 @@ public class EnterpriseServiceImpl implements EnterpriseService { } } + if (pageReqVO.getType() != null) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in("tag_id", pageReqVO.getType()); + final List enterpriseTagDOS = enterpriseTagMapper.selectList(queryWrapper); + if (!CollectionUtils.isAnyEmpty(enterpriseTagDOS)) { + pageReqVO.setEnterpriseIds(CollectionUtils.convertList(enterpriseTagDOS, EnterpriseTagDO::getEnterpriseId)); + } + } + final PageResult enterpriseDOPageResult = enterpriseMapper.selectPage(pageReqVO); return enterpriseDOPageResult; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java index e3f95c0..f602ebf 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsService.java @@ -65,4 +65,6 @@ public interface EnterpriseInspectionsService { List getEnterpriseInspectionsList(EnterpriseInspectionsPageReqVO pageReqVO); List changeSelectUser(Long deptId); + + PageResult inspectionsByEnterpriseId(EnterpriseInspectionsPageReqVO pageReqVO); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java index 1f5079b..ae68a2c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/enterpriseinspections/EnterpriseInspectionsServiceImpl.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.system.service.enterpriseinspections; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.RoleNameAndSelectTypeVO; +import cn.iocoder.yudao.module.system.convert.user.UserConvert; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; @@ -31,6 +32,9 @@ import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.module.system.util.EntityUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.sun.xml.bind.v2.TODO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -265,7 +269,7 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe } } - + //TODO 按状态查询不好用 final PageResult enterpriseInspectionsDOPageResult = enterpriseInspectionsMapper.selectPage(pageReqVO); if ( enterpriseInspectionsDOPageResult.getList() != null && enterpriseInspectionsDOPageResult.getList().size() > 0 ) { enterpriseInspectionsDOPageResult.getList().forEach(item->{ @@ -479,4 +483,52 @@ public class EnterpriseInspectionsServiceImpl implements EnterpriseInspectionsSe return list; } + + @Override + public PageResult inspectionsByEnterpriseId(EnterpriseInspectionsPageReqVO pageReqVO) { + // 分页查询主记录 + Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); + IPage inspectionByEnterpriseIdVOS = enterpriseInspectionsMapper.inspectionsByEnterpriseId(page, pageReqVO); + + // 无数据时直接返回空分页结果 + if (inspectionByEnterpriseIdVOS.getRecords().isEmpty()) { + return new PageResult<>(Collections.emptyList(), inspectionByEnterpriseIdVOS.getTotal()); + } + + // 批量获取所有关联的签到日志(一次性查询) + List logIds = inspectionByEnterpriseIdVOS.getRecords().stream() + .map(InspectionByEnterpriseIdVO::getLogId) + .collect(Collectors.toList()); + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SignInLogDO::getInsId, logIds); + List allSignInLogs = signInLogMapper.selectList(wrapper); + + // 按日志ID分组签到记录(内存快速匹配) + Map> signInLogMap = allSignInLogs.stream() + .collect(Collectors.groupingBy(SignInLogDO::getInsId)); + + // 构建响应列表 + List inspectionByEnterpriseIdList = + inspectionByEnterpriseIdVOS.getRecords().stream().map(item -> { + InspectionByEnterpriseIdRespVO respVO = new InspectionByEnterpriseIdRespVO(); + respVO.setInspectionsId(item.getLogId()); + respVO.setTaskId(item.getTaskId()); + respVO.setTitle(item.getTitle()); + respVO.setTime(item.getCreateTime()); + respVO.setStatus(item.getStatus()); + + // 从预加载的Map中获取签到人员(避免单独查询) + List signInLogs = signInLogMap.getOrDefault(item.getLogId(), Collections.emptyList()); + String inspectNames = signInLogs.stream() + .map(SignInLogDO::getRealName) + .collect(Collectors.joining(", ")); + respVO.setInspectNames(inspectNames); + + return respVO; + }).collect(Collectors.toList()); + + // 使用主查询的总数(而非当前页数量) + return new PageResult<>(inspectionByEnterpriseIdList, inspectionByEnterpriseIdVOS.getTotal()); + } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java index 6c3332c..4d33689 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoService.java @@ -56,6 +56,7 @@ public interface FileInfoService { PageResult getFileInfoPage(FileInfoPageReqVO pageReqVO); List getFileList(Long dictType, Long dictData, String unitId); + Map> getFileListMap(Long dictType, Long dictData, Collection unitId); /** @@ -71,4 +72,6 @@ public interface FileInfoService { void deleteFilesByDictData(Long dictType, Long dictData, String unitId); + + void deleteByInfraId(Long id) throws Exception; } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java index 6ac0fca..4942885 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/fileInfo/FileInfoServiceImpl.java @@ -171,4 +171,15 @@ public class FileInfoServiceImpl implements FileInfoService { fileInfoMapper.delete(list); } + @Override + public void deleteByInfraId(Long id) throws Exception { + + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(FileInfoDO::getInfraFileId, id); + fileInfoMapper.delete(wrapper); + + fileApi.deleteFile(id); + + } + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java index efc4714..1301dc8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionService.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.permission; import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO; import java.util.Collection; +import java.util.List; import java.util.Set; import static java.util.Collections.singleton; @@ -34,7 +35,6 @@ public interface PermissionService { boolean hasAnyRoles(Long userId, String... roles); // ========== 角色-菜单的相关方法 ========== - /** * 设置角色菜单 * @@ -143,4 +143,14 @@ public interface PermissionService { */ DeptDataPermissionRespDTO getDeptDataPermission(Long userId); + /* + 根据用户id获得角色名称列表 + */ + List getRoleListByUserId(Long userId); + + /* + 根据用户id获得角色ID列表 + */ + List getRoleIdListByUserId(Long userId); + } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java index cef739d..0eaf1f8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java @@ -329,6 +329,20 @@ public class PermissionServiceImpl implements PermissionService { return result; } + @Override + public List getRoleListByUserId(Long userId) { + final Set userRoleIdListByUserId = this.getUserRoleIdListByUserId(userId); + final List roleList = roleService.getRoleListFromCache(userRoleIdListByUserId); + return CollectionUtils.convertList(roleList, RoleDO::getName); + } + + @Override + public List getRoleIdListByUserId(Long userId) { + final Set userRoleIdListByUserId = this.getUserRoleIdListByUserId(userId); + final List roleList = roleService.getRoleListFromCache(userRoleIdListByUserId); + return CollectionUtils.convertList(roleList, RoleDO::getId); + } + /** * 获得自身的代理对象,解决 AOP 生效问题 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java index 6203cd7..6780358 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/RoleServiceImpl.java @@ -12,11 +12,14 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RolePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; 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.mysql.permission.RoleMapper; +import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants; import cn.iocoder.yudao.module.system.enums.permission.DataScopeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleCodeEnum; import cn.iocoder.yudao.module.system.enums.permission.RoleTypeEnum; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.service.impl.DiffParseFunction; @@ -51,6 +54,9 @@ public class RoleServiceImpl implements RoleService { @Resource private RoleMapper roleMapper; + @Resource + private UserRoleMapper userRoleMapper; + @Override @Transactional(rollbackFor = Exception.class) @LogRecord(type = SYSTEM_ROLE_TYPE, subType = SYSTEM_ROLE_CREATE_SUB_TYPE, bizNo = "{{#role.id}}", @@ -169,6 +175,15 @@ public class RoleServiceImpl implements RoleService { if (RoleTypeEnum.SYSTEM.getType().equals(role.getType())) { throw exception(ROLE_CAN_NOT_UPDATE_SYSTEM_TYPE_ROLE); } + + //角色下有用户,不允许删除 + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("role_id", id); + final List userRoleDOS = userRoleMapper.selectList(wrapper); + if (! userRoleDOS.isEmpty()) { + throw exception(ROLE_USER_CODE_ERROR); + } + return role; } 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 39d4910..20c4e45 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 @@ -75,4 +75,8 @@ public interface TaskInfoService { void test(); List appSelectCreateDept(); + + void audit(Long id); + + void createTaskInfoBath(TaskInfoRespVO taskInfoDO); } 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 0ef65b9..6744fc5 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 @@ -18,12 +18,14 @@ import cn.iocoder.yudao.module.system.controller.admin.tasktag.vo.TaskTagPageReq import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterprise.EnterpriseDO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; +import cn.iocoder.yudao.module.system.dal.dataobject.fileInfo.FileInfoDO; 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.fileInfo.FileInfoMapper; 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; @@ -93,6 +95,13 @@ public class TaskInfoServiceImpl implements TaskInfoService { NotifyMessageSendApi notifyMessageSendApi; @Resource private UserAreaMapper userAreaMapper; + @Resource + private FileInfoMapper fileInfoMapper; + + //企业红头文件 + public final static Long DEFAULT_DICT_DATA_QY = 4L; + + public final static Long DEFAULT_DICT_TYPE = 644L; @Override @Transactional @@ -141,6 +150,20 @@ public class TaskInfoServiceImpl implements TaskInfoService { list.add(inspection); }); + //添加红头文件 + if (createReqVO.getFileIds() != null && createReqVO.getFileIds().length > 0) { + List fileInfoDOS = new ArrayList<>(); + for (Long fileId : createReqVO.getFileIds()) { + FileInfoDO fileInfoDO = new FileInfoDO(); + fileInfoDO.setDictData(DEFAULT_DICT_DATA_QY); + fileInfoDO.setDictType(DEFAULT_DICT_TYPE); + fileInfoDO.setUnitId(taskInfo.getId().toString()); + fileInfoDO.setInfraFileId(fileId); + fileInfoDOS.add(fileInfoDO); + } + fileInfoMapper.insertBatch(fileInfoDOS); + } + enterpriseInspectionsMapper.insertBatch(list); } // 返回 @@ -149,11 +172,27 @@ public class TaskInfoServiceImpl implements TaskInfoService { @Override + @Transactional public void updateTaskInfo(TaskInfoSaveReqVO updateReqVO) { // 校验存在 validateTaskInfoExists(updateReqVO.getId()); // 更新 TaskInfoDO updateObj = BeanUtils.toBean(updateReqVO, TaskInfoDO.class); + + //添加红头文件 + if (updateReqVO.getFileIds() != null && updateReqVO.getFileIds().length > 0) { + List fileInfoDOS = new ArrayList<>(); + for (Long fileId : updateReqVO.getFileIds()) { + FileInfoDO fileInfoDO = new FileInfoDO(); + fileInfoDO.setDictData(DEFAULT_DICT_DATA_QY); + fileInfoDO.setDictType(DEFAULT_DICT_TYPE); + fileInfoDO.setUnitId(updateReqVO.getId().toString()); + fileInfoDO.setInfraFileId(fileId); + fileInfoDOS.add(fileInfoDO); + } + fileInfoMapper.insertBatch(fileInfoDOS); + } + taskInfoMapper.updateById(updateObj); } @@ -265,7 +304,6 @@ public class TaskInfoServiceImpl implements TaskInfoService { } Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); - log.info("taskInfoDOIPage:{}", pageReqVO); final IPage taskInfoDOIPage = taskInfoMapper.selectMyPage(page, pageReqVO); final PageResult taskInfoDOPageResult = new PageResult<>(taskInfoDOIPage.getRecords(), taskInfoDOIPage.getTotal()); @@ -426,4 +464,93 @@ public class TaskInfoServiceImpl implements TaskInfoService { return taskInfoMapper.appSelectCreateDept(map); } + @Override + public void audit(Long id) { + final TaskInfoDO taskInfoDO = validateTaskInfoExists(id); + // 当前日期 + LocalDateTime currentDate = LocalDateTime.now(); + + //大于当前时间直接发布 + // 比较逻辑 + final LocalDateTime startDate = taskInfoDO.getStartDate(); + final LocalDate localDate = startDate.toLocalDate(); + final LocalDateTime startTime = localDate.atTime(taskInfoDO.getExecCycle(), 0); + + if (currentDate.isBefore(startTime)) { + taskInfoDO.setStatus(1); + taskInfoMapper.updateById(taskInfoDO); + } else { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, taskInfoDO.getId()); + final List enterpriseInspectionsDOS = enterpriseInspectionsMapper.selectList(wrapper); + + TaskInfoRespVO taskInfoRespVO = new TaskInfoRespVO(); + BeanUtils.copyProperties(taskInfoDO, taskInfoRespVO); + taskInfoRespVO.setEnterpriseIdeTasks(enterpriseInspectionsDOS); + createTaskInfoBath(taskInfoRespVO); + } + } + + /* + 直接发布任务 + */ + @Override + public void createTaskInfoBath(TaskInfoRespVO taskInfoDO) { + taskInfoDO.getEnterpriseIdeTasks().forEach(x ->{ + if(x.getUserId()!= null){ + + try { + //发送消息); + SocialWxaSubscribeMessageSendReqDTO reqDTO = new SocialWxaSubscribeMessageSendReqDTO(); + reqDTO.setUserType(1); + reqDTO.setTemplateTitle("环保任务通知"); + reqDTO.setPage("sub/task/detail?id="+taskInfoDO.getId()); + reqDTO.setUserId(x.getUserId()); + Map message = new HashMap<>(); + message.put("thing2", StringUtil.truncateString(taskInfoDO.getTitle(), 15)); + message.put("time5", DateUtil.format(taskInfoDO.getStartDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + message.put("thing4", StringUtil.truncateString(taskInfoDO.getDescription(), 15)); + message.put("time3", DateUtil.format(taskInfoDO.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + reqDTO.setMessages(message); + socialClientApi.sendWxaSubscribeMessage(reqDTO); + } + catch (Exception e){ + log.error("任务发送通知错误:",e.toString()); + } + + //修改任务状态 + final TaskInfoDO updateTask = taskInfoMapper.selectById(taskInfoDO.getId()); + updateTask.setStatus(2); + taskInfoMapper.updateById(updateTask); + + //执法任务更改状态 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getTaskId()); + List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); + if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size() > 0) { + List list = new ArrayList<>(); + for (EnterpriseInspectionsDO enterpriseInspectionsDO : enterpriseInspectionsDOList) { + //站内信发送通知 + 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().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); + templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY) ); + templateParams.put("url", "/sub/task/detail?id="+ enterpriseInspectionsDO.getTaskId()); + + notifyMessage.setTemplateParams(templateParams); + notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); + + enterpriseInspectionsDO.setStatus(2); + list.add(enterpriseInspectionsDO); + } + enterpriseInspectionsMapper.updateBatch(list); + } + } + + }); + } + } 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 dae0f47..56c2588 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,11 @@ public class AdminUserServiceImpl implements AdminUserService { // 2.2 更新岗位 updateUserPost(updateReqVO, updateObj); + //更新职位 + if (updateReqVO.getRoleIds() != null) { + permissionService.assignUserRole(updateReqVO.getId(), updateReqVO.getRoleIds()); + } + //2.3 添加管理区域 todo // 3. 记录操作日志上下文 diff --git a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/bigviewdata/BigViewDataMapper.xml b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/bigviewdata/BigViewDataMapper.xml index 880a8d9..723dc7c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/bigviewdata/BigViewDataMapper.xml +++ b/yudao-module-system/yudao-module-system-biz/src/main/resources/mapper/bigviewdata/BigViewDataMapper.xml @@ -54,94 +54,186 @@ GROUP BY status; + + 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 1ed17ad..215baa8 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 @@ -21,4 +21,21 @@ WHERE ei.deleted = 0 and el.correction_time < NOW() + 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 8ee3713..814210c 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 @@ -50,9 +50,6 @@ GROUP BY t.id ORDER BY t.create_time DESC - - -