Commit 8602d1ec authored by 赵啸非's avatar 赵啸非

修改考勤汇总

parent 7a16b11e
package com.mortals.xhx.busiz;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.utils.ServletUtils;
import com.mortals.xhx.base.system.idgenerator.service.IdgeneratorService;
import com.mortals.xhx.base.system.upload.service.UploadService;
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.service.UserService;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.perform.model.PerformPerposeStaffEntity;
import com.mortals.xhx.module.perform.model.PerformPerposeStaffStatEntity;
import com.mortals.xhx.module.perform.service.PerformPerposeStaffService;
import com.mortals.xhx.module.perform.service.PerformPerposeStaffStatService;
import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService;
import com.mortals.xhx.module.workman.model.WorkmanEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
/**
* 设备
*
* @author: zxfei
* @date: 2021/8/24 20:28
*/
@RestController
@Slf4j
@RequestMapping("/mock")
public class MockDataController {
@Autowired
private IdgeneratorService idgeneratorService;
@Autowired
private ICacheService cacheService;
@Autowired
private StaffService staffService;
@Autowired
private UserService userService;
@Autowired
private IHikFaceService faceService;
@Autowired
private UploadService uploadService;
@Autowired
private PerformPerposeStaffStatService perposeStaffStatService;
/**
* 生成模拟数据
* mortals_xhx_perform_perpose_staff_stat
*
* @return
*/
@GetMapping("randomStatPerposeStaffData")
@UnAuth
public Rest<Void> randomStatPerposeStaffData() {
List<StaffEntity> cacheList = staffService.getCacheList();
//最近两月模拟数据
DateTime beforeStartDate = DateUtil.offsetDay(new Date(), 60);
for (int i = 1; i <= 60; i++) {
DateTime curDate = DateUtil.offsetDay(beforeStartDate, i);
List<PerformPerposeStaffStatEntity> collect = cacheList.stream().map(item -> {
PerformPerposeStaffStatEntity statEntity = new PerformPerposeStaffStatEntity();
statEntity.initAttrValue();
statEntity.setStaffId(item.getId());
statEntity.setStaffName(item.getName());
statEntity.setNumber(item.getWorkNum());
statEntity.setAbsentRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setAbsenceRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setLateRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setEarlyRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setLeaveRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setTurnoverRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setSleepRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setPlayPhoneRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setExpireWorkRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setNegaReviewRate(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
statEntity.setYear(DateUtil.year(curDate));
statEntity.setMonth(DateUtil.month(curDate)+1);
statEntity.setDay(DateUtil.dayOfMonth(curDate));
return statEntity;
}).collect(Collectors.toList());
perposeStaffStatService.save(collect);
}
return Rest.ok();
}
public static void main(String[] args) {
System.out.println(RandomUtil.randomBigDecimal(BigDecimal.ZERO, new BigDecimal("1")).setScale(2,BigDecimal.ROUND_CEILING));
}
}
...@@ -17,6 +17,7 @@ import com.mortals.xhx.base.system.user.service.UserService; ...@@ -17,6 +17,7 @@ import com.mortals.xhx.base.system.user.service.UserService;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.hik.face.model.req.img.ImgReq; import com.mortals.xhx.module.hik.face.model.req.img.ImgReq;
import com.mortals.xhx.module.hik.face.service.IHikFaceService; import com.mortals.xhx.module.hik.face.service.IHikFaceService;
import com.mortals.xhx.module.perform.service.PerformPerposeStaffService;
import com.mortals.xhx.module.staff.model.StaffEntity; import com.mortals.xhx.module.staff.model.StaffEntity;
import com.mortals.xhx.module.staff.model.StaffQuery; import com.mortals.xhx.module.staff.model.StaffQuery;
import com.mortals.xhx.module.staff.service.StaffService; import com.mortals.xhx.module.staff.service.StaffService;
...@@ -62,6 +63,9 @@ public class TestController { ...@@ -62,6 +63,9 @@ public class TestController {
@Autowired @Autowired
private UploadService uploadService; private UploadService uploadService;
@Autowired
private PerformPerposeStaffService performPerposeStaffService;
// @GetMapping("webservice")@GetMapping("idGens") // @GetMapping("webservice")@GetMapping("idGens")
// public String idGens() { // public String idGens() {
...@@ -207,11 +211,12 @@ public class TestController { ...@@ -207,11 +211,12 @@ public class TestController {
/** /**
* 生成模拟数据 * 生成模拟数据
* mortals_xhx_perform_perpose_staff_stat
* @return * @return
*/ */
@GetMapping("randomStatData") @GetMapping("randomStatPerposeStaffData")
@UnAuth @UnAuth
public Rest<Void> randomMockStatData() { public Rest<Void> randomStatPerposeStaffData() {
return Rest.ok(); return Rest.ok();
......
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