|
@@ -1,5 +1,6 @@
|
|
|
package com.management.platform.task;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.management.platform.entity.*;
|
|
@@ -584,6 +585,9 @@ public class DataCollectTask {
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
for (Project project : toAddList) {
|
|
|
+ //以项目编码前五为作为分类名称
|
|
|
+ String categoryName = project.getProjectCode().substring(0,5);
|
|
|
+ project.setCategoryName(categoryName);
|
|
|
ProjectCategory category = projectCategoryMapper.selectOne(new LambdaQueryWrapper<ProjectCategory>()
|
|
|
.eq(ProjectCategory::getCompanyId, specialCompanyId)
|
|
|
.eq(ProjectCategory::getName, project.getCategoryName())
|
|
@@ -703,7 +707,7 @@ public class DataCollectTask {
|
|
|
}
|
|
|
|
|
|
@Scheduled(cron = "0 0 3 * * ?")
|
|
|
-//@Scheduled(cron = "0 20 17 * * ?")
|
|
|
+//@Scheduled(cron = "0 57 9 * * ?")
|
|
|
@Async
|
|
|
public void businessTripTask(){
|
|
|
if(isDev){return;}
|
|
@@ -724,6 +728,7 @@ public class DataCollectTask {
|
|
|
} else {
|
|
|
System.out.println("请求失败,状态码: " + sumResponse.getStatusCode());
|
|
|
}
|
|
|
+ System.out.println("出差数据:"+totalNum);
|
|
|
if(totalNum > 0){
|
|
|
int pageSize = 1000;
|
|
|
int offset = 0;
|
|
@@ -757,35 +762,72 @@ public class DataCollectTask {
|
|
|
List<BusinessTrip> realDataList = dataList.stream().filter(t -> StringUtils.isNotBlank(t.getOwnerId())).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(realDataList)){
|
|
|
List<String> collect = realDataList.stream().map(BusinessTrip::getProcinstId).distinct().collect(Collectors.toList());
|
|
|
- List<String> existIds = businessTripMapper.getExistIds(collect,specialCompanyId);
|
|
|
- if(!CollectionUtils.isEmpty(existIds)){
|
|
|
- toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
- toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
- }else{
|
|
|
- toAddList.addAll(realDataList);
|
|
|
+ List<BusinessTrip> existBTripList = businessTripMapper.selectList(new QueryWrapper<BusinessTrip>().in("procinst_id", collect));
|
|
|
+ for (BusinessTrip businessTrip : realDataList) {
|
|
|
+ if (existBTripList.stream().anyMatch(t -> t.getProcinstId().equals(businessTrip.getProcinstId()))) {
|
|
|
+ businessTrip.setId(existBTripList.stream().filter(t -> t.getProcinstId().equals(businessTrip.getProcinstId())).findFirst().get().getId());
|
|
|
+ toUpdateList.add(businessTrip);
|
|
|
+ } else {
|
|
|
+ toAddList.add(businessTrip);
|
|
|
+ }
|
|
|
}
|
|
|
+// if(existBTripList.size() > 0){
|
|
|
+// toUpdateList.addAll(realDataList.stream().filter(t -> existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
+// toAddList.addAll(realDataList.stream().filter(t -> !existIds.contains(t.getProcinstId())).collect(Collectors.toList()));
|
|
|
+// }else{
|
|
|
+// toAddList.addAll(realDataList);
|
|
|
+// }
|
|
|
if(!CollectionUtils.isEmpty(toAddList)){
|
|
|
// businessTripMapper.batchInsert(toAddList);
|
|
|
for (BusinessTrip businessTrip : toAddList) {
|
|
|
businessTripMapper.insert(businessTrip);
|
|
|
- BustripProject bustripProject = new BustripProject();
|
|
|
- bustripProject.setBustripId(businessTrip.getId());
|
|
|
- Project project = projectCodeMap.get(businessTrip.getCCcxmNo());
|
|
|
- bustripProject.setProjectId(null == project?null:project.getId());
|
|
|
- bustripProject.setStartDate(businessTrip.getStartDate());
|
|
|
- bustripProject.setEndDate(businessTrip.getEndDate());
|
|
|
- bustripProjectMapper.insert(bustripProject);
|
|
|
+ if (!StringUtils.isEmpty(businessTrip.getCCcxmNo())) {
|
|
|
+ String[] split = businessTrip.getCCcxmNo().split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ Project project = projectCodeMap.get(s);
|
|
|
+ if (project != null) {
|
|
|
+ BustripProject bustripProject = new BustripProject();
|
|
|
+ bustripProject.setBustripId(businessTrip.getId());
|
|
|
+ bustripProject.setProjectId(project.getId());
|
|
|
+ bustripProject.setStartDate(businessTrip.getStartDate());
|
|
|
+ bustripProject.setEndDate(businessTrip.getEndDate());
|
|
|
+ bustripProjectMapper.insert(bustripProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(toUpdateList)){
|
|
|
for (BusinessTrip tmp : toUpdateList) {
|
|
|
businessTripMapper.updateById(tmp);
|
|
|
+ //检查出差项目
|
|
|
+ if (!StringUtils.isEmpty(tmp.getCCcxmNo())) {
|
|
|
+ String[] split = tmp.getCCcxmNo().split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ Project project = projectCodeMap.get(s);
|
|
|
+ if (project != null) {
|
|
|
+ //查找是否已经存在
|
|
|
+ BustripProject existBustripProject = bustripProjectMapper.selectOne(
|
|
|
+ new LambdaQueryWrapper<BustripProject>().eq(BustripProject::getBustripId, tmp.getId()).eq(BustripProject::getProjectId, project.getId()).between(BustripProject::getStartDate, tmp.getStartDate(), tmp.getEndDate()));
|
|
|
+ if (existBustripProject == null) {
|
|
|
+ BustripProject bustripProject = new BustripProject();
|
|
|
+ bustripProject.setBustripId(tmp.getId());
|
|
|
+ bustripProject.setProjectId(project.getId());
|
|
|
+ bustripProject.setStartDate(tmp.getStartDate());
|
|
|
+ bustripProject.setEndDate(tmp.getEndDate());
|
|
|
+ bustripProjectMapper.insert(bustripProject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
toUpdateList.clear();
|
|
|
toAddList.clear();
|
|
|
+ } else {
|
|
|
+ System.out.println("出差数据为空");
|
|
|
}
|
|
|
|
|
|
}
|