Browse Source

计算流程 设定集团编码

miaolijing 2 years ago
parent
commit
0dc0b55970

+ 2 - 0
src/main/java/com/persagy/apm/diagnose/maintenance/service/impl/ProjectDataRecordServiceImpl.java

@@ -111,6 +111,8 @@ public class ProjectDataRecordServiceImpl implements IProjectDataRecordService {
                 // 获取不到锁,略过
                 return new AsyncResult<>("【监测维保数据计算线程】项目:" + projectDTO.getProjectId() + "被占用");
             }
+            String groupCode = SaasContext.getContextGroupCode();
+            SaasContext.setContextGroupCode(groupCode);
             long start = System.currentTimeMillis();
             AsyncResult<String> projectDTOBack = computeProjectMaintenanceData(todayDate, projectDTO);
             if (projectDTOBack != null) {

+ 5 - 0
src/main/java/com/persagy/apm/diagnose/service/CenterDataService.java

@@ -252,10 +252,15 @@ public class CenterDataService{
                         if (StringUtils.isEmpty(city)) {
                             continue;
                         }
+                        String groupCode = (String) infoMap.get("groupCode");
+                        if (StringUtils.isEmpty(groupCode)) {
+                            continue;
+                        }
                         ProjectDTO dto = new ProjectDTO();
                         dto.setProjectId(projID);
                         dto.setProjectLocalId(projLocalID);
                         dto.setCity(city);
+                        dto.setGroupCode(groupCode);
                         list.add(dto);
                     }
                 }

+ 3 - 1
src/main/java/com/persagy/apm/diagnose/service/MaintenanceDataService.java

@@ -4,6 +4,7 @@ import com.persagy.apm.diagnose.maintenance.model.dto.AlarmProjectDTO;
 import com.persagy.apm.diagnose.maintenance.service.IProjectDataRecordService;
 import com.persagy.apm.diagnose.service.dto.ProjectDTO;
 import com.persagy.apm.diagnose.utils.CommonUtils;
+import com.persagy.framework.tenant.mybatis.datasource.db.holder.SaasContext;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.time.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,7 +36,7 @@ public class MaintenanceDataService {
      * 计算 数据
      */
     public void computeMaintenanceData() throws Exception {
-
+        String groupCode = SaasContext.getContextGroupCode();
         //查询项目列表
         List<ProjectDTO> projectDTOList = centerDataService.queryProjectList();
         if (CollectionUtils.isEmpty(projectDTOList)) {
@@ -47,6 +48,7 @@ public class MaintenanceDataService {
         List<Future<String>> futureList = new ArrayList<>();
         CountDownLatch latch = new CountDownLatch(projectDTOList.size());
         for (ProjectDTO projectDTO : projectDTOList) {
+            SaasContext.setContextGroupCode(groupCode);
             futureList.add(projectDataRecordService.computeMaintenanceData(todayDate,projectDTO, latch));
         }
         //等待所有任务执行完

+ 1 - 0
src/main/java/com/persagy/apm/diagnose/service/dto/ProjectDTO.java

@@ -22,4 +22,5 @@ public class ProjectDTO {
 	private String projectId;
 	private String projectLocalId;
 	private String city;
+	private String groupCode;
 }