Commit 3e8d92b7 authored by suhuiguang's avatar suhuiguang

1.增加定时任务生成资质过期问题

parent e94990e4
......@@ -12,8 +12,8 @@ public enum QuestionTypeEnum {
/**
* 问题类型
*/
WBLSYDJ("1", "未办理使用登记"),
XKCQ("2", "许可超期"),
XKCQ("1", "许可超期"),
WBLSYDJ("2", "未办理使用登记"),
JYCQ("3", "检验超期"),
JYBHG("4", "检验不合格"),
WJXCZJJ("5", "未进行充装检查"),
......
......@@ -109,4 +109,9 @@ public class CylinderUnitDto extends BaseDto {
@ApiModelProperty(value = "技术服务商")
private String developerAgency;
/**
* 资质到期日期
*/
private Date expireDate;
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.cylinder.flc.api.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CityCylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderInfoDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit;
import org.apache.ibatis.annotations.Param;
......@@ -56,4 +57,12 @@ public interface CylinderUnitMapper extends BaseMapper<CylinderUnit> {
*/
List<CityCylinderInfoDto> getCylinderDataByLevel(@Param("level") String level);
void saveOrUpdateBatch(@Param("list") List<CylinderUnit> list);
/**
* 查询资质超期但是还没生成问题的单位
* @param questionType 问题类型
* @return List<CylinderInfoDto>
*/
List<CylinderUnitDto> queryCylinderUnitOfPermissionExpire(@Param("questionType") String questionType);
}
......@@ -65,6 +65,19 @@
FROM tz_cylinder_unit tcu
WHERE tcu.region_code like concat('%', #{regionCode}, '%')
</select>
<select id="queryCylinderUnitOfPermissionExpire" resultType="com.yeejoin.amos.boot.module.cylinder.flc.api.dto.CylinderUnitDto">
SELECT
(SELECT min(l.expiry_date) from tz_base_unit_licence l where l."UNIT_CODE" = u.credit_code) as expire_date,
u.app_id,
u.unit_name,
u.region_code,
u.credit_code
FROM
tz_cylinder_unit u
where
date_gt(CURRENT_DATE, expire_date)
and not EXISTS (select 1 from tz_cylinder_question_info q where u.credit_code = q.question_object_id and q.question_type = #{questionType} )
</select>
<insert id="saveOrUpdateBatch" parameterType="com.yeejoin.amos.boot.module.cylinder.flc.api.entity.CylinderUnit">
INSERT INTO "tz_cylinder_unit"(sequence_nbr,unit_id,region_code,unit_name,credit_code,address,unit_person,person_mobile_phone,person_telephone,postal_code,rec_date,rec_user_id,sync_date,sync_state,app_id,security_adm,security_adm_phone,region_name)
VALUES
......
package com.yeejoin.amos.boot.module.cylinder.biz.job;
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.CylinderUnitDto;
import com.yeejoin.amos.boot.module.cylinder.flc.api.mapper.CylinderUnitMapper;
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 javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Administrator
*/
@Component
@EnableScheduling
public class CompanyQuestionJob {
private CylinderUnitMapper cylinderUnitMapper;
private CylinderQuestionInfoServiceImpl questionInfoService;
public CompanyQuestionJob(CylinderUnitMapper cylinderUnitMapper,
CylinderQuestionInfoServiceImpl questionInfoService) {
this.cylinderUnitMapper = cylinderUnitMapper;
this.questionInfoService = questionInfoService;
}
/**
* 资质超期
*/
@SchedulerLock(name = "genCompanyQuestionOfPermissionExpireJob", lockAtMostFor = "PT4M")
@Scheduled(cron = "${inspection.cert.expire.job.cron:0 0/2 * * * ?}")
@Transactional(rollbackFor = Exception.class)
public void genCompanyQuestionOfPermissionExpire() {
List<CylinderUnitDto> cylinderUnitDtoList = cylinderUnitMapper.queryCylinderUnitOfPermissionExpire(QuestionTypeEnum.XKCQ.getCode());
List<CylinderQuestionInfo> cylinderQuestionInfos = cylinderUnitDtoList.stream().map(cylinderUnitDto -> {
CylinderQuestionInfo cylinderQuestionInfo = new CylinderQuestionInfo();
cylinderQuestionInfo.setQuestionType(QuestionTypeEnum.XKCQ.getCode());
cylinderQuestionInfo.setQuestionTypeName(QuestionTypeEnum.XKCQ.getName());
return this.fillCommonField(cylinderUnitDto, cylinderQuestionInfo);
}).collect(Collectors.toList());
if (cylinderQuestionInfos.size() > 0) {
questionInfoService.saveBatch(cylinderQuestionInfos);
}
}
@NotNull
private CylinderQuestionInfo fillCommonField(CylinderUnitDto cylinderUnitDto, CylinderQuestionInfo cylinderQuestionInfo) {
cylinderQuestionInfo.setHappenDate(new Date());
cylinderQuestionInfo.setRecDate(new Date());
cylinderQuestionInfo.setRegionCode(cylinderUnitDto.getRegionCode());
cylinderQuestionInfo.setQuestionObjectId(cylinderUnitDto.getCreditCode());
cylinderQuestionInfo.setQuestionObjectName(cylinderUnitDto.getUnitName());
cylinderQuestionInfo.setQuestionAttributionId(cylinderUnitDto.getAppId());
cylinderQuestionInfo.setQuestionAttributionName(cylinderUnitDto.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