Commit 1cf4df0c authored by suhuiguang's avatar suhuiguang

1.气瓶检验超期后只生成一条数据不是每天都生成

parent bb47c8dd
...@@ -463,7 +463,7 @@ ...@@ -463,7 +463,7 @@
tz_cylinder_unit u tz_cylinder_unit u
where where
a.sequence_code = b.sequence_code a.sequence_code = b.sequence_code
and u.credit_code = a.credit_code and u.app_id = a.app_id
and a.last_inspection_id = b.sequence_nbr and a.last_inspection_id = b.sequence_nbr
and date_gt(CURRENT_DATE, cast(b.next_inspection_date as date)) and date_gt(CURRENT_DATE, cast(b.next_inspection_date as date))
</select> </select>
...@@ -481,7 +481,7 @@ ...@@ -481,7 +481,7 @@
tz_cylinder_unit u tz_cylinder_unit u
where where
a.sequence_code = b.sequence_code a.sequence_code = b.sequence_code
and u.credit_code = a.credit_code and u.app_id = a.app_id
and a.last_inspection_id = b.sequence_nbr and a.last_inspection_id = b.sequence_nbr
and (b.is_deal_question = false or b.is_deal_question is null) and (b.is_deal_question = false or b.is_deal_question is null)
</select> </select>
......
package com.yeejoin.amos.boot.module.cylinder.biz.job; package com.yeejoin.amos.boot.module.cylinder.biz.job;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderQuestionInfo; import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderQuestionInfo;
import com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum; import com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum;
...@@ -16,8 +17,10 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -16,8 +17,10 @@ import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity; import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -46,8 +49,8 @@ public class InspectionQuestionJob { ...@@ -46,8 +49,8 @@ public class InspectionQuestionJob {
/** /**
* 检验超期 * 检验超期
*/ */
@SchedulerLock(name = "genOverdueQuestionJobCylinder", lockAtMostFor = "PT1H") @SchedulerLock(name = "genOverdueQuestionJobCylinder2", lockAtMostFor = "PT1H")
@Scheduled(cron = "${inspection.overdue.job.cron:0 0 2 * * ?}") @Scheduled(cron = "${inspection.overdue.job.cron:0 0 1 * * ?}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void genOverdueQuestion() { public void genOverdueQuestion() {
List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfInspectionOverdue(); List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfInspectionOverdue();
...@@ -57,17 +60,34 @@ public class InspectionQuestionJob { ...@@ -57,17 +60,34 @@ public class InspectionQuestionJob {
cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYCQ.getName()); cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYCQ.getName());
return fillCommonField(cylinderInfoDto, cylinderQuestionInfo); return fillCommonField(cylinderInfoDto, cylinderQuestionInfo);
}).collect(Collectors.toList()); }).collect(Collectors.toList());
// 已经生成的数据不再重复生成
List<CylinderQuestionInfo> needToDbQuestionInfos = this.removeRepeatData(cylinderQuestionInfos);
if (needToDbQuestionInfos.size() > 0) {
questionInfoService.saveBatch(needToDbQuestionInfos);
}
}
private List<CylinderQuestionInfo> removeRepeatData(List<CylinderQuestionInfo> cylinderQuestionInfos) {
if (cylinderQuestionInfos.size() > 0) { if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos); Set<String> questionObjectIds = cylinderQuestionInfos.stream().map(CylinderQuestionInfo::getQuestionObjectId).collect(Collectors.toSet());
Set<String> appIds = cylinderQuestionInfos.stream().map(CylinderQuestionInfo::getQuestionAttributionId).collect(Collectors.toSet());
// 已经生成问题的气瓶
List<CylinderQuestionInfo> questionInfos = questionInfoService.list(new LambdaQueryWrapper<CylinderQuestionInfo>()
.in(CylinderQuestionInfo::getQuestionObjectId, questionObjectIds)
.in(CylinderQuestionInfo::getQuestionAttributionId, appIds).eq(CylinderQuestionInfo::getQuestionType, QuestionTypeEnum.JYCQ.getCode()));
// 去掉已经生成的气瓶问题,不在重复生成问题
return cylinderQuestionInfos.stream().filter(c -> questionInfos.stream().noneMatch(d -> d.getQuestionObjectId().equals(c.getQuestionObjectId()) &&
d.getQuestionAttributionId().equals(c.getQuestionAttributionId()))).collect(Collectors.toList());
} }
return new ArrayList<>();
} }
/** /**
* 检验不合格任务 * 检验不合格任务
*/ */
@SchedulerLock(name = "genInspectionUnqualifiedQuestionJobCylinder", lockAtMostFor = "PT1H") @SchedulerLock(name = "genInspectionUnqualifiedQuestionJobCylinder2", lockAtMostFor = "PT20M")
@Scheduled(cron = "${inspection.unqualified.job.cron:0 0/5 * * * ?}") @Scheduled(cron = "${inspection.unqualified.job.cron:0 0/10 * * * ?}")
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void genInspectionUnqualifiedQuestion() { public void genInspectionUnqualifiedQuestion() {
List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfUnqualifiedQuestion(); List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfUnqualifiedQuestion();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment