diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/UserTypeEnum.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/UserTypeEnum.java index 5a42ec1..99ee4e4 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/UserTypeEnum.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/UserTypeEnum.java @@ -13,9 +13,12 @@ import java.util.Arrays; @AllArgsConstructor @Getter public enum UserTypeEnum implements IntArrayValuable { - ORDINARY(1, "普通用户"), // 面向 c 端,企业用户 - MEMBER(2, "企业用户"), // 面向 c 端,企业用户 - ADMIN(3, "局内用户"); // 面向 b 端,管理后台 +// ORDINARY(1, "普通用户"), // 面向 c 端,企业用户 +// MEMBER(2, "企业用户"), // 面向 c 端,企业用户 +// ADMIN(3, "局内用户"); // 面向 b 端,管理后台 + + MEMBER(1, "会员"), // 面向 c 端,普通用户 + ADMIN(2, "管理员"); // 面向 b 端,管理后台 public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(UserTypeEnum::getValue).toArray(); 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 a9603d9..0e96010 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 @@ -66,7 +66,7 @@ public class TaskInfoDO extends BaseDO { /** * 任务状态 */ - private String status; + private Integer status; /** * 任务计划开始时间 */ 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 3fdce35..c350bf0 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 @@ -9,8 +9,10 @@ import cn.iocoder.yudao.module.system.api.social.SocialClientApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO; import cn.iocoder.yudao.module.system.controller.admin.taskinfo.vo.TaskInfoRespVO; import cn.iocoder.yudao.module.system.dal.dataobject.enterpriseinspections.EnterpriseInspectionsDO; +import cn.iocoder.yudao.module.system.dal.dataobject.taskinfo.TaskInfoDO; 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.taskinfo.TaskInfoMapper; import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import lombok.extern.slf4j.Slf4j; @@ -18,6 +20,7 @@ import org.redisson.executor.TasksService; import org.springframework.stereotype.Component; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -35,6 +38,8 @@ public class TaskSendStartMessageJob implements JobHandler { EnterpriseInspectionsMapper enterpriseInspectionsMapper; @Resource NotifyMessageSendApi notifyMessageSendApi; + @Resource + TaskInfoMapper taskInfoMapper; @Override public String execute(String param) throws Exception { @@ -58,31 +63,43 @@ public class TaskSendStartMessageJob implements JobHandler { message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY)); reqDTO.setMessages(message); socialClientApi.sendWxaSubscribeMessage(reqDTO); + } catch (Exception e){ log.error("任务发送通知错误:",e.toString()); } + + //修改任务状态 + final TaskInfoDO taskInfoDO = taskInfoMapper.selectById(beforeTaskInfo.getId()); + taskInfoDO.setStatus(2); + taskInfoMapper.updateById(taskInfoDO); + + //执法任务更改状态 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getId()); + 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", beforeTaskInfo.getTitle()); + templateParams.put("startTime", beforeTaskInfo.getStartDate()); + notifyMessage.setTemplateParams(templateParams); + notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); + + enterpriseInspectionsDO.setStatus(2); + list.add(enterpriseInspectionsDO); + } + enterpriseInspectionsMapper.updateBatch(list); + } + + } - //执法任务更改状态 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(EnterpriseInspectionsDO::getTaskId, x.getId()); - List enterpriseInspectionsDOList = enterpriseInspectionsMapper.selectList(wrapper); - if(enterpriseInspectionsDOList!=null && enterpriseInspectionsDOList.size()>0){ - 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", beforeTaskInfo.getTitle()); - templateParams.put("startTime", beforeTaskInfo.getStartDate()); - notifyMessage.setTemplateParams(templateParams); - notifyMessageSendApi.sendSingleMessageToAdmin(notifyMessage); - enterpriseInspectionsDO.setStatus(2); - } - } - enterpriseInspectionsMapper.updateBatch(enterpriseInspectionsDOList); }); }); return "发送消息任务数量:"+ beforeTaskInfoList.size(); 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 cfbf627..bdfe6c1 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 @@ -307,7 +307,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { AuthUser authUser = socialClientService.getAuthUser( SocialTypeEnum.WECHAT_MINI_APP.getType(), - reqVO.getUserType(), // 假设用户类型为会员 + UserTypeEnum.ADMIN.getValue(),// 假设用户类型为会员 reqVO.getCode(), reqVO.getState() ); @@ -332,14 +332,6 @@ public class AdminAuthServiceImpl implements AdminAuthService { throw exception(INSERT_ERROR); } - if (reqVO.getUserType() == UserTypeEnum.ADMIN.getValue()) { - //给一个默认的专管员角色 - UserRoleDO userRoleDO = new UserRoleDO(); - userRoleDO.setUserId(user.getId()); - userRoleDO.setRoleId(155L); - userRoleMapper.insert(userRoleDO); - } - user = userService.autoRegisterUser(authUser, reqVO.getUserType()); user.setIsBand(false); 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 31c9b67..07ed606 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 @@ -88,6 +88,8 @@ public class TaskInfoServiceImpl implements TaskInfoService { //随机数 taskInfo.setTaskNumber(serialNumber); + //测试直接触发 TODO +// taskInfo.setStatus(2); taskInfoMapper.insert(taskInfo); //添加任务标签 @@ -110,6 +112,9 @@ public class TaskInfoServiceImpl implements TaskInfoService { inspection.setTaskId(taskInfo.getId()); inspection.setEnterpriseId(item); + //测试直接触发 TODO +// inspection.setStatus(2); + if (enterpriseDO.getUserId() != null) { inspection.setUserId(enterpriseDO.getUserId()); } 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 0bb5791..5383bc0 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 @@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.exception.ServiceException; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; @@ -22,10 +23,12 @@ import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*; import cn.iocoder.yudao.module.system.controller.admin.userAuditlog.vo.UserAuditLogSaveReqVO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO; import cn.iocoder.yudao.module.system.dal.dataobject.dept.UserPostDO; +import cn.iocoder.yudao.module.system.dal.dataobject.permission.UserRoleDO; import cn.iocoder.yudao.module.system.dal.dataobject.social.SocialUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.userAuditlog.UserAuditLogDO; import cn.iocoder.yudao.module.system.dal.mysql.dept.UserPostMapper; +import cn.iocoder.yudao.module.system.dal.mysql.permission.UserRoleMapper; import cn.iocoder.yudao.module.system.dal.mysql.user.AdminUserMapper; import cn.iocoder.yudao.module.system.dal.mysql.userAuditlog.UserAuditLogMapper; import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; @@ -95,6 +98,8 @@ public class AdminUserServiceImpl implements AdminUserService { private UserAuditLogMapper userAuditLogMapper; @Resource private AdminUserMapper adminUserMapper; + @Resource + private UserRoleMapper userRoleMapper; @Override @Transactional(rollbackFor = Exception.class) @@ -207,6 +212,12 @@ public class AdminUserServiceImpl implements AdminUserService { reqVO.setAudit(1); } + //给一个默认的专管员角色 + UserRoleDO userRoleDO = new UserRoleDO(); + userRoleDO.setUserId(id); + userRoleDO.setRoleId(155L); + userRoleMapper.insert(userRoleDO); + // 执行更新 userMapper.updateById(BeanUtils.toBean(reqVO, AdminUserDO.class).setId(id)); } 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 0ed6499..8b72d43 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 @@ -85,7 +85,7 @@ WHERE ei.deleted = 0 AND e.deleted = 0 and ei.status = 2 - and e.department_id = #{deptId} + and e.department_id = #{deptId} and su.real_name is not null and e.department_id != 100 diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 1c9a812..863011f 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -46,7 +46,7 @@ spring: primary: master datasource: master: - url: jdbc:mysql://82.156.141.150:3306/hb-yudao?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + url: jdbc:mysql://192.168.2.5:3306/hb-yudao?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 @@ -54,14 +54,8 @@ spring: # url: jdbc:dm://127.0.0.1:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 # url: jdbc:kingbase8://127.0.0.1:54321/test # 人大金仓 KingbaseES 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/postgres # OpenGauss 连接的示例 - username: huanbao - password: DF64GBXeC4TkZcAP - # username: sa # SQL Server 连接的示例 - # password: Yudao@2024 # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA001 # DM 连接的示例 - # username: root # OpenGauss 连接的示例 - # password: Yudao@2024 # OpenGauss 连接的示例 + username: root + password: jingke@123 slave: # 模拟从库,可根据自己需要修改 lazy: true # 开启懒加载,保证启动速度 url: jdbc:mysql://192.168.2.5:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true