提交 52532a65 authored 作者: zjm's avatar zjm

添加系统自动考评

上级 bcf00ac4
流水线 #126 已失败 于阶段
......@@ -42,7 +42,9 @@ public class ScController {
@ApiOperation(value = "新增考评信息.", notes = "新增不可在数据中附带id.成功时返回新增数据保存的id.")
public ResponseEntity<JobResponse> add(@RequestBody ScRo scRo
) {
String saveId = scoreCoefficientService.add(scRo.toDb());
ScoreCoefficient scoreCoefficient= scRo.toDb();
scoreCoefficient.setTime(new Date());
String saveId = scoreCoefficientService.add(scoreCoefficient);
businessTreeManagement.saveAction(scRo.getUserId(),scRo.getWorkId(),Action.APPRAISAL_WORD,new Date(),"自我评价");
return ok(new JobResponse(saveId));
}
......@@ -60,9 +62,12 @@ public class ScController {
public ResponseEntity<JobResponse> modify(@RequestBody ScoreCoefficient scoreCoefficient,
@RequestParam String userId,
@RequestParam String msg) {
if (!msg.equals("修改考评")){
scoreCoefficient.setTime(new Date());
}
String saveId = scoreCoefficientService.modify(scoreCoefficient);
businessTreeManagement.saveAction(userId,scoreCoefficient.getWordId(),Action.APPRAISAL_WORD,new Date(),msg);
return ok(new JobResponse(saveId));
return ok(new JobResponse(saveId));
}
......
......@@ -7,6 +7,8 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@AutoDocument
......@@ -57,4 +59,20 @@ public class ScoreCoefficient {
*/
@ApiModelProperty(value = "最终工作量", example = "endWorkLoad")
private Double endWorkLoad;
/**
* 考评的时间 每个阶段考评的时间 后一个阶段考评了 覆盖这个时间
*/
private Date time;
public ScoreCoefficient(String id, String wordId, String score1, String groupLeaderScore2, String directorScore2, String viceScore3, String justScore4, Double endWorkLoad) {
this.id = id;
this.wordId = wordId;
this.score1 = score1;
this.groupLeaderScore2 = groupLeaderScore2;
this.directorScore2 = directorScore2;
this.viceScore3 = viceScore3;
this.justScore4 = justScore4;
this.endWorkLoad = endWorkLoad;
}
}
......@@ -10,6 +10,10 @@ import java.util.List;
public interface ScoreCoefficientRepository extends MongoRepository<ScoreCoefficient, String> {
List<ScoreCoefficient> findByWordId(String workId);
// List<ScoreCoefficient> findByScore2IsNot();
List<ScoreCoefficient> findAllByGroupLeaderScore2IsNullOrDirectorScore2IsNull();
List<ScoreCoefficient> findAllByGroupLeaderScore2IsNotNullAndDirectorScore2IsNotNullAndViceScore3IsNull();
List<ScoreCoefficient> findAllByViceScore3IsNotNullAndJustScore4IsNull();
}
......@@ -58,7 +58,8 @@ public interface AttachmentService {
/**
* 查找指定id的Work
*
* @param workId 指定id
* @param
* workId 指定id
* @return Work对象
*/
Attachment findById(String attachmentId);
......
......@@ -10,6 +10,7 @@ import com.zjty.tynotes.job.common.exception.BadRequestException;
import com.zjty.tynotes.job.common.exception.NotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.util.Date;
......
//package com.zjty.tynotes.job.task;
//
//import com.zjty.tynotes.job.basic.entity.database.Work;
//import com.zjty.tynotes.job.basic.service.ScoreCoefficientService;
//import com.zjty.tynotes.job.basic.service.WorkService;
//import com.zjty.tynotes.job.common.Action;
//import com.zjty.tynotes.job.common.constant.WorkStatus;
//import com.zjty.tynotes.job.status.service.BusinessTreeManagement;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Service;
//
//import java.time.LocalDateTime;
//import java.time.ZoneOffset;
//import java.util.Date;
//
//@Slf4j
//@Service
//public class Task {
// @Autowired
// ScoreCoefficientService scoreCoefficientService;
// @Autowired
// WorkService workService;
// @Autowired
// BusinessTreeManagement businessTreeManagement;
//
// @Scheduled(cron ="0 0 0 * * ?")
// public void task() {
//
// long time=LocalDateTime.now().minusDays(7)
// .withHour(0)
// .withMinute(0)
// .withSecond(0)
// .withNano(0)
// .atOffset(ZoneOffset.ofHours(8))
// .toEpochSecond();
//
//
// scoreCoefficientService.selectSorct2IsNull()
// .forEach(
// sc->{
// Work work= workService.findById(sc.getWordId());
// if (work.getAuditTime().getTime()<time){
//// sc.setScore2(sc.getScore1());
// scoreCoefficientService.modify(sc);
// businessTreeManagement.saveAction(work.getPublisher(),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"");
package com.zjty.tynotes.job.task;
import com.zjty.tynotes.job.basic.entity.database.Work;
import com.zjty.tynotes.job.basic.repository.ScoreCoefficientRepository;
import com.zjty.tynotes.job.basic.service.ScoreCoefficientService;
import com.zjty.tynotes.job.basic.service.WorkService;
import com.zjty.tynotes.job.common.Action;
import com.zjty.tynotes.job.common.constant.WorkStatus;
import com.zjty.tynotes.job.status.service.BusinessTreeManagement;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
@Slf4j
@Service
public class Task {
@Autowired
ScoreCoefficientRepository scoreCoefficientRepository;
@Autowired
WorkService workService;
@Autowired
BusinessTreeManagement businessTreeManagement;
@Scheduled(cron ="0 0 0 * * ?")
public void task() {
long time=LocalDateTime.now().minusDays(1)
.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0)
.atOffset(ZoneOffset.ofHours(8))
.toEpochSecond();
long finalTime2 = time;
scoreCoefficientRepository.findAllByGroupLeaderScore2IsNullOrDirectorScore2IsNull()
.forEach(
sc->{
Work work=workService.findById(sc.getWordId());
if (sc.getTime().getTime()< finalTime2){
if(sc.getDirectorScore2()==null&&sc.getGroupLeaderScore2() != null){
sc.setDirectorScore2(sc.getGroupLeaderScore2());
sc.setTime(new Date());
businessTreeManagement.saveAction(work.getMajordomos().get(0),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"总监评价");
}else if (sc.getGroupLeaderScore2()==null && sc.getDirectorScore2() !=null){
sc.setGroupLeaderScore2(sc.getDirectorScore2());
sc.setTime(new Date());
businessTreeManagement.saveAction(work.getAudit(),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"组长评价");
}else {
sc.setTime(new Date());
sc.setGroupLeaderScore2(sc.getScore1());
businessTreeManagement.saveAction(work.getAudit(),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"组长评价");
sc.setDirectorScore2(sc.getScore1());
businessTreeManagement.saveAction(work.getMajordomos().get(0),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"总监评价");
}
scoreCoefficientRepository.save(sc);
// workService.alterTaskStatus(sc.getWordId(),WorkStatus.FINISHED,work.getPublisher());
// businessTreeManagement.saveAction(work.getPublisher(), sc.getWordId(), Action.FINISHED_WORK, new Date(), "");
// }
//
// }
// );
// }
//}
}
}
);
time=LocalDateTime.now().minusDays(2)
.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0)
.atOffset(ZoneOffset.ofHours(8))
.toEpochSecond();
//副总经理
long finalTime1 = time;
scoreCoefficientRepository.findAllByGroupLeaderScore2IsNotNullAndDirectorScore2IsNotNullAndViceScore3IsNull()
.forEach(
sc->{
Work work=workService.findById(sc.getWordId());
if (sc.getTime().getTime()< finalTime1){
String score3= String.valueOf(Integer.valueOf(sc.getDirectorScore2())+Integer.valueOf(sc.getGroupLeaderScore2()));
sc.setViceScore3(score3);
sc.setTime(new Date());
businessTreeManagement.saveAction(work.getAssistantManagers().get(0),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"副总经理评价");
}
scoreCoefficientRepository.save(sc);
// workService.alterTaskStatus(sc.getWordId(),WorkStatus.FINISHED,work.getPublisher());
// businessTreeManagement.saveAction(work.getPublisher(), sc.getWordId(), Action.FINISHED_WORK, new Date(), "");
}
);
time=LocalDateTime.now().minusDays(2)
.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0)
.atOffset(ZoneOffset.ofHours(8))
.toEpochSecond();
//总经理
long finalTime = time;
scoreCoefficientRepository.findAllByViceScore3IsNotNullAndJustScore4IsNull()
.forEach(
sc->{
Work work=workService.findById(sc.getWordId());
if (sc.getTime().getTime()< finalTime){
sc.setJustScore4(sc.getViceScore3());
sc.setTime(new Date());
businessTreeManagement.saveAction(work.getGeneralManagers().get(0),sc.getWordId(),Action.APPRAISAL_WORD,new Date(),"总经理评价");
}
scoreCoefficientRepository.save(sc);
workService.alterTaskStatus(sc.getWordId(),WorkStatus.FINISHED,work.getPublisher());
businessTreeManagement.saveAction(work.getGeneralManagers().get(0), sc.getWordId(), Action.FINISHED_WORK, new Date(), "");
}
);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论