From 2fcd97552d16718cc7997629fd637a73a5a4483f Mon Sep 17 00:00:00 2001 From: 郑永安 <zyazyz250@sina.com> Date: 星期一, 19 六月 2023 14:44:19 +0800 Subject: [PATCH] 删除 --- src/main/java/com/gk/firework/Scheduls/AssessTask/EnforcePunishmentTask.java | 101 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/gk/firework/Scheduls/AssessTask/EnforcePunishmentTask.java b/src/main/java/com/gk/firework/Scheduls/AssessTask/EnforcePunishmentTask.java new file mode 100644 index 0000000..48a79ee --- /dev/null +++ b/src/main/java/com/gk/firework/Scheduls/AssessTask/EnforcePunishmentTask.java @@ -0,0 +1,101 @@ +package com.gk.firework.Scheduls.AssessTask; + +import com.gk.firework.Domain.AccessAssessApply; +import com.gk.firework.Domain.Enterprise; +import com.gk.firework.Domain.Enum.AssessPunishment; +import com.gk.firework.Domain.Enum.EnterpriseStatus; +import com.gk.firework.Domain.Enum.PunishStatus; +import com.gk.firework.Domain.Exception.BusinessException; +import com.gk.firework.Domain.UserInfo; +import com.gk.firework.Service.AccessAssessApplyService; +import com.gk.firework.Service.AssessApplyService; +import com.gk.firework.Service.EnterpriseService; +import com.gk.firework.Service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; +/** +* @Description: 0点执行处罚 +* @date 2021/7/12 9:51 +*/ +@Component +@EnableScheduling +public class EnforcePunishmentTask { + + + @Value("${com.gk.firework.schedules.all.switch}") + private Boolean switchBtn; + //销售评定 + @Autowired + private AssessApplyService assessApplyService; + //准入评定 + @Autowired + private AccessAssessApplyService accessAssessApplyService; + @Autowired + private EnterpriseService enterpriseService; + @Autowired + private UserService userService; + + @Scheduled(cron = "0 0 0 * * ?") + public void EnforcePunishment() { + if (switchBtn) { + Date currentTime = new Date(); + + //1.销售评定审批结束已经处罚 + + //2.准入评定 公示14天处罚,获取截止日期大于等于当日的准入评定进行相对应的处罚 + List<AccessAssessApply> allOverTimeData = accessAssessApplyService.selectAllOverTimeAccessAssessApply(); + if (allOverTimeData.size() > 0) { + for (AccessAssessApply accessAssessApply : allOverTimeData) { + //企业信息检查 + Enterprise enterprise = enterpriseService.selectEnterpriseByNumber(accessAssessApply.getEnterprisenumber()); + if (enterprise == null) throw new BusinessException("单位编号:" + accessAssessApply.getEnterprisenumber() + ",企业信息为空"); + //用户检查 + List<UserInfo> userInfos = userService.selectByCompanyId(enterprise.getId(), (byte) 0); + if (userInfos.size() != 2) throw new BusinessException("数据异常:用户对象个数不匹配"); + //除了吊销,都是过期 + if (accessAssessApply.getPunishmentmeasure() == AssessPunishment.M0) { + this.deactivateEnterprise(enterprise, userInfos); + accessAssessApply.setPunishstatus(PunishStatus.PUNISHING); + accessAssessApplyService.updateById(accessAssessApply); + } + + if (accessAssessApply.getPunishmentmeasure() != AssessPunishment.M0) + this.deactivateUser(userInfos); + accessAssessApply.setPunishstatus(PunishStatus.PUNISHING); + accessAssessApplyService.updateById(accessAssessApply); + + } + } + } + } + + //停用企业 + private void deactivateEnterprise(Enterprise enterprise,List<UserInfo> userInfos) { + //停用企业 + enterpriseService.setEnterpriseStatus(EnterpriseStatus.OFF, enterprise.getId()); + //停用用户 + for (UserInfo user : userInfos) { + userService.deleteById(user.getId()); + } + } + + + //用户过期 + private void deactivateUser(List<UserInfo> userInfos) { + for (UserInfo user : userInfos) { + userService.deleteById(user.getId()); + } + } + + + + +} -- Gitblit v1.9.2