Commit ea2eab80 authored by suhuiguang's avatar suhuiguang

1.气瓶检验超期、检验不合格定时任务

parent 34b5fbfa
package com.yeejoin.amos.boot.module.cylinder.flc.api.dto;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
......@@ -15,14 +16,12 @@ import java.util.Date;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderInspectionDto", description="气瓶检验信息")
@ApiModel(value = "CylinderInspectionDto", description = "气瓶检验信息")
public class CylinderInspectionDto extends BaseDto {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
private Long sequenceNbr;
......@@ -63,4 +62,7 @@ public class CylinderInspectionDto extends BaseDto {
@ApiModelProperty(value = "不合格报废数量")
private String scrapQuantity;
@ApiModelProperty(value = "是否处理生过问题")
private Boolean isDealQuestion;
}
package com.yeejoin.amos.boot.module.cylinder.flc.api.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
/**
* 气瓶检验信息
*
......@@ -19,14 +20,12 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("tz_cylinder_inspection")
@ApiModel(value="TzCylinderInspection对象", description="气瓶检验信息")
@ApiModel(value = "TzCylinderInspection对象", description = "气瓶检验信息")
public class CylinderInspection extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "检验单位")
private String inspectionUnit;
......@@ -43,7 +42,6 @@ public class CylinderInspection extends BaseEntity {
private String inspectionResult;
@ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss")
private Date syncDate;
......@@ -58,4 +56,7 @@ public class CylinderInspection extends BaseEntity {
@ApiModelProperty(value = "不合格报废数量")
private String scrapQuantity;
@ApiModelProperty(value = "是否处理生过问题")
private Boolean isDealQuestion = false;
}
......@@ -109,4 +109,6 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> {
Map<String, Object> countFillingTimesAndQuantityByCompany(@Param("companyId") String companyId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<CylinderInfoDto> queryCylinderOfInspectionOverdue();
List<CylinderInfoDto> queryCylinderOfUnqualifiedQuestion();
}
......@@ -455,6 +455,24 @@
and a.last_inspection_id = b.sequence_nbr
and date_gt(CURRENT_DATE, cast(b.next_inspection_date as date))
</select>
<select id="queryCylinderOfUnqualifiedQuestion" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto">
SELECT
b.sequence_nbr,
a.sequence_code,
a.app_id,
u.unit_name,
u.region_code,
a.factory_num
FROM
tz_cylinder_info a,
tz_cylinder_inspection b,
tz_cylinder_unit u
where
a.sequence_code = b.sequence_code
and u.credit_code = a.credit_code
and a.last_inspection_id = b.sequence_nbr
and b.is_deal_question = false
</select>
<update id="updateEsCylinderInfoStatus">
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
......
package com.yeejoin.amos.boot.module.cylinder.biz.job;
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.enums.QuestionTypeEnum;
import com.yeejoin.amos.boot.module.cylinder.biz.service.impl.CylinderQuestionInfoServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderInspection;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderInfoMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderInspectionServiceImpl;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -19,28 +25,75 @@ import java.util.stream.Collectors;
*/
@Component
@EnableScheduling
public class InspectionOverdueJob {
public class InspectionQuestionJob {
private CylinderInfoMapper cylinderInfoMapper;
private CylinderInspectionServiceImpl cylinderInspectionService;
private CylinderQuestionInfoServiceImpl questionInfoService;
public InspectionOverdueJob(CylinderInfoMapper cylinderInfoMapper,
public InspectionQuestionJob(CylinderInfoMapper cylinderInfoMapper,
CylinderInspectionServiceImpl cylinderInspectionService,
CylinderQuestionInfoServiceImpl questionInfoService) {
this.cylinderInfoMapper = cylinderInfoMapper;
this.questionInfoService = questionInfoService;
this.cylinderInspectionService = cylinderInspectionService;
}
@SchedulerLock(name = "overdueQuestionJobCylinder", lockAtMostFor = "PT1H")
/**
* 检验超期
*/
@SchedulerLock(name = "genOverdueQuestionJobCylinder", lockAtMostFor = "PT1H")
@Scheduled(cron = "${inspection.overdue.job.cron:0 0 2 * * ?}")
@Transactional(rollbackFor = Exception.class)
public void genOverdueQuestion() {
List<CylinderInfoDto> cylinderInfo = cylinderInfoMapper.queryCylinderOfInspectionOverdue();
List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderInfo.stream().map(cylinderInfoDto -> {
List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfInspectionOverdue();
List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderList.stream().map(cylinderInfoDto -> {
CylinderQuestionInfo cylinderQuestionInfo = new CylinderQuestionInfo();
cylinderQuestionInfo.setQuestionType(QuestionTypeEnum.JYCQ.getCode());
cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYCQ.getName());
return fillCommonField(cylinderInfoDto, cylinderQuestionInfo);
}).collect(Collectors.toList());
if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos);
}
}
/**
* 检验不合格任务
*/
@SchedulerLock(name = "genInspectionUnqualifiedQuestionJobCylinder", lockAtMostFor = "PT1H")
@Scheduled(cron = "${inspection.unqualified.job.cron:0 0/5 * * * ?}")
@Transactional(rollbackFor = Exception.class)
public void genInspectionUnqualifiedQuestion() {
List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfUnqualifiedQuestion();
List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderList.stream().map(cylinderInfoDto -> {
CylinderQuestionInfo cylinderQuestionInfo = new CylinderQuestionInfo();
cylinderQuestionInfo.setQuestionType(QuestionTypeEnum.JYBHG.getCode());
cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYBHG.getName());
return fillCommonField(cylinderInfoDto, cylinderQuestionInfo);
}).collect(Collectors.toList());
if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos);
updateDealStatusAfterJobDeal(cylinderList);
}
}
private void updateDealStatusAfterJobDeal(List<CylinderInfoDto> cylinderList) {
LambdaUpdateWrapper<CylinderInspection> updateWrapper = new LambdaUpdateWrapper<>();
cylinderList.forEach(cylinder -> {
updateWrapper.eq(BaseEntity::getSequenceNbr, cylinder.getSequenceNbr());
updateWrapper.set(CylinderInspection::getIsDealQuestion, true);
cylinderInspectionService.update(updateWrapper);
});
}
@NotNull
private CylinderQuestionInfo fillCommonField(CylinderInfoDto cylinderInfoDto, CylinderQuestionInfo cylinderQuestionInfo) {
cylinderQuestionInfo.setHappenDate(new Date());
cylinderQuestionInfo.setRecDate(new Date());
cylinderQuestionInfo.setRegionCode(cylinderInfoDto.getRegionCode());
......@@ -49,9 +102,5 @@ public class InspectionOverdueJob {
cylinderQuestionInfo.setQuestionAttributionId(cylinderInfoDto.getAppId());
cylinderQuestionInfo.setQuestionAttributionName(cylinderInfoDto.getUnitName());
return cylinderQuestionInfo;
}).collect(Collectors.toList());
if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos);
}
}
}
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