|
@@ -0,0 +1,143 @@
|
|
|
+package com.persagy.adm.server.custom.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
+import com.persagy.adm.server.custom.common.AdmConst;
|
|
|
+import com.persagy.adm.server.custom.dao.AdmCadMapper;
|
|
|
+import com.persagy.adm.server.custom.dao.AdmFileMapper;
|
|
|
+import com.persagy.adm.server.custom.dao.AdmProblemMapper;
|
|
|
+import com.persagy.adm.server.custom.dao.AdmQrCodeMapper;
|
|
|
+import com.persagy.adm.server.custom.entity.Pagination;
|
|
|
+import com.persagy.adm.server.custom.entity.db.AdmCad;
|
|
|
+import com.persagy.adm.server.custom.entity.db.AdmFile;
|
|
|
+import com.persagy.adm.server.custom.entity.db.AdmProblem;
|
|
|
+import com.persagy.adm.server.custom.entity.db.AdmQrCode;
|
|
|
+import com.persagy.adm.server.custom.interceptor.TokenInterceptor;
|
|
|
+import com.persagy.adm.server.custom.service.ServiceUtil;
|
|
|
+import com.persagy.adm.server.custom.service.impl.offline_data_download.CriteriaUtils;
|
|
|
+import com.persagy.adm.server.custom.service.impl.offline_data_download.DownLoadDataDeal;
|
|
|
+import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
+import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
+import com.persagy.dmp.common.utils.ResultHelper;
|
|
|
+import com.persagy.dmp.digital.client.DigitalObjectClient;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * APP离线数据下载接口
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/download")
|
|
|
+public class AppDataDownloadController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ AdmProblemMapper problemMapper;
|
|
|
+ @Autowired
|
|
|
+ AdmCadMapper admCadMapper;
|
|
|
+ @Autowired
|
|
|
+ AdmFileMapper fileMapper;
|
|
|
+ @Autowired
|
|
|
+ AdmQrCodeMapper qrCodeMapper;
|
|
|
+ @Autowired
|
|
|
+ ObjectMapper objectMapper;
|
|
|
+ @Autowired
|
|
|
+ DigitalObjectClient objectClient;
|
|
|
+ @Autowired
|
|
|
+ DownLoadDataDeal downLoadDataDeal;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载问题数据
|
|
|
+ */
|
|
|
+ @GetMapping("/problems")
|
|
|
+ public CommonResult<List<AdmProblem>> problems(@RequestParam String groupCode,@RequestParam String projectId,@RequestParam String buildingId, @RequestParam(required = false) Long ts, @RequestParam String clientId){
|
|
|
+ LambdaQueryWrapper<AdmProblem> queryWrapper = new LambdaQueryWrapper<AdmProblem>()
|
|
|
+ .eq(AdmProblem::getGroupCode, groupCode)
|
|
|
+ .eq(AdmProblem::getProjectId, projectId)
|
|
|
+ .eq(AdmProblem::getBuildingId, buildingId)
|
|
|
+ .gt(ts != null && ts != 0,AdmProblem::getTs, ts)
|
|
|
+ .ne(ts != null && ts != 0,AdmProblem::getModifier,CriteriaUtils.getOperator(clientId,TokenInterceptor.bossAuthUserThreadLocal.get().getId()))
|
|
|
+ .orderByDesc(AdmProblem::getModifiedTime);
|
|
|
+ List<AdmProblem> problems = problemMapper.selectList(queryWrapper);
|
|
|
+ Long modifiedTime = problems.get(0).getTs().getTime();
|
|
|
+
|
|
|
+ return ResultHelper.multi(problems);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载图纸数据
|
|
|
+ */
|
|
|
+ @GetMapping("/cadFiles")
|
|
|
+ public CommonResult<List<AdmCad>> cadFiles(@RequestParam String groupCode,@RequestParam String projectId,@RequestParam String buildingId,@RequestParam(required = false) Long ts){
|
|
|
+ List<AdmCad> admCads = admCadMapper.selectList(new LambdaQueryWrapper<AdmCad>()
|
|
|
+ .eq(AdmCad::getGroupCode,groupCode)
|
|
|
+ .eq(AdmCad::getProjectId,projectId)
|
|
|
+ .eq(AdmCad::getBuildingId,buildingId)
|
|
|
+ .gt(ts != null && ts != 0,AdmCad::getTs,ts));
|
|
|
+ return ResultHelper.multi(admCads);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 下载附件现场照片数据
|
|
|
+ */
|
|
|
+ @GetMapping("/files")
|
|
|
+ public CommonResult<List<AdmFile>> attachmentsFiles(@RequestParam String groupCode,@RequestParam String projectId,@RequestParam String buildingId, @RequestParam(required = false) Long ts, @RequestParam String clientId){
|
|
|
+ LambdaQueryWrapper<AdmFile> queryWrapper = Wrappers.lambdaQuery(AdmFile.class)
|
|
|
+ .eq(AdmFile::getGroupCode,groupCode)
|
|
|
+ .eq(AdmFile::getProjectId,projectId)
|
|
|
+ .eq(AdmFile::getBuildingId,buildingId)
|
|
|
+ .gt(ts != null && ts != 0 ,AdmFile::getTs,ts)
|
|
|
+ .ne(ts != null && ts != 0 ,AdmFile::getModifier, CriteriaUtils.getOperator(clientId,TokenInterceptor.bossAuthUserThreadLocal.get().getId()));
|
|
|
+ List<AdmFile> files = fileMapper.selectList(queryWrapper);
|
|
|
+ return ResultHelper.multi(files);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 二维码数据
|
|
|
+ */
|
|
|
+ @GetMapping("/qrCodes")
|
|
|
+ public CommonResult<List<AdmQrCode>> qrCodes(@RequestParam String groupCode,@RequestParam String projectId,@RequestParam String buildingId, @RequestParam(required = false) Long ts, @RequestParam String clientId){
|
|
|
+ LambdaQueryWrapper<AdmQrCode> queryWrapper = Wrappers.lambdaQuery(AdmQrCode.class)
|
|
|
+ .eq(AdmQrCode::getGroupCode,groupCode)
|
|
|
+ .eq(AdmQrCode::getProjectId,projectId)
|
|
|
+ .eq(AdmQrCode::getBuildingId,buildingId)
|
|
|
+ .gt(ts != null && ts != 0 ,AdmQrCode::getTs,ts)
|
|
|
+ .ne(ts != null && ts != 0 ,AdmQrCode::getModifier,CriteriaUtils.getOperator(clientId,TokenInterceptor.bossAuthUserThreadLocal.get().getId()));
|
|
|
+ List<AdmQrCode> qrCodes = qrCodeMapper.selectList(queryWrapper);
|
|
|
+ return ResultHelper.multi(qrCodes);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 对象数据
|
|
|
+ */
|
|
|
+ @GetMapping("/objects")
|
|
|
+ public Object objects(@RequestParam String groupCode,@RequestParam String projectId,@RequestParam String buildingId, @RequestParam(required = false) Long ts, @RequestParam String clientId){
|
|
|
+ //从bdtp下载对象(空间、竖井、系统、设备、元空间)
|
|
|
+ QueryCriteria criteria = ServiceUtil.getQueryCriteria(objectMapper, AdmConst.OBJ_TYPE_SPACE, AdmConst.OBJ_TYPE_SHAFT, AdmConst.OBJ_TYPE_SYSTEM, AdmConst.OBJ_TYPE_EQUIPMENT, AdmConst.OBJ_TYPE_ISPACE);
|
|
|
+ String operator = CriteriaUtils.getOperator(clientId, TokenInterceptor.bossAuthUserThreadLocal.get().getId());
|
|
|
+ CriteriaUtils.buildDownloadQueryCriteria(criteria,operator,ts);
|
|
|
+
|
|
|
+ // 增量数据下载
|
|
|
+ if (ts != null && ts > 0){
|
|
|
+ criteria.getCriteria().putObject("ts").put("$gt", ts);
|
|
|
+ criteria.getCriteria().putObject("modifier").put("$ne", operator);
|
|
|
+ }
|
|
|
+ criteria.getCriteria().put("buildingId", buildingId);
|
|
|
+ List<ObjectNode> objs = ServiceUtil.queryAllPage(() -> objectClient.query(groupCode, projectId, AdmConst.APP_ID, TokenInterceptor.bossAuthUserThreadLocal.get().getId(), criteria), criteria, new Pagination(500));
|
|
|
+ if (objs == null)
|
|
|
+ objs = new ArrayList<>(0);
|
|
|
+
|
|
|
+ // 处理下载数据并压缩公共字段
|
|
|
+ downLoadDataDeal.packInfos(objs);
|
|
|
+ // 填充ts
|
|
|
+ downLoadDataDeal.test4Ts(objs);
|
|
|
+ return ResultHelper.multi(objs);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|