Commit ea2eab80 authored by suhuiguang's avatar suhuiguang

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

parent 34b5fbfa
package com.yeejoin.amos.boot.module.cylinder.flc.api.dto; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import com.yeejoin.amos.boot.biz.common.dto.BaseDto;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.util.Date; import java.util.Date;
/** /**
...@@ -15,52 +16,53 @@ import java.util.Date; ...@@ -15,52 +16,53 @@ import java.util.Date;
*/ */
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ApiModel(value="CylinderInspectionDto", description="气瓶检验信息") @ApiModel(value = "CylinderInspectionDto", description = "气瓶检验信息")
public class CylinderInspectionDto extends BaseDto { public class CylinderInspectionDto extends BaseDto {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id")
@ApiModelProperty(value = "id") private Long sequenceNbr;
private Long sequenceNbr; @ApiModelProperty(value = "检验单位")
private String inspectionUnit;
@ApiModelProperty(value = "检验单位") @ApiModelProperty(value = "气瓶唯一标识码")
private String inspectionUnit; private String sequenceCode;
@ApiModelProperty(value = "气瓶唯一标识码") @ApiModelProperty(value = "检验日期")
private String sequenceCode; private String inspectionDate;
@ApiModelProperty(value = "检验日期") @ApiModelProperty(value = "下次检验日期")
private String inspectionDate; private String nextInspectionDate;
@ApiModelProperty(value = "下次检验日期") @ApiModelProperty(value = "检验结果")
private String nextInspectionDate; private String inspectionResult;
@ApiModelProperty(value = "检验结果") @ApiModelProperty(value = "创建时间")
private String inspectionResult; private Date recDate;
@ApiModelProperty(value = "创建时间") @ApiModelProperty(value = "操作人员")
private Date recDate; private String recUserId;
@ApiModelProperty(value = "操作人员") @ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss")
private String recUserId; private Date syncDate;
@ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss") @ApiModelProperty(value = "0-新增 1-更新 2-删除")
private Date syncDate; private Integer syncState;
@ApiModelProperty(value = "0-新增 1-更新 2-删除") @ApiModelProperty(value = "对接公司编码")
private Integer syncState; private String appId;
@ApiModelProperty(value = "对接公司编码") @ApiModelProperty(value = "数据完整度")
private String appId; private Double integrity;
@ApiModelProperty(value = "数据完整度") @ApiModelProperty(value = "不合格报废数量")
private Double integrity; private String scrapQuantity;
@ApiModelProperty(value = "不合格报废数量") @ApiModelProperty(value = "是否处理生过问题")
private String scrapQuantity; private Boolean isDealQuestion;
} }
package com.yeejoin.amos.boot.module.cylinder.flc.api.entity; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity; 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; ...@@ -19,14 +20,12 @@ import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Accessors(chain = true) @Accessors(chain = true)
@TableName("tz_cylinder_inspection") @TableName("tz_cylinder_inspection")
@ApiModel(value="TzCylinderInspection对象", description="气瓶检验信息") @ApiModel(value = "TzCylinderInspection对象", description = "气瓶检验信息")
public class CylinderInspection extends BaseEntity { public class CylinderInspection extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "检验单位") @ApiModelProperty(value = "检验单位")
private String inspectionUnit; private String inspectionUnit;
...@@ -43,7 +42,6 @@ public class CylinderInspection extends BaseEntity { ...@@ -43,7 +42,6 @@ public class CylinderInspection extends BaseEntity {
private String inspectionResult; private String inspectionResult;
@ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss") @ApiModelProperty(value = "同步时间 yyyy-MM-dd HH24:mi:ss")
private Date syncDate; private Date syncDate;
...@@ -58,4 +56,7 @@ public class CylinderInspection extends BaseEntity { ...@@ -58,4 +56,7 @@ public class CylinderInspection extends BaseEntity {
@ApiModelProperty(value = "不合格报废数量") @ApiModelProperty(value = "不合格报废数量")
private String scrapQuantity; private String scrapQuantity;
@ApiModelProperty(value = "是否处理生过问题")
private Boolean isDealQuestion = false;
} }
...@@ -109,4 +109,6 @@ public interface CylinderInfoMapper extends BaseMapper<CylinderInfo> { ...@@ -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); Map<String, Object> countFillingTimesAndQuantityByCompany(@Param("companyId") String companyId, @Param("startTime") String startTime, @Param("endTime") String endTime);
List<CylinderInfoDto> queryCylinderOfInspectionOverdue(); List<CylinderInfoDto> queryCylinderOfInspectionOverdue();
List<CylinderInfoDto> queryCylinderOfUnqualifiedQuestion();
} }
...@@ -455,6 +455,24 @@ ...@@ -455,6 +455,24 @@
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>
<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 id="updateEsCylinderInfoStatus">
UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN UPDATE tz_cylinder_info SET "is_not_es" = 1 WHERE "sequence_nbr" IN
......
package com.yeejoin.amos.boot.module.cylinder.biz.job; 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.entity.CylinderQuestionInfo;
import com.yeejoin.amos.boot.module.cylinder.api.enums.QuestionTypeEnum; 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.biz.service.impl.CylinderQuestionInfoServiceImpl;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto; 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.api.mapper.CylinderInfoMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.biz.service.impl.CylinderInspectionServiceImpl;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock; import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; 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.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -19,39 +25,82 @@ import java.util.stream.Collectors; ...@@ -19,39 +25,82 @@ import java.util.stream.Collectors;
*/ */
@Component @Component
@EnableScheduling @EnableScheduling
public class InspectionOverdueJob { public class InspectionQuestionJob {
private CylinderInfoMapper cylinderInfoMapper; private CylinderInfoMapper cylinderInfoMapper;
private CylinderInspectionServiceImpl cylinderInspectionService;
private CylinderQuestionInfoServiceImpl questionInfoService; private CylinderQuestionInfoServiceImpl questionInfoService;
public InspectionOverdueJob(CylinderInfoMapper cylinderInfoMapper, public InspectionQuestionJob(CylinderInfoMapper cylinderInfoMapper,
CylinderQuestionInfoServiceImpl questionInfoService) { CylinderInspectionServiceImpl cylinderInspectionService,
CylinderQuestionInfoServiceImpl questionInfoService) {
this.cylinderInfoMapper = cylinderInfoMapper; this.cylinderInfoMapper = cylinderInfoMapper;
this.questionInfoService = questionInfoService; 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 * * ?}") @Scheduled(cron = "${inspection.overdue.job.cron:0 0 2 * * ?}")
@Transactional(rollbackFor = Exception.class)
public void genOverdueQuestion() { public void genOverdueQuestion() {
List<CylinderInfoDto> cylinderInfo = cylinderInfoMapper.queryCylinderOfInspectionOverdue(); List<CylinderInfoDto> cylinderList = cylinderInfoMapper.queryCylinderOfInspectionOverdue();
List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderInfo.stream().map(cylinderInfoDto -> { List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderList.stream().map(cylinderInfoDto -> {
CylinderQuestionInfo cylinderQuestionInfo = new CylinderQuestionInfo(); CylinderQuestionInfo cylinderQuestionInfo = new CylinderQuestionInfo();
cylinderQuestionInfo.setQuestionType(QuestionTypeEnum.JYCQ.getCode()); cylinderQuestionInfo.setQuestionType(QuestionTypeEnum.JYCQ.getCode());
cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYCQ.getName()); cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.JYCQ.getName());
cylinderQuestionInfo.setHappenDate(new Date()); return fillCommonField(cylinderInfoDto, cylinderQuestionInfo);
cylinderQuestionInfo.setRecDate(new Date());
cylinderQuestionInfo.setRegionCode(cylinderInfoDto.getRegionCode());
cylinderQuestionInfo.setQuestionObjectId(cylinderInfoDto.getSequenceCode());
cylinderQuestionInfo.setQuestionObjectName(cylinderInfoDto.getFactoryNum());
cylinderQuestionInfo.setQuestionAttributionId(cylinderInfoDto.getAppId());
cylinderQuestionInfo.setQuestionAttributionName(cylinderInfoDto.getUnitName());
return cylinderQuestionInfo;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
if (cylinderQuestionInfos.size() > 0) { if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos); 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());
cylinderQuestionInfo.setQuestionObjectId(cylinderInfoDto.getSequenceCode());
cylinderQuestionInfo.setQuestionObjectName(cylinderInfoDto.getFactoryNum());
cylinderQuestionInfo.setQuestionAttributionId(cylinderInfoDto.getAppId());
cylinderQuestionInfo.setQuestionAttributionName(cylinderInfoDto.getUnitName());
return cylinderQuestionInfo;
}
} }
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