配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒
This commit is contained in:
parent
39ba91f3ba
commit
84e57f0337
@ -16,4 +16,7 @@ public interface RepairDictConstants {
|
||||
|
||||
/** 配件属性 */
|
||||
String WARES_ATTRIBUTE = "repair_attribute";
|
||||
|
||||
/** 配件相关提醒配置 */
|
||||
String REPAIR_WARES_NOTICE = "repair_wares_notice";
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
|
||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:40 2024/11/30
|
||||
**/
|
||||
@Component
|
||||
@TenantJob
|
||||
@Slf4j
|
||||
public class WaresTimeOverJob implements JobHandler {
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairWaresService waresService;
|
||||
|
||||
@Override
|
||||
public String execute(String param) throws Exception {
|
||||
waresService.timeOver();
|
||||
return null;
|
||||
}
|
||||
}
|
@ -86,4 +86,12 @@ public interface RepairWaresService extends IService<RepairWares> {
|
||||
* @date 16:20 2024/11/29
|
||||
**/
|
||||
ImportExcelRespVO importData(List<RepairWaresExcelVO> list, Boolean updateSupport);
|
||||
|
||||
/**
|
||||
* 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:42 2024/11/30
|
||||
**/
|
||||
void timeOver();
|
||||
}
|
@ -2,7 +2,11 @@ package cn.iocoder.yudao.module.project.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.RepairDictConstants;
|
||||
import cn.iocoder.yudao.common.RepairRoleEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.base.service.RepairWorkerService;
|
||||
import cn.iocoder.yudao.module.conf.entity.BaseType;
|
||||
import cn.iocoder.yudao.module.conf.entity.BaseWarehouse;
|
||||
import cn.iocoder.yudao.module.conf.service.BaseTypeService;
|
||||
@ -11,6 +15,12 @@ import cn.iocoder.yudao.module.project.entity.RepairWares;
|
||||
import cn.iocoder.yudao.module.project.mapper.RepairWaresMapper;
|
||||
import cn.iocoder.yudao.module.project.service.RepairWaresService;
|
||||
import cn.iocoder.yudao.module.project.vo.*;
|
||||
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.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||
import cn.iocoder.yudao.module.warnMessage.entity.WarnMessageByRepair;
|
||||
import cn.iocoder.yudao.module.warnMessage.service.WarnMessageByRepairService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -22,6 +32,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -47,6 +58,22 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
|
||||
@Lazy
|
||||
private BaseTypeService typeService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RoleApi roleApi;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private RepairWorkerService workerService;
|
||||
|
||||
@Resource
|
||||
@Lazy
|
||||
private WarnMessageByRepairService warnMessageByRepairService;
|
||||
|
||||
|
||||
/**
|
||||
* 保存配件库
|
||||
@ -211,4 +238,49 @@ public class RepairWaresServiceImpl extends ServiceImpl<RepairWaresMapper, Repai
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒
|
||||
*
|
||||
* @author 小李
|
||||
* @date 14:42 2024/11/30
|
||||
**/
|
||||
@Override
|
||||
public void timeOver() {
|
||||
// 取配置
|
||||
List<DictDataRespDTO> dataList = dictDataApi.getDictDataList(RepairDictConstants.REPAIR_WARES_NOTICE);
|
||||
// 取仓管、维修管理员
|
||||
List<UserDTO> warehouse = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.WAREHOUSE.getCode());
|
||||
List<UserDTO> admin = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.ADMIN.getCode());
|
||||
|
||||
// 取出第一个
|
||||
if (CollUtil.isEmpty(dataList)) {
|
||||
// 如果为空就通知相关人员出现了问题
|
||||
if (CollUtil.isNotEmpty(warehouse)) {
|
||||
warehouse.forEach(item -> workerService.sentMessage(item.getId(), "检查配件入库是否超时出现故障,请联系开发人员解决"));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(admin)) {
|
||||
admin.forEach(item -> workerService.sentMessage(item.getId(), "检查配件入库是否超时出现故障,请联系开发人员解决"));
|
||||
}
|
||||
}
|
||||
DictDataRespDTO dictDataRespDTO = dataList.get(0);
|
||||
String day = dictDataRespDTO.getValue();
|
||||
// 转时间,如果updateTime小于这个时间,那就是需要提醒的
|
||||
LocalDateTime dateAgo = LocalDateTime.now().minusDays(Integer.parseInt(day));
|
||||
|
||||
List<RepairWares> repairWares = baseMapper.selectList(new LambdaQueryWrapper<RepairWares>().le(RepairWares::getUpdateTime, dateAgo));
|
||||
if (CollUtil.isNotEmpty(repairWares)) {
|
||||
// 构建对象
|
||||
List<WarnMessageByRepair> warnMessages = repairWares.stream().map(item ->
|
||||
WarnMessageByRepair
|
||||
.builder()
|
||||
.title("配件超时未使用")
|
||||
.content("名为:" + item.getName() + "的配件超过设定的未使用天数提醒,请及时处理相关事项!")
|
||||
.warnTime(new Date())
|
||||
.isRead("0")
|
||||
.build()
|
||||
).collect(Collectors.toList());
|
||||
warnMessageByRepairService.saveBatch(warnMessages);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package cn.iocoder.yudao.module.warnMessage.entity;
|
||||
|
||||
import cn.iocoder.yudao.annotation.Excel;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* warnMsg对象 warn_message
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:11 2024/11/30
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
public class WarnMessageByRepair extends TenantBaseDO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
//equ设备提醒file文件提醒
|
||||
private String type;
|
||||
//对应的数据主键
|
||||
private Long objectId;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
@Excel(name = "标题")
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
@Excel(name = "内容")
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 提醒时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "提醒时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date warnTime;
|
||||
|
||||
/**
|
||||
* 店铺主键
|
||||
*/
|
||||
@Excel(name = "店铺主键")
|
||||
private Long partnerId;
|
||||
|
||||
/**
|
||||
* 是否已读
|
||||
*/
|
||||
@Excel(name = "是否已读")
|
||||
private String isRead;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.warnMessage.mapper;
|
||||
|
||||
import cn.iocoder.yudao.module.warnMessage.entity.WarnMessageByRepair;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* warnMsgMapper接口
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:14 2024/11/30
|
||||
**/
|
||||
@Mapper
|
||||
public interface WarnMessageByRepairMapper extends BaseMapper<WarnMessageByRepair> {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package cn.iocoder.yudao.module.warnMessage.service;
|
||||
|
||||
import cn.iocoder.yudao.module.warnMessage.entity.WarnMessageByRepair;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* warnMsgService接口
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:12 2024/11/30
|
||||
**/
|
||||
public interface WarnMessageByRepairService extends IService<WarnMessageByRepair> {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.warnMessage.service.impl;
|
||||
|
||||
import cn.iocoder.yudao.module.warnMessage.entity.WarnMessageByRepair;
|
||||
import cn.iocoder.yudao.module.warnMessage.mapper.WarnMessageByRepairMapper;
|
||||
import cn.iocoder.yudao.module.warnMessage.service.WarnMessageByRepairService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* warnMsgService业务层处理
|
||||
*
|
||||
* @author 小李
|
||||
* @date 15:15 2024/11/30
|
||||
**/
|
||||
@Service
|
||||
public class WarnMessageByRepairServiceImpl extends ServiceImpl<WarnMessageByRepairMapper, WarnMessageByRepair> implements WarnMessageByRepairService {
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.iocoder.yudao.module.warnMessage.mapper.WarnMessageByRepairMapper">
|
||||
</mapper>
|
Loading…
Reference in New Issue
Block a user