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 05fa3b96..0a2dace0 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 @@ -43,4 +43,8 @@ public class BaseConstants { public static final String FUNC_COMPANY = "company"; /**批量操作数据量*/ public static final Integer BATCH_SIZE = 100; + /**资质临期通知模板*/ + public static final String QUALS_INTERIM_PERIOD = "quals_interim_period"; + /**资质过期通知模板*/ + public static final String QUALS_EXPIRED = "quals_expired"; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java index 27655086..11da91c6 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java @@ -19,4 +19,6 @@ public class DictBaseConstants { public static final String DICT_SYS_USER_SEX = "system_user_sex"; /**学历*/ public static final String COMPANY_STAFF_EDU = "company_staff_edu"; + /**企业资质临期判定时间*/ + public static final String COMPANY_QUALS_EXPIRED = "company_quals_expired"; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/mapper/CompanyMapper.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/mapper/CompanyMapper.java index 069d95f9..b21b0327 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/mapper/CompanyMapper.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/mapper/CompanyMapper.java @@ -2,12 +2,15 @@ package cn.iocoder.yudao.module.company.mapper; import cn.iocoder.yudao.module.company.entity.Company; import cn.iocoder.yudao.module.company.vo.CompanyReqVO; +import cn.iocoder.yudao.module.company.vo.CompanyRespVO; 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; +import java.util.List; + /** * 企业信息表(每个租户的下属企业信息);(dl_company)表数据库访问层 * @author : http://www.chiner.pro @@ -16,4 +19,11 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface CompanyMapper extends BaseMapper{ IPage selectListPage(@Param("map") CompanyReqVO companyReqVO, Page page); + + /** + * 获取所有企业及对应的管理信息 + * @author 小李 + * @date 10:15 2024/8/14 + **/ + List getCompanyAndManager(); } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyQualsService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyQualsService.java index 53b4688f..2d369529 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyQualsService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyQualsService.java @@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.company.service; import cn.iocoder.yudao.module.company.entity.CompanyQuals; import cn.iocoder.yudao.module.company.vo.CompanyQualsRespVO; +import cn.iocoder.yudao.module.company.vo.CompanyRespVO; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 企业资质信息表 * @author : http://www.chiner.pro @@ -34,4 +37,11 @@ public interface CompanyQualsService extends IService { * @param id 企业资质id **/ void removeDataObj(String id); + + /** + * 企业资质临期提醒 + * @author 小李 + * @date 8:54 2024/8/14 + **/ + void noticeCompanyQualsExpired(List companyRespVOS); } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java index a8f281e1..1bd6a9b3 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/CompanyService.java @@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * 企业信息表(每个租户的下属企业信息);(dl_company)表服务接口 * @author : http://www.chiner.pro @@ -44,4 +46,11 @@ public interface CompanyService extends IService { * @param id 企业id **/ void removeDataObj(String id); + + /** + * 获取所有企业及对应的管理信息 + * @author 小李 + * @date 10:15 2024/8/14 + **/ + List getCompanyAndManager(); } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyQualsServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyQualsServiceImpl.java index d9cbd915..7b6ac397 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyQualsServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyQualsServiceImpl.java @@ -1,19 +1,43 @@ package cn.iocoder.yudao.module.company.service.impl; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.BaseConstants; +import cn.iocoder.yudao.common.DictBaseConstants; import cn.iocoder.yudao.module.company.entity.CompanyQuals; import cn.iocoder.yudao.module.company.mapper.CompanyQualsMapper; import cn.iocoder.yudao.module.company.service.CompanyQualsService; import cn.iocoder.yudao.module.company.vo.CompanyQualsRespVO; +import cn.iocoder.yudao.module.company.vo.CompanyRespVO; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; +import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.time.LocalDate; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; @Service public class CompanyQualsServiceImpl extends ServiceImpl implements CompanyQualsService { @Resource private CompanyQualsMapper companyQualsMapper; + @Resource + private DictDataApi dataApi; + + @Resource + private NotifyMessageSendApi sendApi; + /** * 新增企业资质信息 * @@ -49,4 +73,73 @@ public class CompanyQualsServiceImpl extends ServiceImpl companyRespVOS) { + // 构建分页条件 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + Page page = new Page<>(0, BaseConstants.BATCH_SIZE); + // 获取临期判定时间 + List dictDataList = dataApi.getDictDataList(DictBaseConstants.COMPANY_QUALS_EXPIRED); + Long ruleDay = null; + if (ObjectUtil.isNotEmpty(dictDataList)) { + ruleDay = Long.valueOf(dictDataList.get(0).getValue()); + } + while (ObjectUtil.isNotEmpty(ruleDay)) { + // 查询一页数据 + Page qualsPage = baseMapper.selectPage(page, queryWrapper); + // 分类出临期和过期的数据 + // 这里重新赋值是因为不重新赋值用不了,我也不知道为什么,看到这里的人知道的话可以给我讲讲 + Long finalRuleDay = ruleDay; + qualsPage.getRecords().forEach(item -> { + LocalDate currentDate = LocalDate.now(); + LocalDate endDate = item.getEndDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); + + // 计算离当前时间还有多少天 + Long day = ChronoUnit.DAYS.between(currentDate, endDate); + // day 小于0是过期了 小于等于finalRuleDay是临期了 其他就正常的 + if (day < 0) { + sendMessage(item, BaseConstants.QUALS_EXPIRED, companyRespVOS, day); + } else if (day <= finalRuleDay) { + sendMessage(item, BaseConstants.QUALS_INTERIM_PERIOD, companyRespVOS, day); + } + }); + } + } + + /** + * 发送站内信 + * + * @param data 要发送的数据 + * @param templateCode 发送用什么模板 + * @param companyRespVOS 企业和其管理员数据集 + * @param day 资质的到期时间到今天还有多少天 + * @author 小李 + * @date 9:58 2024/8/14 + **/ + private void sendMessage(CompanyQuals data, String templateCode, List companyRespVOS, Long day) { + // 获取记录的企业管理员的id + List collect = companyRespVOS.stream().filter(company -> company.getId() == data.getCorpId()).collect(Collectors.toList()); + if (ObjectUtil.isNotEmpty(collect)) { + Long userId = collect.get(0).getUserDTO().getId(); + + // 准备发送参数 + Map templateParams = new HashMap<>(); + // 什么资质 + templateParams.put("qualsName", data.getQualsName()); + // 还有多少天过期或已过期多少天,可能是负数,绝对值一下 + templateParams.put("day", Math.abs(day)); + + // 发送 + sendApi.sendSingleMessageToAdmin(new NotifySendSingleToUserReqDTO() + .setUserId(userId) + .setTemplateCode(templateCode).setTemplateParams(templateParams)); + } + } } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java index a484c752..a6d3b365 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/service/impl/CompanyServiceImpl.java @@ -159,4 +159,13 @@ public class CompanyServiceImpl extends ServiceImpl impl } } + /** + * 获取所有企业及对应的管理信息 + * @author 小李 + * @date 10:15 2024/8/14 + **/ + @Override + public List getCompanyAndManager(){ + return baseMapper.getCompanyAndManager(); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/vo/CompanyRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/vo/CompanyRespVO.java index a61d3fd0..6651a981 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/vo/CompanyRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/vo/CompanyRespVO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.company.vo; import cn.iocoder.yudao.module.company.entity.Company; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import lombok.Data; import java.util.List; @@ -20,4 +21,9 @@ public class CompanyRespVO extends Company { * 登录账户密码 */ List serviceCodeArray; + + /** + * 企业对应的管理员 + **/ + private UserDTO userDTO; } 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 index 103a3141..8b562587 100644 --- 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 @@ -1,7 +1,13 @@ package cn.iocoder.yudao.module.custom.vo; import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; /** * 推广记录表查询VO @@ -10,4 +16,8 @@ import lombok.Data; **/ @Data public class BasePromotionReqVO extends BasePromotion { + + @Schema(description = "被推广人注册日期查询范围") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private Date[] registerTimeArray; } 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 index f9b1575e..bd999d93 100644 --- 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 @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.custom.vo; import cn.iocoder.yudao.module.custom.entity.BasePromotion; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import lombok.Data; /** @@ -10,4 +11,10 @@ import lombok.Data; **/ @Data public class BasePromotionRespVO extends BasePromotion { + + /** 推广人 */ + private UserDTO oldUser; + + /** 被推广人 */ + private UserDTO newUser; } 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 index a2252460..5c9e041c 100644 --- 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 @@ -2,9 +2,15 @@ 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.company.service.CompanyQualsService; +import cn.iocoder.yudao.module.company.service.CompanyService; +import cn.iocoder.yudao.module.company.vo.CompanyRespVO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import javax.annotation.Resource; +import java.util.List; + /** * 定时提醒企业管理员资质过期 * @author 小李 @@ -15,9 +21,18 @@ import org.springframework.stereotype.Component; @Slf4j public class NoticeCompanyQualsExpiredJob implements JobHandler { + @Resource + private CompanyQualsService qualsService; + + @Resource + private CompanyService companyService; + @Override public String execute(String param) throws Exception { - // TODO + // 获取所有企业和其管理员 + List companyAndManager = companyService.getCompanyAndManager(); + // 提醒管理员资质过期 + qualsService.noticeCompanyQualsExpired(companyAndManager); return null; } } diff --git a/dl-module-base/src/main/resources/mapper/company/CompanyMapper.xml b/dl-module-base/src/main/resources/mapper/company/CompanyMapper.xml index aad7d417..3f4d2f97 100644 --- a/dl-module-base/src/main/resources/mapper/company/CompanyMapper.xml +++ b/dl-module-base/src/main/resources/mapper/company/CompanyMapper.xml @@ -6,29 +6,42 @@ SELECT bc.* FROM - base_company bc + base_company bc WHERE deleted = '0' AND (bc.regist_date BETWEEN #{map.registDateArray[0]} AND #{map.registDateArray[1]}) - AND (bc.corp_name LIKE CONCAT('%',#{map.corpName},'%')) + AND (bc.corp_name LIKE CONCAT('%',#{map.corpName},'%')) - AND (bc.org_card LIKE CONCAT('%',#{map.orgCard},'%')) + AND (bc.org_card LIKE CONCAT('%',#{map.orgCard},'%')) - AND (bc.legal_name LIKE CONCAT('%',#{map.legalName},'%')) + AND (bc.legal_name LIKE CONCAT('%',#{map.legalName},'%')) - AND (bc.legal_card LIKE CONCAT('%',#{map.legalCard},'%')) + AND (bc.legal_card LIKE CONCAT('%',#{map.legalCard},'%')) - AND (bc.contact_name LIKE CONCAT('%',#{map.contactName},'%')) + AND (bc.contact_name LIKE CONCAT('%',#{map.contactName},'%')) - AND (bc.mobile_phone LIKE CONCAT('%',#{map.mobilePhone},'%')) + AND (bc.mobile_phone LIKE CONCAT('%',#{map.mobilePhone},'%')) ORDER BY bc.create_time DESC + + + + + + + + \ No newline at end of file diff --git a/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml b/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml index 555e355c..43e15772 100644 --- a/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml +++ b/dl-module-base/src/main/resources/mapper/custom/BasePromotionMapper.xml @@ -4,18 +4,50 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffChangeServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffChangeServiceImpl.java index 98bb580d..0c59c2df 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffChangeServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/service/impl/CompanyStaffChangeServiceImpl.java @@ -55,6 +55,8 @@ public class CompanyStaffChangeServiceImpl extends ServiceImpl list = null; - if (ObjectUtil.isNotEmpty(staffChangeReqVO.getName())){ - list = staffService.list(new LambdaQueryWrapper() - .like(CompanyStaff::getName, staffChangeReqVO.getName()) - ); - }else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getWorkNo())){ - list = staffService.list(new LambdaQueryWrapper() - .like(CompanyStaff::getWorkNo, staffChangeReqVO.getWorkNo()) - ); - }else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getTel())){ - list = staffService.list(new LambdaQueryWrapper() - .like(CompanyStaff::getTel, staffChangeReqVO.getTel()) - ); - } - // 如果查到了结果才处理,没查到不管 - if (ObjectUtil.isNotEmpty(list)){ + if (ObjectUtil.isNotEmpty(staffChangeReqVO.getName())) { + list = staffService.list(new LambdaQueryWrapper() + .like(CompanyStaff::getName, staffChangeReqVO.getName()) + ); + } else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getWorkNo())) { + list = staffService.list(new LambdaQueryWrapper() + .like(CompanyStaff::getWorkNo, staffChangeReqVO.getWorkNo()) + ); + } else if (ObjectUtil.isNotEmpty(staffChangeReqVO.getTel())) { + list = staffService.list(new LambdaQueryWrapper() + .like(CompanyStaff::getTel, staffChangeReqVO.getTel()) + ); + } + // 如果查到了结果才处理,没查到不管 + if (ObjectUtil.isNotEmpty(list)) { List userIds = list.stream().map(item -> item.getUserId()).collect(Collectors.toList()); - if (staffChangeReqVO.getChangeType().equals("0")){ + if (staffChangeReqVO.getChangeType().equals("0")) { staffChangeReqVO.setOldUserIds(userIds); - }else{ + } else { staffChangeReqVO.setNewUserIds(userIds); } } 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 f0ff361e..07a123b0 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 @@ -137,8 +137,7 @@ public class CompanyStaffServiceImpl extends ServiceImpl().and(item -> { - item.eq(CompanyStaff::getWorkNo, workNo) - .eq(CompanyStaff::getDeptId, loginDept.getId()) - .eq(CompanyStaff::getCorpId, loginCompany.getId()); + item.eq(CompanyStaff::getWorkNo, workNo); })) == 0; } @@ -403,17 +396,6 @@ public class CompanyStaffServiceImpl extends ServiceImpl().eq(Company::getCorpName, corpName)); - } - /** * 更新员工的工龄和司龄 * 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 1c83d711..c4ffe78d 100644 --- a/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml +++ b/dl-module-company/src/main/resources/mapper/staff/CompanyStaffChangeMapper.xml @@ -49,49 +49,50 @@