新购及修试未入库定时器
This commit is contained in:
parent
609c0c3421
commit
9e4dada563
|
|
@ -183,4 +183,32 @@ public interface TmTaskMapper {
|
|||
List<RepairApplyDetails> selectBackApplyInfoById(BackApplyInfo backApplyInfo);
|
||||
|
||||
List<TmTask> getTaskIdByAgreementId(SltAgreementInfo info);
|
||||
|
||||
/**
|
||||
* 查询新购待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectPurchaseInfo(TmTask info);
|
||||
|
||||
/**
|
||||
* 根据typeId查询审核人及部门
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> selectApplyInfo(@Param("list") List<Long> list);
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门人手机号
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
String selectPhone(int userId);
|
||||
|
||||
/**
|
||||
* 查询修饰待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectRepairInfo(TmTask info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package com.bonus.material.task.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
|
||||
/**
|
||||
|
|
@ -58,6 +60,34 @@ public interface ITmTaskService {
|
|||
*/
|
||||
public int deleteTmTaskByTaskId(Long taskId);
|
||||
|
||||
/**
|
||||
* 查询新购待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectPurchaseInfo(TmTask info);
|
||||
|
||||
/**
|
||||
* 根据typeId查询审核人及部门
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> selectApplyInfo(List<Long> list);
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门人手机号
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
String selectPhone(int userId);
|
||||
|
||||
/**
|
||||
* 查询修饰待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
List<Long> selectRepairInfo(TmTask info);
|
||||
|
||||
// List<TmTaskRequestVo> getLeaseAuditList(TmTaskRequestVo tmTask);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.task.service.impl;
|
|||
import java.util.List;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||
|
|
@ -96,6 +97,46 @@ public class TmTaskServiceImpl implements ITmTaskService {
|
|||
return tmTaskMapper.deleteTmTaskByTaskId(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询新购待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectPurchaseInfo(TmTask info) {
|
||||
return tmTaskMapper.selectPurchaseInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据typeId查询审核人及部门
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<BackApplyInfo> selectApplyInfo(List<Long> list) {
|
||||
return tmTaskMapper.selectApplyInfo(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门id获取部门人手机号
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String selectPhone(int userId) {
|
||||
return tmTaskMapper.selectPhone(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询修饰待入库任务
|
||||
* @param info
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Long> selectRepairInfo(TmTask info) {
|
||||
return tmTaskMapper.selectRepairInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单个申请列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@ import cn.hutool.json.JSONObject;
|
|||
import com.ah.sbd.SmsTool;
|
||||
import com.ah.sbd.utils.param.SmsParam;
|
||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||
import com.alibaba.nacos.common.utils.StringUtils;
|
||||
import com.bonus.common.biz.constant.BmConfigItems;
|
||||
import com.bonus.common.biz.enums.PurchaseTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.RepairInputStatusEnum;
|
||||
import com.bonus.common.biz.enums.TmTaskTypeEnum;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.service.ITmTaskService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
|
@ -19,7 +18,9 @@ import javax.annotation.PostConstruct;
|
|||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 待入库定时任务
|
||||
|
|
@ -75,27 +76,182 @@ public class WashHouseScheduledTasks {
|
|||
* 未入库定时任务
|
||||
*/
|
||||
public void taskWithWashHouse() {
|
||||
List<SmsParam> mobileList = new ArrayList<>();
|
||||
log.info("开始执行未入库定时推送任务");
|
||||
boolean hasNullTask = false;
|
||||
TmTask info = new TmTask();
|
||||
List<TmTask> list = tmTaskService.selectTmTaskList(info);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (TmTask tmTask : list) {
|
||||
if (tmTask.getTaskType().equals(TmTaskTypeEnum.TM_TASK_PURCHASE.getTaskTypeId())) {
|
||||
if (tmTask.getTaskStatus().equals(PurchaseTaskStatusEnum.TASK_IN_PROGRESS.getStatus())) {
|
||||
hasNullTask = true;
|
||||
break;
|
||||
// 查询新购待入库任务
|
||||
List<Long> purchaseList = tmTaskService.selectPurchaseInfo(info);
|
||||
// 查询修试待入库任务
|
||||
List<Long> repairList = tmTaskService.selectRepairInfo(info);
|
||||
// 1. 处理【只有新购任务】的情况(purchaseList非空,repairList为空)
|
||||
if (CollectionUtils.isNotEmpty(purchaseList) && CollectionUtils.isEmpty(repairList)) {
|
||||
List<BackApplyInfo> purchaseInfoList = tmTaskService.selectApplyInfo(purchaseList);
|
||||
if (CollectionUtils.isNotEmpty(purchaseInfoList)) {
|
||||
// 1.1 部门107有新购任务
|
||||
boolean purchaseHas107 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 107);
|
||||
if (purchaseHas107) {
|
||||
// 李勇
|
||||
String phone = tmTaskService.selectPhone(118);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
} else if (tmTask.getTaskType().equals(TmTaskTypeEnum.TM_TASK_REPAIR_INPUT.getTaskTypeId())) {
|
||||
if (tmTask.getTaskStatus().equals(RepairInputStatusEnum.INPUT_TASK_NO_FINISHED.getStatus())) {
|
||||
hasNullTask = true;
|
||||
break;
|
||||
}
|
||||
// 1.2 部门336有新购任务
|
||||
boolean purchaseHas336 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 336);
|
||||
if (purchaseHas336) {
|
||||
// 王国宝
|
||||
String phone = tmTaskService.selectPhone(455);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
// 1.3 部门106或335有新购任务
|
||||
boolean purchaseHas106 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 106 || dto.getDeptId() == 335);
|
||||
if (purchaseHas106) {
|
||||
// 刘春杰
|
||||
String phone = tmTaskService.selectPhone(1549);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
// 1.4 部门334有新购任务
|
||||
boolean purchaseHas334 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 334);
|
||||
if (purchaseHas334) {
|
||||
// 董照霞
|
||||
String phone = tmTaskService.selectPhone(65);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hasNullTask) {
|
||||
sendSms("15527030643", "您好!您还有待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!");
|
||||
|
||||
// 2. 处理【只有修试任务】的情况(purchaseList为空,repairList非空)
|
||||
else if (CollectionUtils.isEmpty(purchaseList) && CollectionUtils.isNotEmpty(repairList)) {
|
||||
List<BackApplyInfo> repairInfoList = tmTaskService.selectApplyInfo(repairList);
|
||||
if (CollectionUtils.isNotEmpty(repairInfoList)) {
|
||||
// 2.1 部门107有修试任务
|
||||
boolean repairHas107 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 107);
|
||||
if (repairHas107) {
|
||||
// 李勇
|
||||
String phone = tmTaskService.selectPhone(118);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 2.2 部门336有修试任务
|
||||
boolean repairHas336 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 336);
|
||||
if (repairHas336) {
|
||||
// 王国宝
|
||||
String phone = tmTaskService.selectPhone(455);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 2.3 部门106或335有修试任务
|
||||
boolean repairHas106 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 106 || dto.getDeptId() == 335);
|
||||
if (repairHas106) {
|
||||
// 刘春杰
|
||||
String phone = tmTaskService.selectPhone(1549);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 2.4 部门334有修试任务
|
||||
boolean repairHas334 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 334);
|
||||
if (repairHas334) {
|
||||
// 董照霞
|
||||
String phone = tmTaskService.selectPhone(65);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 处理【既有新购又有修试任务】的情况(原逻辑保留,内容微调)
|
||||
else if (CollectionUtils.isNotEmpty(purchaseList) && CollectionUtils.isNotEmpty(repairList)) {
|
||||
List<BackApplyInfo> purchaseInfoList = tmTaskService.selectApplyInfo(purchaseList);
|
||||
List<BackApplyInfo> repairInfoList = tmTaskService.selectApplyInfo(repairList);
|
||||
if (CollectionUtils.isNotEmpty(purchaseInfoList) && CollectionUtils.isNotEmpty(repairInfoList)) {
|
||||
// 3.1 部门107既有新购又有修试任务
|
||||
boolean purchaseHas107 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 107);
|
||||
boolean repairHas107 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 107);
|
||||
if (purchaseHas107 && repairHas107) {
|
||||
// 李勇
|
||||
String phone = tmTaskService.selectPhone(118);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购及修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 3.2 部门336既有新购又有修试任务
|
||||
boolean purchaseHas336 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 336);
|
||||
boolean repairHas336 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 336);
|
||||
if (purchaseHas336 && repairHas336) {
|
||||
// 王国宝
|
||||
String phone = tmTaskService.selectPhone(455);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购及修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 3.3 部门106/335既有新购又有修试任务
|
||||
boolean purchaseHas106 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 106 || dto.getDeptId() == 335);
|
||||
boolean repairHas106 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 106 || dto.getDeptId() == 335);
|
||||
if (purchaseHas106 && repairHas106) {
|
||||
// 刘春杰
|
||||
String phone = tmTaskService.selectPhone(1549);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购及修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
|
||||
// 3.4 部门334既有新购又有修试任务
|
||||
boolean purchaseHas334 = purchaseInfoList.stream().anyMatch(dto -> dto.getDeptId() == 334);
|
||||
boolean repairHas334 = repairInfoList.stream().anyMatch(dto -> dto.getDeptId() == 334);
|
||||
if (purchaseHas334 && repairHas334) {
|
||||
// 董照霞
|
||||
String phone = tmTaskService.selectPhone(65);
|
||||
if (StringUtils.isNotBlank(phone)) {
|
||||
String content = "您好!您所属班组还有新购及修试待入库任务需要进行处理,请及时登录系统查看处理,感谢配合!";
|
||||
mobileList.add(new SmsParam(phone, content));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(mobileList)) {
|
||||
// 根据mobileList相同手机号只发送一次短信
|
||||
List<SmsParam> uniqueMobileList = new ArrayList<>(mobileList.stream()
|
||||
// 以手机号为键,SmsParam为值,自动去重(后出现的会覆盖前一个)
|
||||
.collect(Collectors.toMap(
|
||||
SmsParam::getMobile,
|
||||
param -> param,
|
||||
(existing, replacement) -> replacement
|
||||
))
|
||||
.values());
|
||||
JSONObject sendResult = SmsTool.sendSms(uniqueMobileList, BmConfigItems.ANHUI_COMPANY_SMS_KEY);
|
||||
if (sendResult != null && !sendResult.isEmpty()) {
|
||||
log.info("短信发送成功: {}", sendResult);
|
||||
System.out.println("短信发送成功: " + sendResult);
|
||||
} else {
|
||||
log.error("短信发送失败,发送结果为空!");
|
||||
System.out.println("短信发送失败,发送结果为空!");
|
||||
}
|
||||
} else {
|
||||
log.info("没有待入库的单子");
|
||||
System.out.println("没有待入库的单子");
|
||||
|
|
|
|||
|
|
@ -287,4 +287,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
|
||||
</select>
|
||||
|
||||
<select id="selectPurchaseInfo" resultType="java.lang.Long">
|
||||
SELECT
|
||||
pcd.type_id
|
||||
FROM
|
||||
purchase_check_details pcd
|
||||
LEFT JOIN ma_type mt ON pcd.type_id = mt.type_id
|
||||
WHERE
|
||||
`status` = 4
|
||||
AND NOT ( mt.manage_type = 0 AND ( pcd.bind_num IS NULL OR pcd.bind_num = 0 ) )
|
||||
GROUP BY pcd.type_id
|
||||
</select>
|
||||
|
||||
<select id="selectApplyInfo" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
||||
SELECT
|
||||
mtr.user_id AS userId,
|
||||
su.dept_id AS deptId
|
||||
FROM
|
||||
ma_type_keeper mtr
|
||||
LEFT JOIN sys_user su ON su.user_id = mtr.user_id
|
||||
WHERE
|
||||
( su.dept_id = '106' OR su.dept_id = '107' OR su.dept_id = '334' OR su.dept_id = '335' OR su.dept_id = '336')
|
||||
AND mtr.type_id in
|
||||
<foreach item="item" collection="list" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
su.dept_id
|
||||
</select>
|
||||
|
||||
<select id="selectPhone" resultType="java.lang.String">
|
||||
SELECT phonenumber
|
||||
from sys_user
|
||||
WHERE user_id = #{userId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="selectRepairInfo" resultType="java.lang.Long">
|
||||
SELECT
|
||||
type_id
|
||||
FROM
|
||||
repair_input_details
|
||||
WHERE
|
||||
reject_num IS NULL
|
||||
AND input_num IS NULL
|
||||
GROUP BY
|
||||
type_id
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue