From 603e962aa956a72196ca4db0075b481e57e4cee0 Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Tue, 13 Aug 2024 18:38:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=81=E4=B8=9A=E7=AE=A1=E7=90=86-=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iocoder/yudao/common/BaseConstants.java | 2 + .../admin/BasePromotionController.java | 55 ++++++++++++ .../module/custom/entity/BasePromotion.java | 49 ++++++++++ .../custom/mapper/BasePromotionMapper.java | 28 ++++++ .../custom/service/BasePromotionService.java | 17 ++++ .../impl/BasePromotionServiceImpl.java | 32 +++++++ .../module/custom/vo/BasePromotionReqVO.java | 13 +++ .../module/custom/vo/BasePromotionRespVO.java | 13 +++ .../NoticeCompanyQualsExpiredJob.java | 23 +++++ .../mapper/custom/BasePromotionMapper.xml | 21 +++++ .../admin/CompanyStaffController.java | 9 +- .../staff/service/CompanyStaffService.java | 7 ++ .../service/impl/CompanyStaffServiceImpl.java | 90 +++++++++++++++---- ...dateCompanyStaffWorkAndJoinedYearsJob.java | 30 +++++++ .../mapper/staff/CompanyStaffChangeMapper.xml | 2 +- .../framework/tenant/core/job/TenantJob.java | 2 +- .../src/main/resources/application-local.yaml | 2 +- 17 files changed, 372 insertions(+), 23 deletions(-) create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/BasePromotionController.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/BasePromotion.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/BasePromotionMapper.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionReqVO.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionRespVO.java create mode 100644 dl-module-base/src/main/java/cn/iocoder/yudao/scheduled/NoticeCompanyQualsExpiredJob.java create mode 100644 dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml create mode 100644 dl-module-company/src/main/java/cn/iocoder/yudao/scheduled/UpdateCompanyStaffWorkAndJoinedYearsJob.java diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java index b6b9a208..a85a0090 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/BaseConstants.java @@ -41,4 +41,6 @@ public class BaseConstants { public static final Integer UNIQUE_CODE_LEN = 6; /**企业功能标识*/ public static final String FUNC_COMPANY = "company"; + /**批量操作数据量*/ + public static final Integer BATCH_SIZE = 100; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/BasePromotionController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/BasePromotionController.java new file mode 100644 index 00000000..9e8a621e --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/BasePromotionController.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.custom.controller.admin; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.custom.service.BasePromotionService; +import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +/** + * 推广记录表 控制层 + * + * @author 小李 + * @date 16:42 2024/8/13 + **/ +@Tag(name = "管理后台 - 推广记录") +@Validated +@RestController +@RequestMapping("/base/promotion") +public class BasePromotionController { + + @Resource + private BasePromotionService promotionService; + + /** + * 分页查询推广记录 + * + * @param pageReqVO 查询条件对象 + * @param pageNo 页码 + * @param pageSize 条数 + * @author 小李 + * @date 16:50 2024/8/13 + **/ + @GetMapping("/page") + @Operation(summary = "分页查询推广记录") + @PreAuthorize("@ss.hasPermission('base:promotion:query')") + public CommonResult> getBasePromotionPage(BasePromotionReqVO pageReqVO, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNo, pageSize); + return success(promotionService.queryListPage(pageReqVO, page)); + } +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/BasePromotion.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/BasePromotion.java new file mode 100644 index 00000000..00f5fad4 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/BasePromotion.java @@ -0,0 +1,49 @@ +package cn.iocoder.yudao.module.custom.entity; + +import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 推广记录表实体 + * @author 小李 + * @date 16:31 2024/8/13 +**/ +@TableName(value ="base_promotion") +@Data +@EqualsAndHashCode(callSuper = true) +public class BasePromotion extends TenantBaseDO { + /** 主键标识 */ + @TableId(type = IdType.ASSIGN_ID) + private String id; + + /** 推广用户id(system_users表的id) */ + private Long oldUserId; + + /** 推广用户姓名 */ + private String oldUserName; + + /** 推广渠道 */ + private String promotionChannel; + + /** 被推广用户id(system_users表的id) */ + private Long newUserId; + + /** 被推广用户姓名 */ + private String newUserName; + + /** 被推广用户注册时间 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + private Date registerTime; + + /** 被推广用户注册时填写的推广码 */ + private String uniqueCode; +} \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/BasePromotionMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/BasePromotionMapper.java new file mode 100644 index 00000000..10845602 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/mapper/BasePromotionMapper.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.custom.mapper; + +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO; +import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 推广记录表 Mapper + * @author 小李 + * @date 16:38 2024/8/13 +**/ +@Mapper +public interface BasePromotionMapper extends BaseMapper { + + /** + * 分页查询推广记录 + * + * @param pageReqVO 查询条件对象 + * @author 小李 + * @date 16:50 2024/8/13 + **/ + IPage queryListPage(@Param("map") BasePromotionReqVO pageReqVO, Page page); +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java new file mode 100644 index 00000000..055a525f --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/BasePromotionService.java @@ -0,0 +1,17 @@ +package cn.iocoder.yudao.module.custom.service; + +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO; +import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + * 推广记录表 接口服务 + * @author 小李 + * @date 16:40 2024/8/13 +**/ +public interface BasePromotionService extends IService { + IPage queryListPage(BasePromotionReqVO pageReqVO, Page page); +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java new file mode 100644 index 00000000..08d88f0c --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/BasePromotionServiceImpl.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.custom.service.impl; + +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.custom.mapper.BasePromotionMapper; +import cn.iocoder.yudao.module.custom.service.BasePromotionService; +import cn.iocoder.yudao.module.custom.vo.BasePromotionReqVO; +import cn.iocoder.yudao.module.custom.vo.BasePromotionRespVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 推广记录表 接口实现类 + * @author 小李 + * @date 16:41 2024/8/13 +**/ +@Service +public class BasePromotionServiceImpl extends ServiceImpl implements BasePromotionService { + + /** + * 分页查询推广记录 + * + * @param pageReqVO 查询条件对象 + * @author 小李 + * @date 16:50 2024/8/13 + **/ + @Override + public IPage queryListPage(BasePromotionReqVO pageReqVO, Page page) { + return baseMapper.queryListPage(pageReqVO, page); + } +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionReqVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionReqVO.java new file mode 100644 index 00000000..103a3141 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionReqVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.custom.vo; + +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import lombok.Data; + +/** + * 推广记录表查询VO + * @author 小李 + * @date 16:36 2024/8/13 +**/ +@Data +public class BasePromotionReqVO extends BasePromotion { +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionRespVO.java new file mode 100644 index 00000000..f9b1575e --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/BasePromotionRespVO.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.custom.vo; + +import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import lombok.Data; + +/** + * 推广记录表响应或提交VO + * @author 小李 + * @date 16:37 2024/8/13 +**/ +@Data +public class BasePromotionRespVO extends BasePromotion { +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/scheduled/NoticeCompanyQualsExpiredJob.java b/dl-module-base/src/main/java/cn/iocoder/yudao/scheduled/NoticeCompanyQualsExpiredJob.java new file mode 100644 index 00000000..a2252460 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/scheduled/NoticeCompanyQualsExpiredJob.java @@ -0,0 +1,23 @@ +package cn.iocoder.yudao.scheduled; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 定时提醒企业管理员资质过期 + * @author 小李 + * @date 16:02 2024/8/13 +**/ +@Component +@TenantJob +@Slf4j +public class NoticeCompanyQualsExpiredJob implements JobHandler { + + @Override + public String execute(String param) throws Exception { + // TODO + return null; + } +} diff --git a/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml b/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml new file mode 100644 index 00000000..555e355c --- /dev/null +++ b/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java index 4e8421e6..3c181ceb 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java @@ -13,7 +13,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.ibatis.annotations.Param; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -154,6 +153,8 @@ public class CompanyStaffController { * @date 14:59 2024/8/7 **/ @GetMapping("/labels") + @Operation(summary = "获取当前功能的标签") + @PreAuthorize("@ss.hasPermission('company:staff:query')") public CommonResult> getLabels() { return success(staffService.getLabels()); } @@ -165,6 +166,8 @@ public class CompanyStaffController { * @date 15:54 2024/8/8 **/ @GetMapping("/list") + @Operation(summary = "获取当前登录用户部门下所有员工信息") + @PreAuthorize("@ss.hasPermission('company:staff:query')") public CommonResult> getStaffList() { return success(staffService.getStaffList()); } @@ -177,6 +180,8 @@ public class CompanyStaffController { * @date 14:03 2024/8/9 **/ @GetMapping("/checkWorkNo") + @Operation(summary = "验证工号是否重复") + @PreAuthorize("@ss.hasPermission('company:staff:query')") public CommonResult checkWorkNo(@RequestParam("workNo") String workNo) { return success(staffService.checkWorkNo(workNo)); } @@ -189,6 +194,8 @@ public class CompanyStaffController { * @date 16:21 2024/8/9 **/ @PostMapping("/resetPassword") + @Operation(summary = "重置员工登录密码") + @PreAuthorize("@ss.hasPermission('company:staff:resetPassword')") public CommonResult resetPassword(@RequestBody CompanyStaffRespVO staffRespVO) { staffService.resetPassword(staffRespVO); return CommonResult.ok(); diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java index ca48208d..3c188bb6 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/CompanyStaffService.java @@ -87,4 +87,11 @@ public interface CompanyStaffService extends IService { * @param workNo 输入的工号 **/ Boolean checkWorkNo(String workNo); + + /** + * 更新员工的工龄和司龄 + * @author 小李 + * @date 11:41 2024/8/13 + **/ + void updateStaffWorkAndJoinedYears(); } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java index 72678e6d..f0ff361e 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffServiceImpl.java @@ -4,10 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.BaseConstants; import cn.iocoder.yudao.common.CommonErrorCodeConstants; -import cn.iocoder.yudao.framework.common.util.io.FileUtils; import cn.iocoder.yudao.framework.datapermission.core.rule.DataPermissionRule; -import cn.iocoder.yudao.framework.datapermission.core.rule.dept.DeptDataPermissionRule; -import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.company.entity.Company; import cn.iocoder.yudao.module.company.service.CompanyService; @@ -16,7 +13,6 @@ import cn.iocoder.yudao.module.label.entity.Label; import cn.iocoder.yudao.module.label.service.BusiLabelService; import cn.iocoder.yudao.module.label.service.LabelService; import cn.iocoder.yudao.module.staff.entity.CompanyStaff; -import cn.iocoder.yudao.module.staff.entity.CompanyStaffChange; import cn.iocoder.yudao.module.staff.mapper.CompanyStaffMapper; import cn.iocoder.yudao.module.staff.service.CompanyStaffChangeService; import cn.iocoder.yudao.module.staff.service.CompanyStaffService; @@ -37,6 +33,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.Period; +import java.time.ZoneId; import java.util.List; import java.util.stream.Collectors; @@ -68,6 +68,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl getStaffList(){ + public List getStaffList() { return baseMapper.selectList(new QueryWrapper<>()); } /** * 重置员工登录密码 + * + * @param staffRespVO 员工对象 * @author 小李 * @date 16:21 2024/8/9 - * @param staffRespVO 员工对象 **/ - public void resetPassword(CompanyStaffRespVO staffRespVO){ + public void resetPassword(CompanyStaffRespVO staffRespVO) { // 修改员工密码 adminUserApi.resetPassword(staffRespVO.getUserId(), staffRespVO.getPassword()); } /** * 验证工号是否重复 + * + * @param workNo 输入的工号 * @author 小李 * @date 14:03 2024/8/9 - * @param workNo 输入的工号 **/ - public Boolean checkWorkNo(String workNo){ + public Boolean checkWorkNo(String workNo) { // 获取当前登录用户的部门ID和企业ID AdminUserRespDTO loginUser = getLoginUser(); DeptRespDTO loginDept = getLoginDept(loginUser.getDeptId()); @@ -379,31 +383,79 @@ public class CompanyStaffServiceImpl extends ServiceImpl().eq(Company::getCorpName, corpName)); } + + /** + * 更新员工的工龄和司龄 + * + * @author 小李 + * @date 11:41 2024/8/13 + **/ + @Override + @DSTransactional + public void updateStaffWorkAndJoinedYears() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Page page = new Page<>(0, BaseConstants.BATCH_SIZE); + while (true) { + // 查询一页的数据 + Page companyStaffPage = baseMapper.selectPage(page, queryWrapper); + // 对每一页数据进行操作更新 + List result = companyStaffPage.getRecords().stream().map(item -> { + // 获取当前时间、工作时间、入职时间 + LocalDate currentDate = LocalDate.now(); + LocalDate workDate = item.getWorkDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + LocalDate joinedDate = item.getJoinedDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + + // 计算工龄 + BigDecimal workYear = new BigDecimal(Period.between(workDate, currentDate).getYears()); + item.setWorkYear(workYear); + + // 计算司龄 + BigDecimal joinedYear = new BigDecimal(Period.between(joinedDate, currentDate).getYears()); + item.setJoinedYear(joinedYear); + + return item; + }).collect(Collectors.toList()); + + // 批量更新 + updateBatchById(result); + + // 没有下一页了就退出 + if (companyStaffPage.getRecords().isEmpty()){ + break; + } + + // 取一页 + queryWrapper.gt(CompanyStaff::getId, page.getRecords().get(page.getRecords().size() - 1).getId()); + } + } } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/scheduled/UpdateCompanyStaffWorkAndJoinedYearsJob.java b/dl-module-company/src/main/java/cn/iocoder/yudao/scheduled/UpdateCompanyStaffWorkAndJoinedYearsJob.java new file mode 100644 index 00000000..127fd373 --- /dev/null +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/scheduled/UpdateCompanyStaffWorkAndJoinedYearsJob.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.scheduled; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import cn.iocoder.yudao.module.staff.service.CompanyStaffService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 定时更新员工的工龄和司龄 + * @author 小李 + * @date 14:00 2024/8/13 +**/ +@Component +@TenantJob +@Slf4j +public class UpdateCompanyStaffWorkAndJoinedYearsJob implements JobHandler { + + @Resource + private CompanyStaffService staffService; + + @Override + public String execute(String param) throws Exception { + // 执行更新 + staffService.updateStaffWorkAndJoinedYears(); + return null; + } +} diff --git a/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml b/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml index 2d0083e2..1c83d711 100644 --- a/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml +++ b/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml @@ -97,7 +97,7 @@ and (cs_old.tel like concat('%', #{map.tel}, '%') or cs_new.tel like concat('%', #{map.tel}, '%')) - and (csc.changeTime between #{map.changeTimeArray[0]} and #{map.changeTimeArray[1]}) + and (csc.change_time between #{map.changeTimeArray[0]} and #{map.changeTimeArray[1]}) and csc.old_user_id in diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJob.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJob.java index 23474bbe..f638e67e 100644 --- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJob.java +++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/core/job/TenantJob.java @@ -8,7 +8,7 @@ import java.lang.annotation.Target; /** * 多租户 Job 注解 */ -@Target({ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface TenantJob { } diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 9f27aad7..206fd83b 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -2,12 +2,12 @@ server: port: 48080 --- #################### 数据库相关配置 #################### +# exclude中少的内容 - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置 spring: # 数据源配置项 autoconfigure: exclude: - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置 - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置 - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置