Commit 89fb7c26 authored by 赵啸非's avatar 赵啸非

修改考勤汇总

parent cc0b2a56
......@@ -162,7 +162,7 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
homeStatInfo.setLevealPersonNum(6);
homeStatInfo.setLatePersonNum(2);
homeStatInfo.setLeftEarlyPersonNum(1);
homeStatInfo.setMissCardPersonNum(0);
homeStatInfo.setMissCardPersonNum(23);
data.put("homeStat", homeStatInfo);
data.put("token", token);
......
......@@ -19,8 +19,6 @@ public abstract class BaseReq implements Serializable {
*/
private Integer size;
/**
* 工号
*/
......
......@@ -14,6 +14,8 @@ 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.busiz.h5.rsp.ApiResp;
import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.module.dept.model.DeptEntity;
import com.mortals.xhx.module.dept.model.DeptQuery;
......@@ -28,9 +30,7 @@ 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.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
......@@ -72,22 +72,21 @@ public class TestController {
@Autowired
private PerformPerposeStaffService performPerposeStaffService;
/**
* 同步指定日期的海康数据
*
* @param req
* @return
*/
@PostMapping("hik")
public String register(@RequestBody BaseReq req) {
log.info("【测试消息】【请求体】--> " + JSONObject.toJSONString(req));
// @GetMapping("webservice")@GetMapping("idGens")
// public String idGens() {
// log.info("测试id生成");
//
// String stringId = idgeneratorService.getLongId(IdgeneratorServiceImpl.IdGeneratorKey.EFFECT).toString();
//
//
// return stringId;
// }
public String webservice() {
log.info("测试");
return "ok";
}
@GetMapping("updateDeptNum")
@UnAuth
public String updateDeptNum() {
......@@ -97,29 +96,86 @@ public class TestController {
collect.entrySet().stream().forEach(item -> {
Long deptId = item.getKey();
Long count = item.getValue();
log.info("dept:{},num:{}",deptId,count);
DeptEntity deptEntity = deptService.get(deptId);
if(!ObjectUtils.isEmpty(deptEntity)){
if (!ObjectUtils.isEmpty(deptEntity)) {
deptEntity.setPersonNum(count.intValue());
deptService.update(deptEntity);
}
});
for (Map.Entry<Long, Long> item : collect.entrySet()) {
Long deptId = item.getKey();
DeptEntity deptEntity = deptService.get(deptId);
if (!ObjectUtils.isEmpty(deptEntity) && !ObjectUtils.isEmpty(deptEntity.getParentId())) {
int sum = deptService.find(new DeptQuery().parentId(deptEntity.getId())).stream().mapToInt(i -> i.getPersonNum()).sum();
DeptEntity parentDept = deptService.get(deptEntity.getParentId());
log.info("dept:{},num:{}",parentDept.getDeptName(),sum);
if (ObjectUtils.isEmpty(parentDept)) {
parentDept.setPersonNum(sum);
deptService.update(parentDept);
// updateDeptPersonNum(parentDept);
}
}
}
/*
//更新父部门的人数归集
collect.entrySet().stream().forEach(item -> {
Long deptId = item.getKey();
DeptEntity deptEntity = deptService.get(deptId);
updateDeptPersonNum(deptEntity);
});
if (!ObjectUtils.isEmpty(deptEntity) && !ObjectUtils.isEmpty(deptEntity.getParentId())) {
int sum = deptService.find(new DeptQuery().parentId(deptEntity.getId())).stream().mapToInt(i -> i.getPersonNum()).sum();
DeptEntity parentDept = deptService.get(deptEntity.getParentId());
if (ObjectUtils.isEmpty(parentDept)) {
parentDept.setPersonNum(sum);
deptService.update(parentDept);
updateDeptPersonNum(parentDept);
}
}
// updateDeptPersonNum(deptEntity);
});*/
return "ok";
}
public static void calculateParentValue(DeptEntity root) {
if (root == null) {
return;
}
// 递归处理叶子节点
if (root.getChildren().isEmpty()) {
return;
}
// 递归计算所有子节点的值之和
int sum = 0;
for (DeptEntity child : root.getChildren()) {
calculateParentValue(child);
sum += child.getPersonNum();
}
// 更新当前节点的值为所有子节点值之和
root.setPersonNum(sum);
}
private void updateDeptPersonNum(DeptEntity deptEntity) {
if(!ObjectUtils.isEmpty(deptEntity)&&!ObjectUtils.isEmpty(deptEntity.getParentId())){
if (!ObjectUtils.isEmpty(deptEntity) && !ObjectUtils.isEmpty(deptEntity.getParentId())) {
int sum = deptService.find(new DeptQuery().parentId(deptEntity.getId())).stream().mapToInt(i -> i.getPersonNum()).sum();
DeptEntity parentDept = deptService.get(deptEntity.getParentId());
if(ObjectUtils.isEmpty(parentDept)){
if (ObjectUtils.isEmpty(parentDept)) {
parentDept.setPersonNum(sum);
deptService.update(parentDept);
updateDeptPersonNum(parentDept);
......
package com.mortals.xhx.busiz;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
@Data
public class TestReq {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimeStart;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTimeEnd;
}
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