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

添加系统自动考评

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