|
|
@@ -7,28 +7,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ktg.common.utils.DateUtils;
|
|
|
import com.ktg.common.utils.bean.BeanUtils;
|
|
|
-import com.ktg.iscs.domain.IsMailNotifyConfig;
|
|
|
-import com.ktg.iscs.domain.IsMailTemplate;
|
|
|
-import com.ktg.iscs.domain.IsMaterialsCheckPlan;
|
|
|
-import com.ktg.iscs.domain.IsMaterialsPlanCabinet;
|
|
|
+import com.ktg.iscs.domain.*;
|
|
|
import com.ktg.iscs.domain.dto.checkPlan.AddCheckPlanDTO;
|
|
|
import com.ktg.iscs.domain.dto.plan.PlanDTO;
|
|
|
import com.ktg.iscs.mapper.IsMaterialsCheckPlanMapper;
|
|
|
-import com.ktg.iscs.service.IIsMailNotifyConfigService;
|
|
|
-import com.ktg.iscs.service.IIsMailTemplateService;
|
|
|
-import com.ktg.iscs.service.IIsMaterialsCheckPlanService;
|
|
|
-import com.ktg.iscs.service.IIsMaterialsPlanCabinetService;
|
|
|
+import com.ktg.iscs.service.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
-import java.util.concurrent.ScheduledExecutorService;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 物资检查计划Service业务层处理
|
|
|
@@ -49,12 +39,34 @@ public class IsMaterialsCheckPlanServiceImpl extends ServiceImpl<IsMaterialsChec
|
|
|
private IIsMailTemplateService iIsMailTemplateService;
|
|
|
@Autowired
|
|
|
private IIsMailNotifyConfigService isMailNotifyConfigService;
|
|
|
+ @Autowired
|
|
|
+ private IIsMaterialsCabinetService iIsMaterialsCabinetService;
|
|
|
|
|
|
- private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
|
|
|
|
|
@Override
|
|
|
public Page<IsMaterialsCheckPlan> getIsMaterialsCheckPlanPage(Page<IsMaterialsCheckPlan> page, PlanDTO dto) {
|
|
|
Page<IsMaterialsCheckPlan> result = isMaterialsCheckPlanMapper.getIsMaterialsCheckPlanPage(page, dto);
|
|
|
+ if (!result.getRecords().isEmpty()) {
|
|
|
+ // 分页中所有的计划
|
|
|
+ List<Long> planIds = result.getRecords().stream().map(IsMaterialsCheckPlan::getPlanId).collect(Collectors.toList());
|
|
|
+ // 计划中所有的关联柜子
|
|
|
+ List<IsMaterialsPlanCabinet> planCabinets = iIsMaterialsPlanCabinetService.list(Wrappers.<IsMaterialsPlanCabinet>lambdaQuery()
|
|
|
+ .in(IsMaterialsPlanCabinet::getPlanId, planIds));
|
|
|
+ // 柜子的id
|
|
|
+ List<Long> cabinetIds = planCabinets.stream().map(IsMaterialsPlanCabinet::getCabinetId).collect(Collectors.toList());
|
|
|
+ // 柜子的详情
|
|
|
+ List<IsMaterialsCabinet> cabinets = iIsMaterialsCabinetService.list(Wrappers.<IsMaterialsCabinet>lambdaQuery()
|
|
|
+ .in(IsMaterialsCabinet::getCabinetId, cabinetIds));
|
|
|
+ for (IsMaterialsCheckPlan record : result.getRecords()) {
|
|
|
+ List<Long> cabinetId = planCabinets.stream().filter(o -> o.getPlanId().equals(record.getPlanId()))
|
|
|
+ .map(IsMaterialsPlanCabinet::getCabinetId).collect(Collectors.toList());
|
|
|
+ String cabinetName = cabinets.stream()
|
|
|
+ .filter(cabinet -> cabinetId.contains(cabinet.getCabinetId()))
|
|
|
+ .map(IsMaterialsCabinet::getCabinetName)
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
+ record.setCabinetName(cabinetName);
|
|
|
+ }
|
|
|
+ }
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -88,47 +100,14 @@ public class IsMaterialsCheckPlanServiceImpl extends ServiceImpl<IsMaterialsChec
|
|
|
// 5.1新增预发送邮件到数据库
|
|
|
// 理应的发送时间计算
|
|
|
Date newDateTime = DateUtils.getNewDateTime(dto.getPlanDate(), notifyConfig.getReminderTime());
|
|
|
- // 5.2新增邮件信息
|
|
|
- // 5.3计算倒计时的秒数,开启倒计时
|
|
|
- Long delayInSeconds = DateUtils.getDatePoorSec(newDateTime);
|
|
|
- // cacheCheckPlan(materialsCheckPlan.getPlanId(), delayInSeconds);
|
|
|
+ // 5.2新增邮件任务
|
|
|
+ // 5.3整理可配置的字段
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
|
+
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 存储检测计划到内存中
|
|
|
- * @return
|
|
|
- */
|
|
|
- /*public Boolean cacheCheckPlan(Long planId, Long delayInSeconds) {
|
|
|
- scheduler.schedule(() -> {
|
|
|
- sendCacheMail(planId);
|
|
|
- }, delayInSeconds, TimeUnit.SECONDS);
|
|
|
- return true;
|
|
|
- }*/
|
|
|
-
|
|
|
- /* public Boolean sendCacheMail(Long planId) {
|
|
|
- // 倒计时结束开始发送邮件
|
|
|
- // 如果修改了计划时间(提前),那么就已经发送完毕,不用管
|
|
|
- IsMail mail = isMailService.getOne(Wrappers.<IsMail>lambdaQuery()
|
|
|
- .eq(IsMail::getTemplateCode, checkPlan)
|
|
|
- .eq(IsMail::getBelongId, planId));
|
|
|
- // 如果修改了时间(推后),则判断当前发送时间和理应发送时间的相差,如果相差过大,则不是此次发送
|
|
|
- if (mail.getSendTime() == null) {
|
|
|
- long absIntValue = Math.abs(DateUtils.getDatePoorSec(mail.getShouldSendTime()));
|
|
|
- if (absIntValue < 60) {
|
|
|
- // 如果误差在1分钟以内,则说明没有改时间,开始发送
|
|
|
- // 防止人员和模板变更,重新根据模板生成发送数据
|
|
|
- IsMail isMail = new IsMail();
|
|
|
- isMail.setMailId(mail.getMailId());
|
|
|
- isMail.setBelongId(planId);
|
|
|
- IsMail sendMail = isMailService.updateMailWhenSend(isMail);
|
|
|
- // 开始发送
|
|
|
- EmailSender.sendLocalMail(sendMail.getEmail(), null, null, sendMail.getTitle(), sendMail.getContent());
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- }*/
|
|
|
|
|
|
@Override
|
|
|
public Boolean updateIsMaterialsCheckPlan(AddCheckPlanDTO dto) {
|
|
|
@@ -153,7 +132,6 @@ public class IsMaterialsCheckPlanServiceImpl extends ServiceImpl<IsMaterialsChec
|
|
|
}
|
|
|
iIsMaterialsPlanCabinetService.saveBatch(isMaterialsPlanCabinets);
|
|
|
// 4.开始计算倒计时给检查员发送邮件,如果时间变更了,
|
|
|
- // 则重新倒计时,如果没有则不需要,变更别的属性在发送的时候会查询计划重新生成邮件,所以不影响
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
@@ -170,5 +148,16 @@ public class IsMaterialsCheckPlanServiceImpl extends ServiceImpl<IsMaterialsChec
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IsMaterialsCheckPlan selectIsMaterialsCheckPlanById(Long planId) {
|
|
|
+ IsMaterialsCheckPlan byId = getById(planId);
|
|
|
+ if (byId != null) {
|
|
|
+ List<IsMaterialsPlanCabinet> list = iIsMaterialsPlanCabinetService.list(Wrappers.<IsMaterialsPlanCabinet>lambdaQuery()
|
|
|
+ .eq(IsMaterialsPlanCabinet::getPlanId, planId));
|
|
|
+ byId.setCabinetIds(list.stream().map(IsMaterialsPlanCabinet::getCabinetId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ return byId;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|