Commit b726f221 authored by 赵啸非's avatar 赵啸非

修改考勤汇总

parent 57a8e1d6
...@@ -16,6 +16,7 @@ import com.mortals.xhx.base.system.user.model.UserEntity; ...@@ -16,6 +16,7 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.base.system.user.model.UserQuery; import com.mortals.xhx.base.system.user.model.UserQuery;
import com.mortals.xhx.base.system.user.service.UserService; import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.module.dept.model.DeptEntity; import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptPerformStatEntity;
import com.mortals.xhx.module.dept.model.DeptQuery; import com.mortals.xhx.module.dept.model.DeptQuery;
import com.mortals.xhx.module.dept.service.DeptPerformStatService; import com.mortals.xhx.module.dept.service.DeptPerformStatService;
import com.mortals.xhx.module.dept.service.DeptService; import com.mortals.xhx.module.dept.service.DeptService;
...@@ -81,7 +82,7 @@ public class MockDataController { ...@@ -81,7 +82,7 @@ public class MockDataController {
private StaffPerformSummaryService summaryService; private StaffPerformSummaryService summaryService;
@Autowired @Autowired
private StaffPerformStatService staffPerformStatService; private StaffPerformStatService staffPerformStatService;
@Autowired
private DeptPerformStatService deptPerformStatService; private DeptPerformStatService deptPerformStatService;
/** /**
...@@ -287,7 +288,7 @@ public class MockDataController { ...@@ -287,7 +288,7 @@ public class MockDataController {
statEntity.setTotalSubScore(totalScoreSub); statEntity.setTotalSubScore(totalScoreSub);
BigDecimal subtract = statEntity.getTotalAddScore().subtract(statEntity.getTotalSubScore()); BigDecimal subtract = statEntity.getTotalAddScore().subtract(statEntity.getTotalSubScore());
statEntity.setTotalScore(subtract.compareTo(BigDecimal.ZERO)>0?subtract:BigDecimal.ZERO); statEntity.setTotalScore(subtract.compareTo(BigDecimal.ZERO) > 0 ? subtract : BigDecimal.ZERO);
statEntity.setYear(DateUtil.year(curDate)); statEntity.setYear(DateUtil.year(curDate));
statEntity.setMonth(DateUtil.month(curDate) + 1); statEntity.setMonth(DateUtil.month(curDate) + 1);
statEntity.setDay(DateUtil.dayOfMonth(curDate)); statEntity.setDay(DateUtil.dayOfMonth(curDate));
...@@ -301,6 +302,87 @@ public class MockDataController { ...@@ -301,6 +302,87 @@ public class MockDataController {
} }
/**
* 生成模拟数据
* mortals_xhx_dept_perform_stat
*
* @return
*/
@GetMapping("randomDeptPerformStatData")
@UnAuth
public Rest<Void> randomDeptPerformStatData() {
List<DeptEntity> deptEntityList = deptService.find(new DeptQuery());
//最近两月模拟数据
DateTime beforeStartDate = DateUtil.offsetDay(new Date(), -60);
for (int i = 1; i <= 60; i++) {
DateTime curDate = DateUtil.offsetDay(beforeStartDate, i);
List<DeptPerformStatEntity> collect = deptEntityList.stream().map(item -> {
DeptPerformStatEntity statEntity = new DeptPerformStatEntity();
statEntity.initAttrValue();
statEntity.setDeptId(item.getId());
statEntity.setDeptName(item.getDeptName());
BigDecimal attendScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal reviewScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal complainScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal goworkScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal effectScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal otherScoreAdd = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal attendScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal reviewScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal complainScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal goworkScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal effectScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
BigDecimal otherScoreSub = RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING);
statEntity.setAttendScoreAdd(attendScoreAdd);
statEntity.setAttendScoreSub(attendScoreSub);
statEntity.setReviewScoreAdd(reviewScoreAdd);
statEntity.setReviewScoreSub(reviewScoreSub);
statEntity.setComplainScoreAdd(complainScoreAdd);
statEntity.setComplainScoreSub(complainScoreSub);
statEntity.setGoworkScoreAdd(goworkScoreAdd);
statEntity.setGoworkScoreSub(goworkScoreSub);
statEntity.setEffectScoreAdd(effectScoreAdd);
statEntity.setEffectScoreSub(effectScoreSub);
statEntity.setOtherScoreAdd(otherScoreAdd);
statEntity.setOtherScoreSub(otherScoreSub);
BigDecimal totalScoreAdd = attendScoreAdd.add(reviewScoreAdd).add(complainScoreAdd)
.add(goworkScoreAdd).add(effectScoreAdd).add(otherScoreAdd);
BigDecimal totalScoreSub = attendScoreSub.add(reviewScoreSub).add(complainScoreSub)
.add(goworkScoreSub).add(effectScoreSub).add(otherScoreSub);
statEntity.setTotalAddScore(totalScoreAdd);
statEntity.setTotalSubScore(totalScoreSub);
BigDecimal subtract = statEntity.getTotalAddScore().subtract(statEntity.getTotalSubScore());
statEntity.setTotalScore(subtract.compareTo(BigDecimal.ZERO) > 0 ? subtract : BigDecimal.ZERO);
int personNum = staffService.count(new StaffQuery().deptId(item.getId()), null);
if (personNum > 0) {
BigDecimal aver = statEntity.getTotalScore().divide(new BigDecimal(personNum), 2, BigDecimal.ROUND_CEILING);
statEntity.setAverageScore(aver);
} else {
statEntity.setAverageScore(BigDecimal.ZERO);
}
statEntity.setYear(DateUtil.year(curDate));
statEntity.setMonth(DateUtil.month(curDate) + 1);
statEntity.setDay(DateUtil.dayOfMonth(curDate));
return statEntity;
}).collect(Collectors.toList());
deptPerformStatService.save(collect);
}
return Rest.ok();
}
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING)); System.out.println(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2, BigDecimal.ROUND_CEILING));
} }
......
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