定时任务添加考核任务状态修改

main 50
hshansha 2 months ago
parent d5ec093310
commit 68d4617949

@ -4,8 +4,10 @@ import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.kaohe.domain.KhPcEmp;
import com.ruoyi.kaohe.domain.KhPingce;
import com.ruoyi.kaohe.domain.KhVoteEmp;
import com.ruoyi.kaohe.service.IKhPcEmpService;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import org.springframework.scheduling.annotation.Scheduled;
import java.math.BigDecimal;
@ -44,6 +46,8 @@ public class KhVoteController extends BaseController {
private IKhPcEmpService pcEmpService;
@Autowired
private IKhVoteEmpService voteEmpService;
@Autowired
private IKhPingceService khPingceService;
@Scheduled(cron = "0 * * * * ?") // 每分钟的第0秒执行一次 监测时间修改评分状态
public void performTask() {
@ -60,14 +64,35 @@ public class KhVoteController extends BaseController {
if (state.equals("0") && (now.after(sTime) && now.before(eTime))) {
vote.setState("1");
khVoteService.updateKhVote(vote);
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " + vote.getVoteTitle() + " 状态为进行中");
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " +vote.getId()+" "+ vote.getVoteTitle() + " 状态为进行中");
}
if (now.after(eTime)) {
vote.setState("2");
khVoteService.updateKhVote(vote);
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " + vote.getVoteTitle() + " 状态为已完成");
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " +vote.getId()+" "+ vote.getVoteTitle() + " 状态为已完成");
}
}
//修改考核任务状态,当考核任务下所有评分都为已完成时,修改考核任务状态为已完成
KhPingce param = new KhPingce();
param.setState("1");
List<KhPingce> pingces = khPingceService.selectKhPingceList(param);
for (KhPingce pingce : pingces) {
boolean finishflag=true;
KhVote khVote = new KhVote();
khVote.setPingceId(pingce.getId());
List<KhVote> khVotes = khVoteService.selectKhVoteList(khVote);
for (KhVote vote : khVotes) {
if(!vote.getState().equals("2")){
finishflag=false;
}
}
if(finishflag){
pingce.setState("2");
khPingceService.updateKhPingce(pingce);
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改考核任务: " +pingce.getId()+" "+ pingce.getPcTitle() + " 状态为已完成");
}
}
}
/**

Loading…
Cancel
Save