|
@@ -1,11 +1,14 @@
|
|
|
package org.springblade.manager.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.date.DateTime;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
+import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.entity.WbsTreeSynchronousRecord;
|
|
|
import org.springblade.manager.mapper.WbsTreePrivateMapper;
|
|
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -42,7 +46,7 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
|
|
|
.select(WbsTreeSynchronousRecord::getNodeId)
|
|
|
.eq(WbsTreeSynchronousRecord::getProjectId, mWbsTreeSynchronousRecord.getProjectId())
|
|
|
.eq(WbsTreeSynchronousRecord::getIsDeleted, 0)
|
|
|
- .in(WbsTreeSynchronousRecord::getStatus, 1, 2));
|
|
|
+ .in(WbsTreeSynchronousRecord::getStatus, 0, 1));
|
|
|
List<String> nodeIds = wbsTreeSynchronousRecords.stream().map(WbsTreeSynchronousRecord::getNodeId).collect(Collectors.toList());
|
|
|
|
|
|
//所有子节点集合
|
|
@@ -59,9 +63,17 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
|
|
|
);
|
|
|
privateIds.add(Long.valueOf(s));
|
|
|
privateIds.addAll(wbsTreePrivates.stream().map(WbsTreePrivate::getPKeyId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+
|
|
|
+ // //判断节点类型 如果是试验或计量则不允许添加合同合同段
|
|
|
+ WbsTreePrivate wbsTreePrivate = wbsTreePrivateMapper.selectById(nodeId);
|
|
|
+ if (mWbsTreeSynchronousRecord.getRange() == 2 && wbsTreePrivate != null && !Objects.equals(wbsTreePrivate.getWbsType(), 1)) {
|
|
|
+ throw new ServiceException(wbsTreePrivate.getNodeName() + " 节点不是质检类型,无法同步合同段");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
//记录选中节点下的表单数
|
|
|
int count = 0;
|
|
|
String[] newNodeIds = mWbsTreeSynchronousRecord.getNodeId().split(",");
|
|
@@ -94,29 +106,33 @@ public class WbsTreeSynchronousRecordServiceImpl extends ServiceImpl<WbsTreeSync
|
|
|
|
|
|
/**
|
|
|
* 同步节点表单
|
|
|
- * 定时检查同步任务,状态为1的数据如果最后更新时间与当前时间超过10分钟,则修改状态为1
|
|
|
+ * 定时检查同步任务,状态为1的数据如果最后更新时间与当前时间超过10分钟,则修改状态为1
|
|
|
*/
|
|
|
@Scheduled(fixedDelay = 10000)
|
|
|
public void syncInit() {
|
|
|
List<WbsTreeSynchronousRecord> wbsTreeSynchronousRecords = baseMapper.selectList(new QueryWrapper<WbsTreeSynchronousRecord>().lambda()
|
|
|
- .in(WbsTreeSynchronousRecord::getStatus, 0,1)
|
|
|
+ .in(WbsTreeSynchronousRecord::getStatus, 0, 1)
|
|
|
.eq(WbsTreeSynchronousRecord::getIsDeleted, 0)
|
|
|
.orderByAsc(WbsTreeSynchronousRecord::getCreateTime)
|
|
|
.last("limit 10")
|
|
|
);
|
|
|
|
|
|
for (WbsTreeSynchronousRecord wbsTreeSynchronousRecord : wbsTreeSynchronousRecords) {
|
|
|
- if(wbsTreeSynchronousRecord.getStatus() == 1){
|
|
|
+ if (wbsTreeSynchronousRecord.getStatus() == 1) {
|
|
|
if (wbsTreeSynchronousRecord.getUpdateTime().getTime() + 600000 < System.currentTimeMillis()) {
|
|
|
- wbsTreeSynchronousRecord.setStatus(0);
|
|
|
- baseMapper.updateById(wbsTreeSynchronousRecord);
|
|
|
+
|
|
|
+ baseMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
+ .set(WbsTreeSynchronousRecord::getStatus, 0)
|
|
|
+ .eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
//通过线程池执行同步任务
|
|
|
wbsSynchronousService.syncExecute(wbsTreeSynchronousRecord);
|
|
|
//修改数据状态为正在同步
|
|
|
- wbsTreeSynchronousRecord.setStatus(1);
|
|
|
- baseMapper.updateById(wbsTreeSynchronousRecord);
|
|
|
+ baseMapper.update(null, Wrappers.<WbsTreeSynchronousRecord>lambdaUpdate()
|
|
|
+ .set(WbsTreeSynchronousRecord::getStatus, 1)
|
|
|
+ .set(WbsTreeSynchronousRecord::getUpdateTime, DateTime.now())
|
|
|
+ .eq(WbsTreeSynchronousRecord::getId, wbsTreeSynchronousRecord.getId()));
|
|
|
}
|
|
|
|
|
|
|