diff --git a/Cpop-Api/src/main/java/com/cpop/api/tencent/wxWork/handler/WebHookSendHandler.java b/Cpop-Api/src/main/java/com/cpop/api/tencent/wxWork/handler/WebHookSendHandler.java index b8b40db..5816804 100644 --- a/Cpop-Api/src/main/java/com/cpop/api/tencent/wxWork/handler/WebHookSendHandler.java +++ b/Cpop-Api/src/main/java/com/cpop/api/tencent/wxWork/handler/WebHookSendHandler.java @@ -13,7 +13,7 @@ import java.util.List; /** * @author DB * @createTime 2023/09/15 16:24 - * @description + * @description 企微机器人 */ @Component public class WebHookSendHandler { diff --git a/Cpop-Oam/Cpop-Oam-Web/src/main/java/com/cpop/oam/web/CpopOamWebApplication.java b/Cpop-Oam/Cpop-Oam-Web/src/main/java/com/cpop/oam/web/CpopOamWebApplication.java index e8eeb4c..6583334 100644 --- a/Cpop-Oam/Cpop-Oam-Web/src/main/java/com/cpop/oam/web/CpopOamWebApplication.java +++ b/Cpop-Oam/Cpop-Oam-Web/src/main/java/com/cpop/oam/web/CpopOamWebApplication.java @@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; /** * @author DB @@ -11,6 +12,7 @@ import org.springframework.scheduling.annotation.EnableAsync; @SpringBootApplication(scanBasePackages = {"com.cpop.**"}) @MapperScan("com.cpop.**.mapper") @EnableAsync +@EnableScheduling public class CpopOamWebApplication { public static void main(String[] args) { diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/StaffController.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/StaffController.java index ec41a82..30796be 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/StaffController.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/controller/backstage/StaffController.java @@ -1,5 +1,8 @@ package com.cpop.oam.business.controller.backstage; +import com.cpop.core.base.entity.LoginUser; +import com.cpop.core.base.enums.InitRoleEnum; +import com.cpop.core.utils.SecurityUtils; import com.cpop.system.business.service.RoleService; import com.mybatisflex.core.paginate.Page; import com.mybatisflex.core.query.QueryWrapper; @@ -14,6 +17,7 @@ import com.cpop.oam.business.service.StaffService; import com.cpop.oam.business.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.catalina.security.SecurityUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; @@ -123,9 +127,11 @@ public class StaffController { @ApiOperation("获取所有角色信息") @GetMapping("/getAllRoleList") public R> getAllSysRoleList() { + LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); List list = SpringUtils.getBean(RoleService.class).listAs(QueryWrapper.create() .where(ROLE.STATUS.eq(true)) - .and(ROLE.ROLE_VALUE.ne(Constants.SUPER_ADMIN_VALUE)) + .and(ROLE.ID.ne(InitRoleEnum.SUPER_OAM_ROLE.getId())) + .and(ROLE.USER_TYPE.eq(loginUser.getUserType())) .orderBy(ROLE.ORDER_NO.asc()) , RoleVo.class); return R.ok(list); diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/dto/StaffDto.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/dto/StaffDto.java new file mode 100644 index 0000000..a976ad1 --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/dto/StaffDto.java @@ -0,0 +1,22 @@ +package com.cpop.oam.business.dto; + +import lombok.Data; + +/** + * @author DB + * @createTime 2023/11/22 18:26 + * @description + */ +@Data +public class StaffDto { + + /** + * 手机号 + */ + private String phoneNumber; + + /** + * 姓名 + */ + private String name; +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DutyService.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DutyService.java index d59db23..5599f34 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DutyService.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/DutyService.java @@ -41,4 +41,12 @@ public interface DutyService extends IService { * @param dutyDate 值班日期 */ void removeDutyByDate(String dutyDate); + + /** + * @descriptions 每天9点通知值班人员 + * @author DB + * @date 2023/11/22 18:09 + * @return: void + */ + void dutyNotice(); } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DutyServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DutyServiceImpl.java index bbe4b06..4b5b301 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DutyServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/DutyServiceImpl.java @@ -1,6 +1,14 @@ package com.cpop.oam.business.service.impl; +import com.cpop.api.tencent.wxWork.handler.WebHookSendHandler; +import com.cpop.core.base.exception.ServiceException; +import com.cpop.core.base.table.SysUser; +import com.cpop.oam.business.dto.StaffDto; +import com.cpop.oam.business.vo.StaffPageVo; +import com.cpop.oam.business.vo.StaffVo; +import com.cpop.oam.framework.constant.WebHookKeyConstant; import com.mybatisflex.core.query.QueryWrapper; +import com.mybatisflex.core.row.DbChain; import com.mybatisflex.spring.service.impl.ServiceImpl; import com.cpop.common.utils.DateUtils; import com.cpop.common.utils.StringUtils; @@ -13,19 +21,20 @@ import com.cpop.oam.business.mapper.DutyMapper; import com.cpop.oam.business.service.DutyService; import com.cpop.oam.business.service.StaffService; import com.cpop.oam.business.vo.DutyListVo; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.IOException; import java.sql.Date; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; +import static com.cpop.core.base.table.table.SysUserTableDef.SYS_USER; import static com.cpop.oam.business.entity.table.DutyTableDef.DUTY; +import static com.cpop.oam.business.entity.table.StaffTableDef.STAFF; /** * 值班表 服务层实现。 @@ -36,6 +45,9 @@ import static com.cpop.oam.business.entity.table.DutyTableDef.DUTY; @Service("oamDutyService") public class DutyServiceImpl extends ServiceImpl implements DutyService { + @Autowired + private WebHookSendHandler webHookSendHandler; + /** * @Description: 查询值班列表(当月) * @param bo 请求参数 @@ -75,6 +87,17 @@ public class DutyServiceImpl extends ServiceImpl implements Du item.setTechnologyStaffName(staffMap.get(item.getTechnologyStaffId())); }); return list; + //查询过多 + /*return this.mapper.selectListByQueryAs(QueryWrapper.create() + .select(DUTY.ID, DUTY.DUTY_DATE, DUTY.SERVICE_STAFF_ID, DUTY.TECHNOLOGY_STAFF_ID) + .where(DUTY.DUTY_DATE.ge(firstDay).and(DUTY.DUTY_DATE.le(lastDay))), + DutyListVo.class, + //服务人员名 + item -> item.field(DutyListVo::getServiceStaffName) + .queryWrapper(serviceStaffName -> queryChain().select(STAFF.NAME).from(STAFF).where(STAFF.ID.eq(serviceStaffName.getServiceStaffId()))), + //技术人员名 + item -> item.field(DutyListVo::getTechnologyStaffName) + .queryWrapper(serviceStaffName -> queryChain().select(STAFF.NAME).from(STAFF).where(STAFF.ID.eq(serviceStaffName.getTechnologyStaffId()))));*/ } /** @@ -113,4 +136,29 @@ public class DutyServiceImpl extends ServiceImpl implements Du public void removeDutyByDate(String dutyDate) { this.remove(QueryWrapper.create().where(DUTY.DUTY_DATE.eq(dutyDate))); } + + /** + * @descriptions 每天9点通知值班人员 + * @author DB + * @date 2023/11/22 18:10 + * @return: void + */ + @Override + public void dutyNotice() { + LocalDate now = LocalDate.now(); + //获取当天值班员工 + Duty one = this.queryChain().where(DUTY.DUTY_DATE.eq(now)).one(); + //获取当天技术值班人员 + StaffDto staff = DbChain.table(SYS_USER).select(SYS_USER.PHONE_NUMBER, STAFF.NAME).from(SYS_USER) + .leftJoin(STAFF).on(STAFF.USER_ID.eq(SYS_USER.ID)) + .where(STAFF.ID.eq(one.getTechnologyStaffId())).oneAs(StaffDto.class); + //技术售后群提醒 + try { + webHookSendHandler.webHookSendText(WebHookKeyConstant.ORDER_INFO_BOT, Collections.singletonList(staff.getPhoneNumber()), + "===今日值班" + staff.getName() + "===" + , false); + } catch (IOException e) { + throw new ServiceException(e.getMessage()); + } + } } diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/FinanceReimburseServiceImpl.java b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/FinanceReimburseServiceImpl.java index 9082039..c761462 100644 --- a/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/FinanceReimburseServiceImpl.java +++ b/Cpop-Oam/src/main/java/com/cpop/oam/business/service/impl/FinanceReimburseServiceImpl.java @@ -23,7 +23,6 @@ import com.cpop.oam.business.service.FinanceReimburseStageService; import com.cpop.oam.business.vo.FinanceReimburseAuditPageVo; import com.cpop.oam.business.vo.FinanceReimbursePageVo; import com.cpop.oam.business.vo.ReimbursePersonStatisticVo; -import com.cpop.oam.framework.utils.OamUtils; import org.springframework.stereotype.Service; import java.math.BigDecimal; @@ -131,9 +130,9 @@ public class FinanceReimburseServiceImpl extends ServiceImpl implements .select(SYS_USER.USER_NAME,SYS_USER.NICK_NAME, SYS_USER.EMAIL, SYS_USER.PHONE_NUMBER, SYS_USER.SEX, SYS_USER.AVATAR, SYS_USER.STATUS, SYS_USER.PASSWORD) .select(ROLE.ROLE_NAME) //将部门id分组 - .select(groupConcat(STAFF_MID_DEPT.DEPT_ID)) + .select(groupConcat(STAFF_MID_DEPT.DEPT_ID).as(StaffPageVo::getDeptId)) .from(STAFF) .leftJoin(SYS_USER).on(SYS_USER.ID.eq(STAFF.USER_ID)) .leftJoin(ROLE).on(ROLE.ID.eq(STAFF.ROLE_ID)) @@ -332,8 +322,8 @@ public class StaffServiceImpl extends ServiceImpl implements @Override public void modifyUserPassword(ModifyUserPasswordBo bo) { //只允许超级管理员或自己修改面膜 - OamStaffLoginInfo loginStaffInfo = SpringUtils.getBean(OamUtils.class).getLoginStaffInfo(); - String userName = loginStaffInfo.getUserName(); + LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); + String userName = loginUser.getUsername(); //同数据库密码进行比较 SysUser user = DbChain.table(SYS_USER) .where(SYS_USER.ID.eq(bo.getUserId())) diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/tasks/OamScheduledTasks.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/tasks/OamScheduledTasks.java new file mode 100644 index 0000000..9eb5b7e --- /dev/null +++ b/Cpop-Oam/src/main/java/com/cpop/oam/framework/tasks/OamScheduledTasks.java @@ -0,0 +1,34 @@ +package com.cpop.oam.framework.tasks; + +import com.cpop.oam.business.service.DutyService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; + +/** + * @author DB + * @createTime 2023/11/22 18:07 + * @description + */ +@Slf4j +@Configuration +@Profile("prod") +public class OamScheduledTasks { + + @Autowired + private DutyService dutyService; + + /** + * @descriptions 每天9点通知值班人员 + * @author DB + * @date 2023/11/22 18:08 + * @return: void + */ + @Scheduled(cron = "0 0 9 * * *") + public void dutyNotice() { + dutyService.dutyNotice(); + } +} diff --git a/Cpop-Oam/src/main/java/com/cpop/oam/framework/utils/OamUtils.java b/Cpop-Oam/src/main/java/com/cpop/oam/framework/utils/OamUtils.java deleted file mode 100644 index 0d90a1b..0000000 --- a/Cpop-Oam/src/main/java/com/cpop/oam/framework/utils/OamUtils.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.cpop.oam.framework.utils; - -import com.alibaba.fastjson.JSONObject; -import com.cpop.core.base.entity.LoginUser; -import com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo; -import com.cpop.core.base.enums.UserType; -import com.cpop.core.service.RedisService; -import com.cpop.core.utils.SecurityUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * @author DB - * @createTime 2023/09/21 15:59 - * @description - */ -@Component -public class OamUtils { - - @Autowired - private RedisService redisService; - - /** - * @descriptions 获取登陆员工信息 - * @author DB - * @date 2023/09/21 16:00 - * @return com.cpop.core.base.entity.loginInfo.OamStaffLoginInfo - */ - public OamStaffLoginInfo getLoginStaffInfo() { - //获取当前登录用户信息 - LoginUser loginUser = SecurityUtils.getInstance().getLoginUser(); - //获取缓存信息 - JSONObject jsonObject = redisService.getCacheObject(UserType.OAM_USER.getKey() + loginUser.getUsername()); - return jsonObject.getJSONObject("user").toJavaObject(OamStaffLoginInfo.class); - } -}