|
@@ -1,5 +1,6 @@
|
|
|
package com.persagy.adm.server.custom.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.date.DatePattern;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -26,12 +27,15 @@ import com.persagy.adm.server.custom.entity.*;
|
|
|
import com.persagy.adm.server.custom.entity.db.*;
|
|
|
import com.persagy.adm.server.custom.enums.DeliveryTypeEnum;
|
|
|
import com.persagy.adm.server.custom.service.*;
|
|
|
+import com.persagy.adm.server.custom.service.impl.check_update.CheckUpdateChain;
|
|
|
+import com.persagy.adm.server.custom.service.impl.check_update.CheckUpdateContext;
|
|
|
import com.persagy.adm.server.custom.util.DataExtrasUtil;
|
|
|
+import com.persagy.dmp.auth.domain.BossAuthUser;
|
|
|
import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.common.constant.ValidEnum;
|
|
|
-import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.digital.client.DigitalObjectClient;
|
|
|
import com.persagy.dmp.digital.client.DigitalRelationClient;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -40,6 +44,7 @@ import java.sql.Timestamp;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SyncAppImpl implements ISyncApp {
|
|
|
|
|
|
@Autowired
|
|
@@ -446,98 +451,15 @@ public class SyncAppImpl implements ISyncApp {
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean hasUpdate(HasUpdateReq hasUpdateReq) {
|
|
|
-
|
|
|
- // downloadAdmTs
|
|
|
- // 1.问题数据最容易变化,优先检查 adm库
|
|
|
- LambdaQueryWrapper<AdmProblem> hasProblemUpdated = new LambdaQueryWrapper<AdmProblem>().select(AdmProblem::getId)
|
|
|
- .gt(AdmProblem::getTs, hasUpdateReq.getDownloadAdmTs())
|
|
|
- .eq(AdmProblem::getGroupCode,hasUpdateReq.getGroupCode())
|
|
|
- .eq(AdmProblem::getProjectId,hasUpdateReq.getProjectId())
|
|
|
- .last("limit 1");
|
|
|
- AdmProblem admProblem = problemMapper.selectOne(hasProblemUpdated);
|
|
|
- if (admProblem != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // downloadAdmTs
|
|
|
- //管道数据,实验方案
|
|
|
- AdmPipe admPipe = pipeMapper.selectOne(new LambdaQueryWrapper<AdmPipe>().select(AdmPipe::getId).eq(AdmPipe::getProjectId, hasUpdateReq.getProjectId()).gt(AdmPipe::getTs, hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if (admPipe != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- //任务相关数据查询
|
|
|
- AdmJobSpace jobSpace = jobSpaceMapper.selectOne(new LambdaQueryWrapper<AdmJobSpace>().select(AdmJobSpace::getId).eq(AdmJobSpace::getProjectId,hasUpdateReq.getProjectId()).gt(AdmJobSpace::getTs,hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if (jobSpace != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 下载ADM图纸
|
|
|
- AdmCad admCad = admCadMapper.selectOne(new LambdaQueryWrapper<AdmCad>().select(AdmCad::getId).eq(AdmCad::getProjectId,hasUpdateReq.getProjectId()).gt(AdmCad::getTs,hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if(admCad != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 文件附件
|
|
|
- AdmFile file = fileMapper.selectOne(new LambdaQueryWrapper<AdmFile>().select(AdmFile::getId).eq(AdmFile::getProjectId,hasUpdateReq.getProjectId()).gt(AdmFile::getTs,hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if (file != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 二维码
|
|
|
- AdmQrCode qrCode = qrCodeMapper.selectOne(new LambdaQueryWrapper<AdmQrCode>().select(AdmQrCode::getId).eq(AdmQrCode::getProjectId,hasUpdateReq.getProjectId()).gt(AdmQrCode::getTs,hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if (qrCode != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 服务区域
|
|
|
- AdmServeArea serveArea = serveAreaMapper.selectOne(new LambdaQueryWrapper<AdmServeArea>().select(AdmServeArea::getId).eq(AdmServeArea::getProjectId,hasUpdateReq.getProjectId()).gt(AdmServeArea::getTs,hasUpdateReq.getDownloadAdmTs()).last("limit 1"));
|
|
|
- if (serveArea != null){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
-// String userId = admAuthService.loginInfo().getId();
|
|
|
- String userId = "1";
|
|
|
-
|
|
|
- // downloadBdtpTs
|
|
|
- // 2.检查对象 bdtp库
|
|
|
- QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper, AdmConst.OBJ_TYPE_BUILDING, AdmConst.OBJ_TYPE_FLOOR,AdmConst.OBJ_TYPE_SPACE, AdmConst.OBJ_TYPE_SHAFT, AdmConst.OBJ_TYPE_SYSTEM, AdmConst.OBJ_TYPE_EQUIPMENT, "ispace");
|
|
|
- criteria.setOnlyCount(true);
|
|
|
- criteria.setWithoutCount(true);
|
|
|
- criteria.getCriteria().putObject("ts").put("$gt", hasUpdateReq.getDownloadBdtpTs());
|
|
|
- CommonResult<List<ObjectNode>> query = objectClient.query(hasUpdateReq.getGroupCode(), hasUpdateReq.getProjectId(), AdmConst.APP_ID, userId, criteria);
|
|
|
- if(query.getCount() > 0){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // downloadObjRelTs
|
|
|
- // 3.检查对象关系
|
|
|
- // 3.1 app端创建的关系 bdtp库
|
|
|
- QueryCriteria objRelCriteria = ServiceUtil.getQueryCriteria(objectMapper);
|
|
|
- objRelCriteria.getCriteria().putObject("ts").put("$gt", hasUpdateReq.getDownLoadObjRelTs());
|
|
|
- objRelCriteria.getCriteria().put("createApp", AdmConst.CREATOR_APP);
|
|
|
- objRelCriteria.setOnlyCount(true);
|
|
|
- objRelCriteria.setWithoutCount(true);
|
|
|
- CommonResult<List<ObjectNode>> objRelResult = rwdClient.queryRelation(hasUpdateReq.getGroupCode(), hasUpdateReq.getProjectId(), AdmConst.APP_ID, userId, objRelCriteria);
|
|
|
- if (objRelResult.getCount() > 0){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- // 3.2 元空间和空间的对应关系 bdtp库
|
|
|
- QueryCriteria objRelCriteria2 = ServiceUtil.getQueryCriteria(objectMapper);
|
|
|
- objRelCriteria2.setOnlyCount(true);
|
|
|
- objRelCriteria2.setWithoutCount(true);
|
|
|
- objRelCriteria2.getCriteria().put("graphCode", "MechInArch").put("relCode", "Sp2Si").put("relValue", "GeneralZone").putObject("ts").put("$gt",hasUpdateReq.getDownLoadObjRelTs());
|
|
|
- CommonResult<List<ObjectNode>> objRelResult2 = rwdClient.queryRelation(hasUpdateReq.getGroupCode(), hasUpdateReq.getProjectId(), AdmConst.APP_ID, userId, objRelCriteria2);
|
|
|
- if (objRelResult2.getCount() > 0){
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
+ CheckUpdateContext context = new CheckUpdateContext();
|
|
|
+ BeanUtil.copyProperties(hasUpdateReq,context);
|
|
|
+ BossAuthUser bossAuthUser = admAuthService.loginInfo();
|
|
|
+ log.info("获取到用户信息:{}",bossAuthUser);
|
|
|
+ context.setUserId(bossAuthUser.getId());
|
|
|
+ return checkUpdateChain.doCheck(context);
|
|
|
}
|
|
|
-
|
|
|
- private AdmM2dEquipMapper m2dEquipMapper;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ CheckUpdateChain checkUpdateChain;
|
|
|
private void autoRelations(List<ObjectNode> newObjs, List<ObjectNode> relations, UploadParams ps){
|
|
|
for(ObjectNode obj : newObjs) {
|
|
|
if (obj.get("objType") != null && AdmConst.OBJ_TYPE_EQUIPMENT.equals(obj.get("objType").asText())) {
|