|
@@ -30,7 +30,9 @@ import java.time.Instant;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author zcj
|
|
@@ -62,13 +64,13 @@ public class WorkHourStatistics {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// @Scheduled(fixedDelay = 432000000L)
|
|
|
+ @Scheduled(fixedDelay = 432000000L)
|
|
|
public void updateHour() {
|
|
|
standardWorkHour();
|
|
|
standardWeeklyWorkHour();
|
|
|
standardMonthlyWorkHour();
|
|
|
- projectMemberHour();
|
|
|
- quitStandradHour();
|
|
|
+// projectMemberHour();
|
|
|
+// quitStandradHour();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -91,13 +93,13 @@ public class WorkHourStatistics {
|
|
|
//工时标准化
|
|
|
standardHour(chuanyunUserCompanyDO);
|
|
|
log.info("每日工时标准化"+chuanyunUserCompanyDO.getUserName()+(Instant.now().getEpochSecond()-start)+"秒");
|
|
|
+ updateChuanyunStandardWorkHour(chuanyunUserCompanyDO);
|
|
|
});
|
|
|
}else {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- log.info("每日工时标准化"+(Instant.now().getEpochSecond()-startTime)+"秒");
|
|
|
- updateChuanyunStandardWorkHour();
|
|
|
+// log.info("每日工时标准化"+(Instant.now().getEpochSecond()-startTime)+"秒");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -108,6 +110,10 @@ public class WorkHourStatistics {
|
|
|
if (!StringUtils.isEmpty(chuanyunUserCompanyDO.getUserId())){
|
|
|
//每人每个项目每天工时
|
|
|
List<ChuanyunWorkHourDO> selfList = chuanyunWorkHourDao.getSelfWorkHour(chuanyunUserCompanyDO.getUserId());
|
|
|
+ //删除多余每日工时
|
|
|
+ List<ChuanyunSelfWorkHourDO> list = chuanyunSelfWorkHourDao.findByUserId(chuanyunUserCompanyDO.getUserId());
|
|
|
+ compareDayWorkHour(selfList,list);
|
|
|
+ //更新
|
|
|
selfList.forEach(self->{
|
|
|
try{
|
|
|
ChuanyunSelfWorkHourDO chuanyunSelfWorkHourDO = new ChuanyunSelfWorkHourDO();
|
|
@@ -148,6 +154,48 @@ public class WorkHourStatistics {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 删除多余每日工时
|
|
|
+ * @param selfList
|
|
|
+ * @param list
|
|
|
+ */
|
|
|
+ private void compareDayWorkHour(List<ChuanyunWorkHourDO> selfList,List<ChuanyunSelfWorkHourDO> list){
|
|
|
+ Map<String, Integer> map = new HashMap<String, Integer>();
|
|
|
+ List<ChuanyunSelfWorkHourDO> surplusList = new ArrayList<>();
|
|
|
+ //判断工时是否有撤回
|
|
|
+ if (!(selfList.size()==list.size())){
|
|
|
+ for (ChuanyunWorkHourDO chuanyunWorkHourDO : selfList){
|
|
|
+ map.put(chuanyunWorkHourDO.getUserId()+chuanyunWorkHourDO.getProjectId()+chuanyunWorkHourDO.getDayLogDate(),1);
|
|
|
+ }
|
|
|
+ //比较是否有撤回工时
|
|
|
+ for (ChuanyunSelfWorkHourDO chuanyunSelfWorkHourDO : list){
|
|
|
+ Integer count = map.get(chuanyunSelfWorkHourDO.getUserId()+chuanyunSelfWorkHourDO.getProjectId()+chuanyunSelfWorkHourDO.getDayLogDate());
|
|
|
+ if (count==null){
|
|
|
+ try{
|
|
|
+ //删除数据库日工时
|
|
|
+ chuanyunSelfWorkHourDao.delete(chuanyunSelfWorkHourDO);
|
|
|
+ //删除氚云日工时
|
|
|
+ List<String> matchers = new ArrayList<>();
|
|
|
+ matchers.add("F0000001_2,"+chuanyunSelfWorkHourDO.getProjectId());
|
|
|
+ matchers.add("F0000002_2,"+chuanyunSelfWorkHourDO.getUserId());
|
|
|
+ matchers.add("F0000003_2,"+chuanyunSelfWorkHourDO.getDayLogDate());
|
|
|
+ var filter= Filter.instance(0,1,true,"And",matchers);
|
|
|
+ var chuanyunFindAllResponse=chuanYunManager.findAll(ChuanyunMemberHourDO.SCHEMA_CODE,filter);
|
|
|
+ ChuanyunSaveDTO chuanyunSaveDTO;
|
|
|
+ if (chuanyunFindAllResponse.getReturnData()!=null){
|
|
|
+ List<ChuanyunMemberHourDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
|
|
|
+ chuanyunSaveDTO = chuanYunManager.delete(ChuanyunMemberHourDO.SCHEMA_CODE,result.get(0).getObjectId());
|
|
|
+ }
|
|
|
+ log.info(chuanyunSelfWorkHourDO.getUserId()+"删除"+chuanyunSelfWorkHourDO.getDayLogDate()+"位于"+chuanyunSelfWorkHourDO.getProjectId()+"工时");
|
|
|
+ }catch(Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ log.error(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 人员-项目-周度工时汇总
|
|
|
*/
|
|
|
private void standardWeeklyWorkHour() {
|
|
@@ -288,17 +336,18 @@ public class WorkHourStatistics {
|
|
|
/**
|
|
|
* 定时更新氚云数据
|
|
|
*/
|
|
|
- private void updateChuanyunStandardWorkHour(){
|
|
|
+ private void updateChuanyunStandardWorkHour(ChuanyunUserCompanyDO oldChuanyunUserCompanyDO){
|
|
|
var flag = true;
|
|
|
var pageSize = 20;
|
|
|
var page = 0;
|
|
|
- log.info("开始更新日工时汇总");
|
|
|
+// log.info("开始更新日工时汇总");
|
|
|
long startTime=Instant.now().getEpochSecond();
|
|
|
- while(flag) {
|
|
|
- var pageable= PageRequest.of(page,pageSize);
|
|
|
- var updateList=chuanyunSelfWorkHourDao.findAll(pageable);
|
|
|
- if (page<=updateList.getTotalPages()){
|
|
|
- page += 1;
|
|
|
+// while(flag) {
|
|
|
+// var pageable= PageRequest.of(page,pageSize);
|
|
|
+// var updateList=chuanyunSelfWorkHourDao.findAll(pageable);
|
|
|
+// if (page<=updateList.getTotalPages()){
|
|
|
+// page += 1;
|
|
|
+ var updateList=chuanyunSelfWorkHourDao.findByUserId(oldChuanyunUserCompanyDO.getUserId());
|
|
|
updateList.forEach(chuanyunSelfWorkHourDO -> {
|
|
|
try{
|
|
|
String departmentId=chuanyunUserCompanyDao.findAllByUserId(chuanyunSelfWorkHourDO.getUserId()).get(0).getDepartmentId();
|
|
@@ -339,12 +388,12 @@ public class WorkHourStatistics {
|
|
|
log.warn("更新标准工时异常");
|
|
|
}
|
|
|
});
|
|
|
- }else {
|
|
|
- //流程执行完
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- log.info("日工时更新花费"+(Instant.now().getEpochSecond()-startTime));
|
|
|
+// }else {
|
|
|
+// //流程执行完
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+ log.info(oldChuanyunUserCompanyDO.getUserName()+"氚云日工时更新花费"+(Instant.now().getEpochSecond()-startTime)+"秒");
|
|
|
}
|
|
|
|
|
|
/**
|