|
@@ -9,14 +9,12 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
|
import com.galaxis.manatee.constant.ChuanYunConstant;
|
|
|
import com.galaxis.manatee.dao.*;
|
|
|
import com.galaxis.manatee.entity.chuanyun.data.object.*;
|
|
|
-import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunFindAllBizDTO;
|
|
|
import com.galaxis.manatee.entity.chuanyun.dto.ChuanyunSaveDTO;
|
|
|
import com.galaxis.manatee.entity.chuanyun.dto.Filter;
|
|
|
import com.galaxis.manatee.exception.BigSizeException;
|
|
|
import com.galaxis.manatee.manager.ChuanYunManager;
|
|
|
import com.galaxis.manatee.service.LogService;
|
|
|
import com.galaxis.manatee.service.LogStandardService;
|
|
|
-import com.galaxis.manatee.service.LogUpdateService;
|
|
|
import com.galaxis.manatee.util.ChuanyunLocalDateTimeDeserializer;
|
|
|
import com.galaxis.manatee.util.ChuanyunLocalDateTimeSerializer;
|
|
|
import lombok.Data;
|
|
@@ -30,7 +28,6 @@ import org.springframework.util.StringUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -47,21 +44,17 @@ public class WorkHourStatistics {
|
|
|
private final ChuanyunUserCompanyDao chuanyunUserCompanyDao;
|
|
|
private final ChuanyunWorkHourDao chuanyunWorkHourDao;
|
|
|
private final ChuanyunSelfWorkHourDao chuanyunSelfWorkHourDao;
|
|
|
- private final ChuanyunSelfCostDao chuanyunSelfCostDao;
|
|
|
private final ChuanyunMemberCostDao chuanyunMemberCostDao;
|
|
|
private final LogStandardService logStandardService;
|
|
|
- private final LogUpdateService logUpdateService;
|
|
|
private final LogService logService;
|
|
|
|
|
|
- public WorkHourStatistics(ChuanYunManager chuanYunManager, ChuanyunUserCompanyDao chuanyunUserCompanyDao, ChuanyunWorkHourDao chuanyunWorkHourDao, ChuanyunSelfWorkHourDao chuanyunSelfWorkHourDao, ChuanyunSelfCostDao chuanyunSelfCostDao, ChuanyunMemberCostDao chuanyunMemberCostDao, LogStandardService logStandardService, LogUpdateService logUpdateService, LogService logService) {
|
|
|
+ public WorkHourStatistics(ChuanYunManager chuanYunManager, ChuanyunUserCompanyDao chuanyunUserCompanyDao, ChuanyunWorkHourDao chuanyunWorkHourDao, ChuanyunSelfWorkHourDao chuanyunSelfWorkHourDao, ChuanyunMemberCostDao chuanyunMemberCostDao, LogStandardService logStandardService, LogService logService) {
|
|
|
this.chuanYunManager = chuanYunManager;
|
|
|
this.chuanyunUserCompanyDao = chuanyunUserCompanyDao;
|
|
|
this.chuanyunWorkHourDao = chuanyunWorkHourDao;
|
|
|
this.chuanyunSelfWorkHourDao = chuanyunSelfWorkHourDao;
|
|
|
- this.chuanyunSelfCostDao = chuanyunSelfCostDao;
|
|
|
this.chuanyunMemberCostDao = chuanyunMemberCostDao;
|
|
|
this.logStandardService = logStandardService;
|
|
|
- this.logUpdateService = logUpdateService;
|
|
|
this.logService = logService;
|
|
|
}
|
|
|
|
|
@@ -70,9 +63,9 @@ public class WorkHourStatistics {
|
|
|
*/
|
|
|
@Scheduled(fixedDelay = 10800000L)
|
|
|
public void updateHour(){
|
|
|
- logUpdateService.updateAllChuanyunSelfWorkHour();
|
|
|
- logUpdateService.updateAllChuanyunWeekMemberHour();
|
|
|
- logUpdateService.updateAllChuanyunSelfCost();
|
|
|
+ logService.updateAllChuanyunSelfWorkHour();
|
|
|
+ logService.updateAllChuanyunWeekMemberHour();
|
|
|
+ logService.updateAllChuanyunSelfCost();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -84,7 +77,7 @@ public class WorkHourStatistics {
|
|
|
//每日工时标准化
|
|
|
standardWorkHour();
|
|
|
standardWeeklyWorkHour();
|
|
|
-// standardMonthlyWorkHour();
|
|
|
+ standardMonthlyWorkHour();
|
|
|
// projectMemberHour();
|
|
|
//离职人员工时标准化
|
|
|
// quitStandardHour();
|
|
@@ -122,98 +115,7 @@ public class WorkHourStatistics {
|
|
|
* 单月工时汇总
|
|
|
*/
|
|
|
private void standardMonthlyWorkHour() {
|
|
|
- var flag = true;
|
|
|
- var pageSize = 20;
|
|
|
- var page = 0;
|
|
|
- log.info("开始月工时标准化");
|
|
|
- while (flag) {
|
|
|
- var pageable = PageRequest.of(page, pageSize);
|
|
|
- var chuanyunUserCompanyList = chuanyunUserCompanyDao.findAllByStatus(1, pageable);
|
|
|
- if (page <= chuanyunUserCompanyList.getTotalPages()) {
|
|
|
- page += 1;
|
|
|
- List<ChuanyunUserCompanyDO> userCompanyDOList = chuanyunUserCompanyList.getContent();
|
|
|
- //单项目单人单月成本
|
|
|
- userCompanyDOList.forEach(this::standardMonthlyHour);
|
|
|
- } else {
|
|
|
- flag = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 员工每月、各个项目标准工时会职工
|
|
|
- *
|
|
|
- * @param chuanyunUserCompanyDO 员工信息
|
|
|
- */
|
|
|
- private void standardMonthlyHour(ChuanyunUserCompanyDO chuanyunUserCompanyDO) {
|
|
|
- log.info(chuanyunUserCompanyDO.getUserName() + "月工时更新");
|
|
|
- //删除上一次状态为审核中,但本次已经审核通过的数据
|
|
|
- chuanyunSelfCostDao.findAllByStatusAndUserId(ChuanYunConstant.IN_PROCESS, chuanyunUserCompanyDO.getUserId()).forEach(chuanyunSelfCostDO -> {
|
|
|
- List<ChuanyunSelfWorkHourDO> chuanyunSelfWorkHourList = chuanyunSelfWorkHourDao.findAllByUserIdAndProjectIdAndProjectTypeAndStatusAndDayLogDateBetween(
|
|
|
- chuanyunSelfCostDO.getUserId(),
|
|
|
- chuanyunSelfCostDO.getProjectId(),
|
|
|
- chuanyunSelfCostDO.getProjectType(),
|
|
|
- ChuanYunConstant.IN_PROCESS,
|
|
|
- chuanyunSelfCostDO.getDayLogDate(),
|
|
|
- chuanyunSelfCostDO.getDayLogDate().plusMonths(1L));
|
|
|
- //如果没有仍在审批中的每日工时,则将该月、该项目的审核中的月工时统计删除,manatee数据库与氚云
|
|
|
- if (chuanyunSelfWorkHourList.size() == 0) {
|
|
|
- //删除manatee中的在审核工时
|
|
|
- chuanyunSelfCostDao.delete(chuanyunSelfCostDO);
|
|
|
- //删除氚云中的在审核工时
|
|
|
- List<String> matchers = new ArrayList<>();
|
|
|
- matchers.add("F0000003_2," + chuanyunSelfCostDO.getProjectId());
|
|
|
- matchers.add("F0000009_2," + ChuanYunConstant.IN_PROCESS);
|
|
|
- matchers.add("F0000002_2," + chuanyunSelfCostDO.getUserId());
|
|
|
- matchers.add("F0000008_2," + chuanyunSelfCostDO.getProjectType());
|
|
|
- matchers.add("F0000004_2," + chuanyunSelfCostDO.getDayLogDate());
|
|
|
- var filter = Filter.instance(0, 1, true, "And", matchers);
|
|
|
- try {
|
|
|
- ChuanyunFindAllBizDTO<Object> chuanyunFindAllResponse = chuanYunManager.findAll(ChuanyunMemberMonthCostDO.SCHEMA_CODE, filter);
|
|
|
- if (chuanyunFindAllResponse.getReturnData() != null) {
|
|
|
- List<ChuanyunMemberMonthCostDO> result = objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>() {
|
|
|
- });
|
|
|
- result.forEach(chuanyunMemberMonthCostDO -> {
|
|
|
- try {
|
|
|
- chuanYunManager.delete(ChuanyunMemberMonthCostDO.SCHEMA_CODE, chuanyunMemberMonthCostDO.getObjectId());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("逐条删除失败" + e.getMessage());
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.error("删除已审核通过的月度数据汇总失败");
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- //每月每项目工时,按月-项目-用户分组统计标准工时
|
|
|
- List<ChuanyunSelfWorkHourDO> list = chuanyunSelfWorkHourDao.getMonthProjectHour(chuanyunUserCompanyDO.getUserId());
|
|
|
- DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
- list.forEach(projectMonth -> {
|
|
|
- //获取人员-月度-相同工时状态标准工时汇总
|
|
|
- ChuanyunSelfWorkHourDO monthHour = chuanyunSelfWorkHourDao.getMonthHour(projectMonth.getUserId(), df.format(projectMonth.getDayLogDate()), projectMonth.getStatus());
|
|
|
- ChuanyunSelfCostDO chuanyunSelfCostDO = new ChuanyunSelfCostDO();
|
|
|
- chuanyunSelfCostDO.setStatus(projectMonth.getStatus());
|
|
|
- if (monthHour != null) {
|
|
|
- chuanyunSelfCostDO.setMonthlyTotalHour(monthHour.getStandardWorkHour());
|
|
|
- }
|
|
|
- chuanyunSelfCostDO.setProjectId(projectMonth.getProjectId());
|
|
|
- chuanyunSelfCostDO.setProjectType(projectMonth.getProjectType());
|
|
|
- chuanyunSelfCostDO.setUserId(projectMonth.getUserId());
|
|
|
- chuanyunSelfCostDO.setDayLogDate(projectMonth.getDayLogDate().withDayOfMonth(1));
|
|
|
- chuanyunSelfCostDO.setTotalHour(projectMonth.getStandardWorkHour());
|
|
|
- chuanyunSelfCostDO.setDepartmentId(chuanyunUserCompanyDO.getDepartmentId());
|
|
|
- ChuanyunSelfCostDO oldSelfDO = chuanyunSelfCostDao.getOldSelfDO(chuanyunSelfCostDO.getUserId(),
|
|
|
- chuanyunSelfCostDO.getProjectId(),
|
|
|
- chuanyunSelfCostDO.getProjectType(),
|
|
|
- df.format(chuanyunSelfCostDO.getDayLogDate()),
|
|
|
- projectMonth.getStatus());
|
|
|
- if (oldSelfDO != null) {
|
|
|
- chuanyunSelfCostDao.delete(oldSelfDO);
|
|
|
- }
|
|
|
- chuanyunSelfCostDao.save(chuanyunSelfCostDO);
|
|
|
- });
|
|
|
+ logService.standardAllSelfCost();
|
|
|
}
|
|
|
|
|
|
/**
|