mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
fix: hybrid approach — keep CFR for files where alt has import/lambda issues
Restored CFR versions for: OrganizationServiceImpl, ValidateManager, PersonAuditServiceImpl, DeviceGroupRefChangeEventHandler, CommonAppExportTaskServiceImpl, CommonAppFileManageServiceImpl, CommonAppExportExecuteTask Deleted re-appeared orphans: CpImageStoreServiceImpl, SelfRegistryHandler Applied batch fixes: map(()), computeIfAbsent(()), (Object) removal, Lists/Sets.newHashSet cleanup Result: 200→144 errors (-56, -28%)
This commit is contained in:
+441
-419
@@ -1,4 +1,5 @@
|
|||||||
package cn.cloudwalk.service.organization.export;
|
package cn.cloudwalk.service.organization.export;
|
||||||
|
// 业务服务
|
||||||
import cn.cloudwalk.client.organization.batch.param.download.FilePartFinishPara;
|
import cn.cloudwalk.client.organization.batch.param.download.FilePartFinishPara;
|
||||||
import cn.cloudwalk.client.organization.batch.param.download.FilePartInitResult;
|
import cn.cloudwalk.client.organization.batch.param.download.FilePartInitResult;
|
||||||
import cn.cloudwalk.client.organization.common.enums.FileStatusEnum;
|
import cn.cloudwalk.client.organization.common.enums.FileStatusEnum;
|
||||||
@@ -17,14 +18,21 @@ import cn.cloudwalk.client.organization.result.PersonProListResult;
|
|||||||
import cn.cloudwalk.client.organization.service.ICommonAppDownloadCenterService;
|
import cn.cloudwalk.client.organization.service.ICommonAppDownloadCenterService;
|
||||||
import cn.cloudwalk.client.organization.service.ICommonAppFileManageService;
|
import cn.cloudwalk.client.organization.service.ICommonAppFileManageService;
|
||||||
import cn.cloudwalk.client.organization.service.ICommonStorageService;
|
import cn.cloudwalk.client.organization.service.ICommonStorageService;
|
||||||
|
import cn.cloudwalk.client.organization.service.LabelService;
|
||||||
import cn.cloudwalk.client.organization.service.OrganizationService;
|
import cn.cloudwalk.client.organization.service.OrganizationService;
|
||||||
import cn.cloudwalk.client.organization.service.store.result.OrganizationResult;
|
import cn.cloudwalk.client.organization.service.store.result.OrganizationResult;
|
||||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||||
import cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartInitResultDTO;
|
import cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartInitResultDTO;
|
||||||
|
import cn.cloudwalk.intelligent.davinci.storage.manager.FilePartManager;
|
||||||
|
import cn.cloudwalk.intelligent.davinci.storage.manager.FileStorageManager;
|
||||||
|
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
|
||||||
import cn.cloudwalk.service.organization.common.CommonDownloadDataConfig;
|
import cn.cloudwalk.service.organization.common.CommonDownloadDataConfig;
|
||||||
import cn.cloudwalk.service.organization.common.MultipartFileUtils;
|
import cn.cloudwalk.service.organization.common.MultipartFileUtils;
|
||||||
import cn.cloudwalk.service.organization.config.ChannelFileReader;
|
import cn.cloudwalk.service.organization.config.ChannelFileReader;
|
||||||
|
import cn.cloudwalk.service.organization.export.CommonAppExportFileByLabelHandler;
|
||||||
|
import cn.cloudwalk.service.organization.export.CommonAppExportFileByOrgHandler;
|
||||||
|
import cn.cloudwalk.service.organization.export.CommonAppExportFileHandler;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -34,437 +42,451 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Base64Utils;
|
import org.springframework.util.Base64Utils;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class CommonAppExportExecuteTask extends AbstractImagStoreService {
|
public class CommonAppExportExecuteTask
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonAppExportExecuteTask.class);
|
extends AbstractImagStoreService {
|
||||||
@Autowired
|
private static final Logger log = LoggerFactory.getLogger(CommonAppExportExecuteTask.class);
|
||||||
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
|
@Autowired
|
||||||
@Autowired
|
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
|
||||||
private CommonDownloadDataConfig commonDownloadDataConfig;
|
@Autowired
|
||||||
@Autowired
|
private CommonDownloadDataConfig commonDownloadDataConfig;
|
||||||
private ICommonStorageService commonAppStorageService;
|
@Autowired
|
||||||
@Autowired
|
private ICommonStorageService commonAppStorageService;
|
||||||
private ImgStorePersonService imgStorePersonService;
|
@Autowired
|
||||||
@Autowired
|
private ImgStorePersonService imgStorePersonService;
|
||||||
private OrganizationService organizationService;
|
@Autowired
|
||||||
@Autowired
|
private OrganizationService organizationService;
|
||||||
private LabelService labelService;
|
@Autowired
|
||||||
@Autowired
|
private LabelService labelService;
|
||||||
private ImgStorePersonPropertiesService imgStorePersonPropertiesService;
|
@Autowired
|
||||||
@Autowired
|
private ImgStorePersonPropertiesService imgStorePersonPropertiesService;
|
||||||
private ICommonAppFileManageService iCommonAppFileManageService;
|
@Autowired
|
||||||
@Autowired
|
private ICommonAppFileManageService iCommonAppFileManageService;
|
||||||
private FilePartManager filePartManager;
|
@Autowired
|
||||||
@Autowired
|
private FilePartManager filePartManager;
|
||||||
private FileStorageManager fileStorageManager;
|
@Autowired
|
||||||
@Value("${cloudwalk.common-app.download.shardingSize}")
|
private FileStorageManager fileStorageManager;
|
||||||
private Integer shardingSize;
|
@Value(value="${cloudwalk.common-app.download.shardingSize}")
|
||||||
String fileName = "人员信息";
|
private Integer shardingSize;
|
||||||
String orgFileName = "机构信息";
|
String fileName = "人员信息";
|
||||||
String labelFileName = "标签信息";
|
String orgFileName = "机构信息";
|
||||||
@Async
|
String labelFileName = "标签信息";
|
||||||
public void execute(ExportRecordTaskParam task, CloudwalkCallContext cloudwalkCallContext) {
|
|
||||||
this.logger.info("开始执行人员信息导出功能");
|
@Async
|
||||||
QueryImgPersonParam queryImgPersonParam = new QueryImgPersonParam();
|
public void execute(ExportRecordTaskParam task, CloudwalkCallContext cloudwalkCallContext) {
|
||||||
BeanUtils.copyProperties(task, queryImgPersonParam);
|
this.logger.info("开始执行人员信息导出功能");
|
||||||
try {
|
QueryImgPersonParam queryImgPersonParam = new QueryImgPersonParam();
|
||||||
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = getPersonData(queryImgPersonParam, cloudwalkCallContext);
|
BeanUtils.copyProperties((Object)task, (Object)queryImgPersonParam);
|
||||||
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
|
try {
|
||||||
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
|
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = this.getPersonData(queryImgPersonParam, cloudwalkCallContext);
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
|
||||||
return;
|
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
|
||||||
}
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
|
return;
|
||||||
Map<String, List<ImgStorePersonGetResult>> dataMap = new HashMap<>();
|
}
|
||||||
dataMap.put(this.fileName, recordList.getData());
|
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
|
||||||
PersonProListResult personProListResult = (PersonProListResult)this.imgStorePersonPropertiesService.getList(task.getBusinessId()).getData();
|
HashMap<String, List<ImgStorePersonGetResult>> dataMap = new HashMap<String, List<ImgStorePersonGetResult>>();
|
||||||
List<ImgPersonProGetResult> properties = personProListResult.getProperties();
|
dataMap.put(this.fileName, (List<ImgStorePersonGetResult>)recordList.getData());
|
||||||
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
PersonProListResult personProListResult = (PersonProListResult)this.imgStorePersonPropertiesService.getList(task.getBusinessId()).getData();
|
||||||
result1.setId("1");
|
List properties = personProListResult.getProperties();
|
||||||
result1.setName("门禁设备(在线)");
|
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
||||||
result1.setCode("onlineDevices");
|
result1.setId("1");
|
||||||
result1.setStatus(Integer.valueOf(0));
|
result1.setName("门禁设备(在线)");
|
||||||
result1.setType(Short.valueOf((short)1));
|
result1.setCode("onlineDevices");
|
||||||
result1.setOrderNum(Integer.valueOf(17));
|
result1.setStatus(Integer.valueOf(0));
|
||||||
result1.setHasDefault(Integer.valueOf(1));
|
result1.setType(Short.valueOf((short)1));
|
||||||
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
result1.setOrderNum(Integer.valueOf(17));
|
||||||
result2.setId("2");
|
result1.setHasDefault(Integer.valueOf(1));
|
||||||
result2.setName("门禁设备(离线)");
|
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
||||||
result2.setCode("offlineDevices");
|
result2.setId("2");
|
||||||
result2.setStatus(Integer.valueOf(0));
|
result2.setName("门禁设备(离线)");
|
||||||
result2.setType(Short.valueOf((short)1));
|
result2.setCode("offlineDevices");
|
||||||
result2.setOrderNum(Integer.valueOf(18));
|
result2.setStatus(Integer.valueOf(0));
|
||||||
result2.setHasDefault(Integer.valueOf(1));
|
result2.setType(Short.valueOf((short)1));
|
||||||
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
result2.setOrderNum(Integer.valueOf(18));
|
||||||
result3.setId("3");
|
result2.setHasDefault(Integer.valueOf(1));
|
||||||
result3.setName("派梯楼层权限");
|
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
||||||
result3.setCode("floorNames");
|
result3.setId("3");
|
||||||
result3.setStatus(Integer.valueOf(0));
|
result3.setName("派梯楼层权限");
|
||||||
result3.setType(Short.valueOf((short)1));
|
result3.setCode("floorNames");
|
||||||
result3.setOrderNum(Integer.valueOf(19));
|
result3.setStatus(Integer.valueOf(0));
|
||||||
result3.setHasDefault(Integer.valueOf(1));
|
result3.setType(Short.valueOf((short)1));
|
||||||
properties.add(result1);
|
result3.setOrderNum(Integer.valueOf(19));
|
||||||
properties.add(result2);
|
result3.setHasDefault(Integer.valueOf(1));
|
||||||
properties.add(result3);
|
properties.add(result1);
|
||||||
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
|
properties.add(result2);
|
||||||
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
|
properties.add(result3);
|
||||||
this.commonDownloadDataConfig.setHasContainImage(task.getHasContainImage());
|
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON((Object)properties));
|
||||||
Path zipPath = (new CommonAppExportFileHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
|
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
|
||||||
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
this.commonDownloadDataConfig.setHasContainImage(task.getHasContainImage());
|
||||||
if (status > 1) {
|
Path zipPath = new CommonAppExportFileHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
|
||||||
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
|
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
if (status > 1) {
|
||||||
return;
|
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
|
||||||
}
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
||||||
this.logger.error("导出人员任务失败:{}", e.getMessage());
|
}
|
||||||
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
catch (Exception e) {
|
||||||
throw new RuntimeException("执行导出人员记录任务异常");
|
this.logger.error("导出人员任务失败:{}", (Object)e.getMessage());
|
||||||
}
|
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
||||||
}
|
throw new RuntimeException("执行导出人员记录任务异常");
|
||||||
@Async
|
}
|
||||||
public void executeOrg(ExportOrgTaskParam task, CloudwalkCallContext context) {
|
}
|
||||||
this.logger.info("开始执行机构信息导出功能");
|
|
||||||
QueryOrganizationParam queryImgPersonParam = new QueryOrganizationParam();
|
@Async
|
||||||
BeanUtils.copyProperties(task, queryImgPersonParam);
|
public void executeOrg(ExportOrgTaskParam task, CloudwalkCallContext context) {
|
||||||
try {
|
this.logger.info("开始执行机构信息导出功能");
|
||||||
CloudwalkResult<List<OrganizationResult>> recordList = getOrgData(queryImgPersonParam, context);
|
QueryOrganizationParam queryImgPersonParam = new QueryOrganizationParam();
|
||||||
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
|
BeanUtils.copyProperties((Object)task, (Object)queryImgPersonParam);
|
||||||
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
|
try {
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
CloudwalkResult<List<OrganizationResult>> recordList = this.getOrgData(queryImgPersonParam, context);
|
||||||
return;
|
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
|
||||||
}
|
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
|
||||||
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
Map<String, List<OrganizationResult>> dataMap = new HashMap<>();
|
return;
|
||||||
dataMap.put(this.orgFileName, recordList.getData());
|
}
|
||||||
PersonProListResult personProListResult = new PersonProListResult();
|
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
|
||||||
List<ImgPersonProGetResult> properties = new ArrayList<>();
|
HashMap<String, List<OrganizationResult>> dataMap = new HashMap<String, List<OrganizationResult>>();
|
||||||
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
dataMap.put(this.orgFileName, (List<OrganizationResult>)recordList.getData());
|
||||||
result1.setId("1");
|
PersonProListResult personProListResult = new PersonProListResult();
|
||||||
result1.setName("机构名称");
|
ArrayList<ImgPersonProGetResult> properties = new ArrayList<ImgPersonProGetResult>();
|
||||||
result1.setCode("name");
|
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
||||||
result1.setStatus(Integer.valueOf(0));
|
result1.setId("1");
|
||||||
result1.setType(Short.valueOf((short)1));
|
result1.setName("机构名称");
|
||||||
result1.setOrderNum(Integer.valueOf(1));
|
result1.setCode("name");
|
||||||
result1.setHasDefault(Integer.valueOf(1));
|
result1.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
result1.setType(Short.valueOf((short)1));
|
||||||
result2.setId("2");
|
result1.setOrderNum(Integer.valueOf(1));
|
||||||
result2.setName("机构id");
|
result1.setHasDefault(Integer.valueOf(1));
|
||||||
result2.setCode("id");
|
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
||||||
result2.setStatus(Integer.valueOf(0));
|
result2.setId("2");
|
||||||
result2.setType(Short.valueOf((short)1));
|
result2.setName("机构id");
|
||||||
result2.setOrderNum(Integer.valueOf(2));
|
result2.setCode("id");
|
||||||
result2.setHasDefault(Integer.valueOf(1));
|
result2.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
result2.setType(Short.valueOf((short)1));
|
||||||
result3.setId("3");
|
result2.setOrderNum(Integer.valueOf(2));
|
||||||
result3.setName("机构类型");
|
result2.setHasDefault(Integer.valueOf(1));
|
||||||
result3.setCode("type");
|
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
||||||
result3.setStatus(Integer.valueOf(0));
|
result3.setId("3");
|
||||||
result3.setType(Short.valueOf((short)1));
|
result3.setName("机构类型");
|
||||||
result3.setOrderNum(Integer.valueOf(3));
|
result3.setCode("type");
|
||||||
result3.setHasDefault(Integer.valueOf(1));
|
result3.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
|
result3.setType(Short.valueOf((short)1));
|
||||||
result4.setId("4");
|
result3.setOrderNum(Integer.valueOf(3));
|
||||||
result4.setName("人员数量");
|
result3.setHasDefault(Integer.valueOf(1));
|
||||||
result4.setCode("personCount");
|
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
|
||||||
result4.setStatus(Integer.valueOf(0));
|
result4.setId("4");
|
||||||
result4.setType(Short.valueOf((short)1));
|
result4.setName("人员数量");
|
||||||
result4.setOrderNum(Integer.valueOf(4));
|
result4.setCode("personCount");
|
||||||
result4.setHasDefault(Integer.valueOf(1));
|
result4.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
|
result4.setType(Short.valueOf((short)1));
|
||||||
result5.setId("5");
|
result4.setOrderNum(Integer.valueOf(4));
|
||||||
result5.setName("状态:0-已启用");
|
result4.setHasDefault(Integer.valueOf(1));
|
||||||
result5.setCode("isDel");
|
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
|
||||||
result5.setStatus(Integer.valueOf(0));
|
result5.setId("5");
|
||||||
result5.setType(Short.valueOf((short)1));
|
result5.setName("状态:0-已启用");
|
||||||
result5.setOrderNum(Integer.valueOf(5));
|
result5.setCode("isDel");
|
||||||
result5.setHasDefault(Integer.valueOf(1));
|
result5.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
|
result5.setType(Short.valueOf((short)1));
|
||||||
result6.setId("6");
|
result5.setOrderNum(Integer.valueOf(5));
|
||||||
result6.setName("门禁设备(在线)");
|
result5.setHasDefault(Integer.valueOf(1));
|
||||||
result6.setCode("onlineDevices");
|
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
|
||||||
result6.setStatus(Integer.valueOf(0));
|
result6.setId("6");
|
||||||
result6.setType(Short.valueOf((short)1));
|
result6.setName("门禁设备(在线)");
|
||||||
result6.setOrderNum(Integer.valueOf(6));
|
result6.setCode("onlineDevices");
|
||||||
result6.setHasDefault(Integer.valueOf(1));
|
result6.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
|
result6.setType(Short.valueOf((short)1));
|
||||||
result7.setId("7");
|
result6.setOrderNum(Integer.valueOf(6));
|
||||||
result7.setName("门禁设备(离线)");
|
result6.setHasDefault(Integer.valueOf(1));
|
||||||
result7.setCode("offlineDevices");
|
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
|
||||||
result7.setStatus(Integer.valueOf(0));
|
result7.setId("7");
|
||||||
result7.setType(Short.valueOf((short)1));
|
result7.setName("门禁设备(离线)");
|
||||||
result7.setOrderNum(Integer.valueOf(7));
|
result7.setCode("offlineDevices");
|
||||||
result7.setHasDefault(Integer.valueOf(1));
|
result7.setStatus(Integer.valueOf(0));
|
||||||
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
|
result7.setType(Short.valueOf((short)1));
|
||||||
result8.setId("8");
|
result7.setOrderNum(Integer.valueOf(7));
|
||||||
result8.setName("派梯楼层权限");
|
result7.setHasDefault(Integer.valueOf(1));
|
||||||
result8.setCode("floorNames");
|
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
|
||||||
result8.setStatus(Integer.valueOf(0));
|
result8.setId("8");
|
||||||
result8.setType(Short.valueOf((short)1));
|
result8.setName("派梯楼层权限");
|
||||||
result8.setOrderNum(Integer.valueOf(8));
|
result8.setCode("floorNames");
|
||||||
result8.setHasDefault(Integer.valueOf(1));
|
result8.setStatus(Integer.valueOf(0));
|
||||||
properties.add(result1);
|
result8.setType(Short.valueOf((short)1));
|
||||||
properties.add(result2);
|
result8.setOrderNum(Integer.valueOf(8));
|
||||||
properties.add(result3);
|
result8.setHasDefault(Integer.valueOf(1));
|
||||||
properties.add(result4);
|
properties.add(result1);
|
||||||
properties.add(result5);
|
properties.add(result2);
|
||||||
properties.add(result6);
|
properties.add(result3);
|
||||||
properties.add(result7);
|
properties.add(result4);
|
||||||
properties.add(result8);
|
properties.add(result5);
|
||||||
personProListResult.setProperties(properties);
|
properties.add(result6);
|
||||||
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
|
properties.add(result7);
|
||||||
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
|
properties.add(result8);
|
||||||
Path zipPath = (new CommonAppExportFileByOrgHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
|
personProListResult.setProperties(properties);
|
||||||
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
|
||||||
if (status > 1) {
|
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
|
||||||
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
|
Path zipPath = new CommonAppExportFileByOrgHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
||||||
return;
|
if (status > 1) {
|
||||||
}
|
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
}
|
return;
|
||||||
catch (Exception e) {
|
}
|
||||||
this.logger.error("导出机构任务失败:{}", e);
|
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
||||||
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
}
|
||||||
throw new RuntimeException("执行导出机构信息任务异常");
|
catch (Exception e) {
|
||||||
}
|
this.logger.error("导出机构任务失败:{}", e);
|
||||||
}
|
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
||||||
@Async
|
throw new RuntimeException("执行导出机构信息任务异常");
|
||||||
public void executeLabel(ExportLabelTaskParam task, CloudwalkCallContext context) {
|
}
|
||||||
this.logger.info("开始执行标签信息导出功能");
|
}
|
||||||
PageLabelParam pageLabelParam = new PageLabelParam();
|
|
||||||
BeanUtils.copyProperties(task, pageLabelParam);
|
@Async
|
||||||
try {
|
public void executeLabel(ExportLabelTaskParam task, CloudwalkCallContext context) {
|
||||||
CloudwalkResult<List<PageLabelResult>> recordList = getLabelData(pageLabelParam, context);
|
this.logger.info("开始执行标签信息导出功能");
|
||||||
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
|
PageLabelParam pageLabelParam = new PageLabelParam();
|
||||||
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
|
BeanUtils.copyProperties((Object)task, (Object)pageLabelParam);
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
try {
|
||||||
return;
|
CloudwalkResult<List<PageLabelResult>> recordList = this.getLabelData(pageLabelParam, context);
|
||||||
}
|
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
|
||||||
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
|
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
|
||||||
Map<String, List<PageLabelResult>> dataMap = new HashMap<>();
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
dataMap.put(this.labelFileName, recordList.getData());
|
return;
|
||||||
PersonProListResult personProListResult = new PersonProListResult();
|
}
|
||||||
List<ImgPersonProGetResult> properties = new ArrayList<>();
|
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
|
||||||
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
HashMap<String, List<PageLabelResult>> dataMap = new HashMap<String, List<PageLabelResult>>();
|
||||||
result1.setId("1");
|
dataMap.put(this.labelFileName, (List<PageLabelResult>)recordList.getData());
|
||||||
result1.setName("标签名称");
|
PersonProListResult personProListResult = new PersonProListResult();
|
||||||
result1.setCode("name");
|
ArrayList<ImgPersonProGetResult> properties = new ArrayList<ImgPersonProGetResult>();
|
||||||
result1.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
|
||||||
result1.setType(Short.valueOf((short)1));
|
result1.setId("1");
|
||||||
result1.setOrderNum(Integer.valueOf(1));
|
result1.setName("标签名称");
|
||||||
result1.setHasDefault(Integer.valueOf(1));
|
result1.setCode("name");
|
||||||
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
result1.setStatus(Integer.valueOf(0));
|
||||||
result2.setId("2");
|
result1.setType(Short.valueOf((short)1));
|
||||||
result2.setName("标签id");
|
result1.setOrderNum(Integer.valueOf(1));
|
||||||
result2.setCode("id");
|
result1.setHasDefault(Integer.valueOf(1));
|
||||||
result2.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
|
||||||
result2.setType(Short.valueOf((short)1));
|
result2.setId("2");
|
||||||
result2.setOrderNum(Integer.valueOf(2));
|
result2.setName("标签id");
|
||||||
result2.setHasDefault(Integer.valueOf(1));
|
result2.setCode("id");
|
||||||
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
result2.setStatus(Integer.valueOf(0));
|
||||||
result3.setId("3");
|
result2.setType(Short.valueOf((short)1));
|
||||||
result3.setName("标签编号");
|
result2.setOrderNum(Integer.valueOf(2));
|
||||||
result3.setCode("code");
|
result2.setHasDefault(Integer.valueOf(1));
|
||||||
result3.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
|
||||||
result3.setType(Short.valueOf((short)1));
|
result3.setId("3");
|
||||||
result3.setOrderNum(Integer.valueOf(3));
|
result3.setName("标签编号");
|
||||||
result3.setHasDefault(Integer.valueOf(1));
|
result3.setCode("code");
|
||||||
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
|
result3.setStatus(Integer.valueOf(0));
|
||||||
result4.setId("4");
|
result3.setType(Short.valueOf((short)1));
|
||||||
result4.setName("人员数量");
|
result3.setOrderNum(Integer.valueOf(3));
|
||||||
result4.setCode("personCount");
|
result3.setHasDefault(Integer.valueOf(1));
|
||||||
result4.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
|
||||||
result4.setType(Short.valueOf((short)1));
|
result4.setId("4");
|
||||||
result4.setOrderNum(Integer.valueOf(4));
|
result4.setName("人员数量");
|
||||||
result4.setHasDefault(Integer.valueOf(1));
|
result4.setCode("personCount");
|
||||||
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
|
result4.setStatus(Integer.valueOf(0));
|
||||||
result5.setId("5");
|
result4.setType(Short.valueOf((short)1));
|
||||||
result5.setName("标签类型:0-手动创建,1-应用初始,2-应用创建");
|
result4.setOrderNum(Integer.valueOf(4));
|
||||||
result5.setCode("addType");
|
result4.setHasDefault(Integer.valueOf(1));
|
||||||
result5.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
|
||||||
result5.setType(Short.valueOf((short)1));
|
result5.setId("5");
|
||||||
result5.setOrderNum(Integer.valueOf(5));
|
result5.setName("标签类型:0-手动创建,1-应用初始,2-应用创建");
|
||||||
result5.setHasDefault(Integer.valueOf(1));
|
result5.setCode("addType");
|
||||||
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
|
result5.setStatus(Integer.valueOf(0));
|
||||||
result6.setId("6");
|
result5.setType(Short.valueOf((short)1));
|
||||||
result6.setName("门禁设备(在线)");
|
result5.setOrderNum(Integer.valueOf(5));
|
||||||
result6.setCode("onlineDevices");
|
result5.setHasDefault(Integer.valueOf(1));
|
||||||
result6.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
|
||||||
result6.setType(Short.valueOf((short)1));
|
result6.setId("6");
|
||||||
result6.setOrderNum(Integer.valueOf(6));
|
result6.setName("门禁设备(在线)");
|
||||||
result6.setHasDefault(Integer.valueOf(1));
|
result6.setCode("onlineDevices");
|
||||||
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
|
result6.setStatus(Integer.valueOf(0));
|
||||||
result7.setId("7");
|
result6.setType(Short.valueOf((short)1));
|
||||||
result7.setName("门禁设备(离线)");
|
result6.setOrderNum(Integer.valueOf(6));
|
||||||
result7.setCode("offlineDevices");
|
result6.setHasDefault(Integer.valueOf(1));
|
||||||
result7.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
|
||||||
result7.setType(Short.valueOf((short)1));
|
result7.setId("7");
|
||||||
result7.setOrderNum(Integer.valueOf(7));
|
result7.setName("门禁设备(离线)");
|
||||||
result7.setHasDefault(Integer.valueOf(1));
|
result7.setCode("offlineDevices");
|
||||||
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
|
result7.setStatus(Integer.valueOf(0));
|
||||||
result8.setId("8");
|
result7.setType(Short.valueOf((short)1));
|
||||||
result8.setName("派梯楼层权限");
|
result7.setOrderNum(Integer.valueOf(7));
|
||||||
result8.setCode("floorNames");
|
result7.setHasDefault(Integer.valueOf(1));
|
||||||
result8.setStatus(Integer.valueOf(0));
|
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
|
||||||
result8.setType(Short.valueOf((short)1));
|
result8.setId("8");
|
||||||
result8.setOrderNum(Integer.valueOf(8));
|
result8.setName("派梯楼层权限");
|
||||||
result8.setHasDefault(Integer.valueOf(1));
|
result8.setCode("floorNames");
|
||||||
properties.add(result1);
|
result8.setStatus(Integer.valueOf(0));
|
||||||
properties.add(result2);
|
result8.setType(Short.valueOf((short)1));
|
||||||
properties.add(result3);
|
result8.setOrderNum(Integer.valueOf(8));
|
||||||
properties.add(result4);
|
result8.setHasDefault(Integer.valueOf(1));
|
||||||
properties.add(result5);
|
properties.add(result1);
|
||||||
properties.add(result6);
|
properties.add(result2);
|
||||||
properties.add(result7);
|
properties.add(result3);
|
||||||
properties.add(result8);
|
properties.add(result4);
|
||||||
personProListResult.setProperties(properties);
|
properties.add(result5);
|
||||||
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
|
properties.add(result6);
|
||||||
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
|
properties.add(result7);
|
||||||
Path zipPath = (new CommonAppExportFileByLabelHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
|
properties.add(result8);
|
||||||
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
personProListResult.setProperties(properties);
|
||||||
if (status > 1) {
|
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
|
||||||
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
|
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), null);
|
Path zipPath = new CommonAppExportFileByLabelHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
|
||||||
return;
|
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
|
||||||
}
|
if (status > 1) {
|
||||||
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
|
||||||
}
|
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
|
||||||
catch (Exception e) {
|
return;
|
||||||
this.logger.error("导出标签任务失败:{}", e);
|
}
|
||||||
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
|
||||||
throw new RuntimeException("执行导出标签信息任务异常");
|
}
|
||||||
}
|
catch (Exception e) {
|
||||||
}
|
this.logger.error("导出标签任务失败:{}", e);
|
||||||
private CloudwalkResult<List<ImgStorePersonGetResult>> getPersonData(QueryImgPersonParam queryImgPersonParam, CloudwalkCallContext cloudwalkCallContext) {
|
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
|
||||||
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = new CloudwalkResult();
|
throw new RuntimeException("执行导出标签信息任务异常");
|
||||||
try {
|
}
|
||||||
recordList = this.imgStorePersonService.listByPage(queryImgPersonParam, cloudwalkCallContext);
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
this.logger.error("查询记录数据失败");
|
private CloudwalkResult<List<ImgStorePersonGetResult>> getPersonData(QueryImgPersonParam queryImgPersonParam, CloudwalkCallContext cloudwalkCallContext) {
|
||||||
}
|
CloudwalkResult recordList = new CloudwalkResult();
|
||||||
return recordList;
|
try {
|
||||||
}
|
recordList = this.imgStorePersonService.listByPage(queryImgPersonParam, cloudwalkCallContext);
|
||||||
private CloudwalkResult<List<OrganizationResult>> getOrgData(QueryOrganizationParam param, CloudwalkCallContext context) {
|
}
|
||||||
CloudwalkResult<List<OrganizationResult>> recordList = new CloudwalkResult();
|
catch (Exception e) {
|
||||||
try {
|
this.logger.error("查询记录数据失败");
|
||||||
recordList = this.organizationService.listByPage(param, context);
|
}
|
||||||
} catch (Exception e) {
|
return recordList;
|
||||||
this.logger.error("查询机构记录数据失败");
|
}
|
||||||
}
|
|
||||||
return recordList;
|
private CloudwalkResult<List<OrganizationResult>> getOrgData(QueryOrganizationParam param, CloudwalkCallContext context) {
|
||||||
}
|
CloudwalkResult recordList = new CloudwalkResult();
|
||||||
private CloudwalkResult<List<PageLabelResult>> getLabelData(PageLabelParam param, CloudwalkCallContext cloudwalkCallContext) {
|
try {
|
||||||
CloudwalkResult<List<PageLabelResult>> recordList = new CloudwalkResult();
|
recordList = this.organizationService.listByPage(param, context);
|
||||||
try {
|
}
|
||||||
recordList = this.labelService.listByPage(param, cloudwalkCallContext);
|
catch (Exception e) {
|
||||||
} catch (Exception e) {
|
this.logger.error("查询机构记录数据失败");
|
||||||
this.logger.error("查询标签记录数据失败");
|
}
|
||||||
}
|
return recordList;
|
||||||
return recordList;
|
}
|
||||||
}
|
|
||||||
private void exportUpload(String businessId, String fileId, String zipPathStr) throws IOException {
|
private CloudwalkResult<List<PageLabelResult>> getLabelData(PageLabelParam param, CloudwalkCallContext cloudwalkCallContext) {
|
||||||
try {
|
CloudwalkResult recordList = new CloudwalkResult();
|
||||||
if (StringUtils.isNotBlank(zipPathStr)) {
|
try {
|
||||||
uploadFile(businessId, fileId, zipPathStr);
|
recordList = this.labelService.listByPage(param, cloudwalkCallContext);
|
||||||
} else {
|
}
|
||||||
byte[] data = Base64Utils.decodeFromString("UEsDBBQACAgIAAuPmlAAAAAAAAAAAAAAAAAGAAAAZW1wdHkvAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQAFAAICAgAC4+aUAAAAAACAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAGVtcHR5L1BLBQYAAAAAAQABADQAAAA2AAAAAAA=");
|
catch (Exception e) {
|
||||||
uploadFile(businessId, fileId, data, data.length);
|
this.logger.error("查询标签记录数据失败");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
return recordList;
|
||||||
this.logger.error("将导出文件生成的zip上传到文件管理中心发生异常:{}", e.getMessage());
|
}
|
||||||
throw new RuntimeException("将导出文件生成的zip上传到文件管理中心发生异常");
|
|
||||||
} finally {
|
private void exportUpload(String businessId, String fileId, String zipPathStr) throws IOException {
|
||||||
this.logger.debug("删除压缩包:{}", zipPathStr);
|
try {
|
||||||
File file = new File(zipPathStr);
|
if (StringUtils.isNotBlank((CharSequence)zipPathStr)) {
|
||||||
if (file.exists()) {
|
this.uploadFile(businessId, fileId, zipPathStr);
|
||||||
Files.delete(file.toPath());
|
} else {
|
||||||
}
|
byte[] data = Base64Utils.decodeFromString((String)"UEsDBBQACAgIAAuPmlAAAAAAAAAAAAAAAAAGAAAAZW1wdHkvAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQAFAAICAgAC4+aUAAAAAACAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAGVtcHR5L1BLBQYAAAAAAQABADQAAAA2AAAAAAA=");
|
||||||
}
|
this.uploadFile(businessId, fileId, data, data.length);
|
||||||
}
|
}
|
||||||
private void uploadFile(String businessId, String fileId, byte[] data, long fileSize) {
|
}
|
||||||
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
|
catch (Exception e) {
|
||||||
String name = uuidCode + this.commonDownloadDataConfig.getCompressionType();
|
this.logger.error("将导出文件生成的zip上传到文件管理中心发生异常:{}", (Object)e.getMessage());
|
||||||
String filePath = this.commonAppStorageService.saveFileBySharding(name, data);
|
throw new RuntimeException("将导出文件生成的zip上传到文件管理中心发生异常");
|
||||||
this.logger.info("存储文件名:fileId = {}, filePath = {}", fileId, filePath);
|
}
|
||||||
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
|
finally {
|
||||||
if (status == FileStatusEnum.PRODUCING.getCode().intValue() || status == FileStatusEnum.ERROR.getCode().intValue()) {
|
this.logger.debug("删除压缩包:{}", (Object)zipPathStr);
|
||||||
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
|
File file = new File(zipPathStr);
|
||||||
} else {
|
if (file.exists()) {
|
||||||
this.commonAppStorageService.deleteFile(filePath);
|
Files.delete(file.toPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void uploadFile(String businessId, String fileId, String zipPathStr) throws IOException {
|
}
|
||||||
ChannelFileReader reader = new ChannelFileReader(zipPathStr, this.shardingSize.intValue());
|
|
||||||
try {
|
private void uploadFile(String businessId, String fileId, byte[] data, long fileSize) {
|
||||||
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
String name = uuidCode + this.commonDownloadDataConfig.getCompressionType();
|
String name = new StringBuffer(uuidCode).append(this.commonDownloadDataConfig.getCompressionType()).toString();
|
||||||
FilePartInitResult resp = this.iCommonAppFileManageService.filePartInit(name);
|
String filePath = this.commonAppStorageService.saveFileBySharding(name, data);
|
||||||
if (resp == null) {
|
this.logger.info("存储文件名:fileId = {}, filePath = {}", (Object)fileId, (Object)filePath);
|
||||||
this.logger.info("分片上传文件初始化返回值为空");
|
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
|
||||||
return;
|
if (status == FileStatusEnum.PRODUCING.getCode() || status == FileStatusEnum.ERROR.getCode()) {
|
||||||
}
|
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
|
||||||
AtomicInteger i = new AtomicInteger(1);
|
} else {
|
||||||
long fileSize = 0L;
|
this.commonAppStorageService.deleteFile(filePath);
|
||||||
while (reader.read() != -1) {
|
}
|
||||||
this.logger.info("分片上传第{}次", Integer.valueOf(i.get()));
|
}
|
||||||
fileSize += (reader.getArray()).length;
|
|
||||||
uploadFileBySharding(reader.getArray(), resp.getFilePath(), resp.getUploadId(), this.fileName, String.valueOf(i.getAndAdd(1)));
|
/*
|
||||||
}
|
* WARNING - Removed try catching itself - possible behaviour change.
|
||||||
String filePath = filePartFinish(fileSize, resp);
|
*/
|
||||||
if (filePath == null) {
|
private void uploadFile(String businessId, String fileId, String zipPathStr) throws IOException {
|
||||||
this.logger.info("分片上传文件完成接口返回值为空");
|
try (ChannelFileReader reader = new ChannelFileReader(zipPathStr, this.shardingSize);){
|
||||||
return;
|
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
}
|
String name = new StringBuffer(uuidCode).append(this.commonDownloadDataConfig.getCompressionType()).toString();
|
||||||
this.logger.info("分片上传文件完成接口返回值 filePath = {}", filePath);
|
FilePartInitResult resp = this.iCommonAppFileManageService.filePartInit(name);
|
||||||
this.logger.info("存储文件名:fileId = {}, filePath = {}", fileId, filePath);
|
if (resp == null) {
|
||||||
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
|
this.logger.info("分片上传文件初始化返回值为空");
|
||||||
if (status == FileStatusEnum.PRODUCING.getCode().intValue() || status == FileStatusEnum.ERROR.getCode().intValue()) {
|
return;
|
||||||
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
|
}
|
||||||
} else {
|
AtomicInteger i = new AtomicInteger(1);
|
||||||
this.commonAppStorageService.deleteFile(filePath);
|
long fileSize = 0L;
|
||||||
}
|
while (reader.read() != -1) {
|
||||||
this.logger.info("完成上传任务 fileId = {}", fileId);
|
this.logger.info("分片上传第{}次", (Object)i.get());
|
||||||
} catch (Exception e) {
|
fileSize += (long)reader.getArray().length;
|
||||||
this.logger.error("分片上传文件报错 {}: {}", e.getClass().getName(), e.getMessage());
|
this.uploadFileBySharding(reader.getArray(), resp.getFilePath(), resp.getUploadId(), this.fileName, String.valueOf(i.getAndAdd(1)));
|
||||||
} finally {
|
}
|
||||||
reader.close();
|
String filePath = this.filePartFinish(fileSize, resp);
|
||||||
}
|
if (filePath == null) {
|
||||||
}
|
this.logger.info("分片上传文件完成接口返回值为空");
|
||||||
private String filePartFinish(long fileSize, FilePartInitResult resp) {
|
return;
|
||||||
FilePartFinishPara para = new FilePartFinishPara();
|
}
|
||||||
BeanUtils.copyProperties(resp, para);
|
this.logger.info("分片上传文件完成接口返回值 filePath = {}", (Object)filePath);
|
||||||
para.setFileSize(Long.valueOf(fileSize));
|
this.logger.info("存储文件名:fileId = {}, filePath = {}", (Object)fileId, (Object)filePath);
|
||||||
para.setReturnType(Integer.valueOf(0));
|
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
|
||||||
return this.iCommonAppFileManageService.filePartFinish(para);
|
if (status == FileStatusEnum.PRODUCING.getCode() || status == FileStatusEnum.ERROR.getCode()) {
|
||||||
}
|
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
|
||||||
private void uploadFileBySharding(byte[] bytes, String filePath, String uploadId, String fileName, String partNumber) {
|
} else {
|
||||||
MultipartFile mfile = MultipartFileUtils.getMultipartFile(fileName, bytes);
|
this.commonAppStorageService.deleteFile(filePath);
|
||||||
try {
|
}
|
||||||
PartInitResultDTO partInitResultDTO = this.filePartManager.append(filePath, Integer.valueOf(partNumber), uploadId, mfile);
|
this.logger.info("完成上传任务 fileId = {}", (Object)fileId);
|
||||||
} catch (Exception e) {
|
}
|
||||||
this.logger.error("分片更新文件错误{}:{}", e.getClass().getName(), e.getMessage());
|
}
|
||||||
}
|
|
||||||
}
|
private String filePartFinish(long fileSize, FilePartInitResult resp) {
|
||||||
|
FilePartFinishPara para = new FilePartFinishPara();
|
||||||
|
BeanUtils.copyProperties((Object)resp, (Object)para);
|
||||||
|
para.setFileSize(Long.valueOf(fileSize));
|
||||||
|
para.setReturnType(Integer.valueOf(0));
|
||||||
|
return this.iCommonAppFileManageService.filePartFinish(para);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void uploadFileBySharding(byte[] bytes, String filePath, String uploadId, String fileName, String partNumber) {
|
||||||
|
MultipartFile mfile = MultipartFileUtils.getMultipartFile(fileName, bytes);
|
||||||
|
try {
|
||||||
|
PartInitResultDTO partInitResultDTO = this.filePartManager.append(filePath, Integer.valueOf(partNumber), uploadId, mfile);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
this.logger.error("分片更新文件错误{}:{}", (Object)e.getClass().getName(), (Object)e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/export/CommonAppExportExecuteTask.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
+1
-1
@@ -203,7 +203,7 @@ PersonBatchImportTask.BATCH_SEMAPHORE.release();
|
|||||||
private void cleanFiles(BatchImportContext context) {
|
private void cleanFiles(BatchImportContext context) {
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(context.getUnzipFolder());
|
FileUtils.deleteDirectory(context.getUnzipFolder());
|
||||||
this.personFileService.delete(Lists.newArrayList((Object[])new String[] { context.getBatchImport().getFilePath() }));
|
this.personFileService.delete(Lists.newArrayList(context.getBatchImport().getFilePath() ));
|
||||||
FileUtils.deleteQuietly(new File(this.tempPath, context.getBatchImport().getBatchNo() + ".zip"));
|
FileUtils.deleteQuietly(new File(this.tempPath, context.getBatchImport().getBatchNo() + ".zip"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
logger.error("", ex);
|
logger.error("", ex);
|
||||||
|
|||||||
+78
-74
@@ -19,81 +19,85 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
public class CommonAppExportTaskServiceImpl extends AbstractImagStoreService implements ICommonAppExportTaskService {
|
public class CommonAppExportTaskServiceImpl
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonAppExportTaskServiceImpl.class);
|
extends AbstractImagStoreService
|
||||||
@Autowired
|
implements ICommonAppExportTaskService {
|
||||||
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
|
private static final Logger log = LoggerFactory.getLogger(CommonAppExportTaskServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private ImgStorePersonService imgStorePersonService;
|
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonAppExportExecuteTask commonAppExportExecuteTask;
|
private ImgStorePersonService imgStorePersonService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CommonDownloadDataConfig commonAppRecordDataConfig;
|
private CommonAppExportExecuteTask commonAppExportExecuteTask;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ComponentInnerKafkaConfig componentInnerKafkaConfig;
|
private CommonDownloadDataConfig commonAppRecordDataConfig;
|
||||||
String fileName = "人员信息";
|
@Autowired
|
||||||
String orgFileName = "机构信息";
|
private ComponentInnerKafkaConfig componentInnerKafkaConfig;
|
||||||
String labelFileName = "标签信息";
|
String fileName = "人员信息";
|
||||||
public String add(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) throws ServiceException {
|
String orgFileName = "机构信息";
|
||||||
String name = createFileName(this.fileName);
|
String labelFileName = "标签信息";
|
||||||
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
|
|
||||||
updateCloudwalkContext(cloudwalkCallContext, task);
|
public String add(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) throws ServiceException {
|
||||||
String fileId = this.commonAppDownloadCenterService.createDownload(cloudwalkCallContext, name, task.getBusinessId());
|
String name = this.createFileName(this.fileName);
|
||||||
task.setFileId(fileId);
|
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
|
||||||
task.setFileName(name);
|
this.updateCloudwalkContext(cloudwalkCallContext, task);
|
||||||
this.commonAppExportExecuteTask.execute(task, cloudwalkCallContext);
|
String fileId = this.commonAppDownloadCenterService.createDownload(cloudwalkCallContext, name, task.getBusinessId());
|
||||||
return fileId;
|
task.setFileId(fileId);
|
||||||
}
|
task.setFileName(name);
|
||||||
public String addOrgExport(CloudwalkCallContext context, ExportOrgTaskParam task) throws ServiceException {
|
this.commonAppExportExecuteTask.execute(task, cloudwalkCallContext);
|
||||||
String name = createFileName(this.orgFileName);
|
return fileId;
|
||||||
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
|
}
|
||||||
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
|
|
||||||
taskParam.setBusinessId(task.getBusinessId());
|
public String addOrgExport(CloudwalkCallContext context, ExportOrgTaskParam task) throws ServiceException {
|
||||||
updateCloudwalkContext(context, taskParam);
|
String name = this.createFileName(this.orgFileName);
|
||||||
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
|
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
|
||||||
task.setFileId(fileId);
|
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
|
||||||
task.setFileName(name);
|
taskParam.setBusinessId(task.getBusinessId());
|
||||||
this.commonAppExportExecuteTask.executeOrg(task, context);
|
this.updateCloudwalkContext(context, taskParam);
|
||||||
return fileId;
|
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
|
||||||
}
|
task.setFileId(fileId);
|
||||||
public String addLabelExport(CloudwalkCallContext context, ExportLabelTaskParam task) throws ServiceException {
|
task.setFileName(name);
|
||||||
String name = createFileName(this.labelFileName);
|
this.commonAppExportExecuteTask.executeOrg(task, context);
|
||||||
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
|
return fileId;
|
||||||
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
|
}
|
||||||
taskParam.setBusinessId(task.getBusinessId());
|
|
||||||
updateCloudwalkContext(context, taskParam);
|
public String addLabelExport(CloudwalkCallContext context, ExportLabelTaskParam task) throws ServiceException {
|
||||||
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
|
String name = this.createFileName(this.labelFileName);
|
||||||
task.setFileId(fileId);
|
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
|
||||||
task.setFileName(name);
|
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
|
||||||
this.commonAppExportExecuteTask.executeLabel(task, context);
|
taskParam.setBusinessId(task.getBusinessId());
|
||||||
return fileId;
|
this.updateCloudwalkContext(context, taskParam);
|
||||||
}
|
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
|
||||||
private void updateCloudwalkContext(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) {
|
task.setFileId(fileId);
|
||||||
cloudwalkCallContext.setServiceCode(this.componentInnerKafkaConfig.getServiceCode());
|
task.setFileName(name);
|
||||||
UserContext userContext = new UserContext();
|
this.commonAppExportExecuteTask.executeLabel(task, context);
|
||||||
userContext.setCaller(cloudwalkCallContext.getUser().getCaller());
|
return fileId;
|
||||||
userContext.setCallerName(cloudwalkCallContext.getUser().getCallerName());
|
}
|
||||||
cloudwalkCallContext.setUser(userContext);
|
|
||||||
CompanyContext companyContext = new CompanyContext();
|
private void updateCloudwalkContext(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) {
|
||||||
companyContext.setCompanyId(task.getBusinessId());
|
cloudwalkCallContext.setServiceCode(this.componentInnerKafkaConfig.getServiceCode());
|
||||||
cloudwalkCallContext.setCompany(companyContext);
|
UserContext userContext = new UserContext();
|
||||||
}
|
userContext.setCaller(cloudwalkCallContext.getUser().getCaller());
|
||||||
private String createFileName(String type) {
|
userContext.setCallerName(cloudwalkCallContext.getUser().getCallerName());
|
||||||
StringBuilder nameBuilder = new StringBuilder();
|
cloudwalkCallContext.setUser(userContext);
|
||||||
LocalDateTime now = LocalDateTime.now();
|
CompanyContext companyContext = new CompanyContext();
|
||||||
nameBuilder.append(type);
|
companyContext.setCompanyId(task.getBusinessId());
|
||||||
nameBuilder.append("_");
|
cloudwalkCallContext.setCompany(companyContext);
|
||||||
nameBuilder.append(now.getYear()).append(now.getMonthValue()).append(now.getDayOfMonth());
|
}
|
||||||
nameBuilder.append("_");
|
|
||||||
nameBuilder.append(now.getHour()).append(now.getMinute()).append(now.getSecond());
|
private String createFileName(String type) {
|
||||||
return nameBuilder.toString();
|
StringBuilder nameBuilder = new StringBuilder();
|
||||||
}
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
nameBuilder.append(type);
|
||||||
|
nameBuilder.append("_");
|
||||||
|
nameBuilder.append(now.getYear()).append(now.getMonthValue()).append(now.getDayOfMonth());
|
||||||
|
nameBuilder.append("_");
|
||||||
|
nameBuilder.append(now.getHour()).append(now.getMinute()).append(now.getSecond());
|
||||||
|
return nameBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/service/CommonAppExportTaskServiceImpl.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
+41
-38
@@ -13,44 +13,47 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CommonAppFileManageServiceImpl implements ICommonAppFileManageService {
|
public class CommonAppFileManageServiceImpl
|
||||||
private static final Logger log = LoggerFactory.getLogger(CommonAppFileManageServiceImpl.class);
|
implements ICommonAppFileManageService {
|
||||||
@Autowired
|
private static final Logger log = LoggerFactory.getLogger(CommonAppFileManageServiceImpl.class);
|
||||||
private FilePartManager filePartManager;
|
@Autowired
|
||||||
public FilePartInitResult filePartInit(String fileName) {
|
private FilePartManager filePartManager;
|
||||||
FilePartInitResult result = new FilePartInitResult();
|
|
||||||
PartInitDTO dto = new PartInitDTO();
|
public FilePartInitResult filePartInit(String fileName) {
|
||||||
dto.setFileName(fileName);
|
FilePartInitResult result = new FilePartInitResult();
|
||||||
PartInitResultDTO partInitResultDTO = new PartInitResultDTO();
|
PartInitDTO dto = new PartInitDTO();
|
||||||
try {
|
dto.setFileName(fileName);
|
||||||
partInitResultDTO = this.filePartManager.init(dto);
|
PartInitResultDTO partInitResultDTO = new PartInitResultDTO();
|
||||||
} catch (DavinciServiceException e) {
|
try {
|
||||||
log.error("分片上传文件初始化接口错误 request = {}", fileName);
|
partInitResultDTO = this.filePartManager.init(dto);
|
||||||
}
|
}
|
||||||
BeanUtils.copyProperties(partInitResultDTO, result);
|
catch (DavinciServiceException e) {
|
||||||
return result;
|
log.error("分片上传文件初始化接口错误 request = {}", (Object)fileName);
|
||||||
}
|
}
|
||||||
public FilePartInitResult filePartAppend(FilePartAppendPara para) {
|
BeanUtils.copyProperties((Object)partInitResultDTO, (Object)result);
|
||||||
return null;
|
return result;
|
||||||
}
|
}
|
||||||
public String filePartFinish(FilePartFinishPara para) {
|
|
||||||
PartFinishDTO partFinishDTO = new PartFinishDTO();
|
public FilePartInitResult filePartAppend(FilePartAppendPara para) {
|
||||||
partFinishDTO.setFilePath(para.getFilePath());
|
return null;
|
||||||
partFinishDTO.setFileSize(para.getFileSize());
|
}
|
||||||
partFinishDTO.setReturnType(para.getReturnType());
|
|
||||||
partFinishDTO.setUploadId(para.getUploadId());
|
public String filePartFinish(FilePartFinishPara para) {
|
||||||
try {
|
PartFinishDTO partFinishDTO = new PartFinishDTO();
|
||||||
return this.filePartManager.finish(partFinishDTO);
|
partFinishDTO.setFilePath(para.getFilePath());
|
||||||
} catch (DavinciServiceException e) {
|
partFinishDTO.setFileSize(para.getFileSize());
|
||||||
log.error("分片上传文件完成接口错误{}:{}", e.getClass().getName(), e.getMessage());
|
partFinishDTO.setReturnType(para.getReturnType());
|
||||||
return null;
|
partFinishDTO.setUploadId(para.getUploadId());
|
||||||
}
|
try {
|
||||||
}
|
return this.filePartManager.finish(partFinishDTO);
|
||||||
|
}
|
||||||
|
catch (DavinciServiceException e) {
|
||||||
|
log.error("分片上传文件完成接口错误{}:{}", (Object)((Object)((Object)e)).getClass().getName(), (Object)e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/service/CommonAppFileManageServiceImpl.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
+1
-1
@@ -687,7 +687,7 @@ groupPersonRefParam.setGroupStatus(GroupModelStatusEnum.MODEL_WAIT.getCode());
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.groupPersonRefMapper.updateImageData(groupPersonRefParam, Lists.newArrayList((Object[])new String[] { imgStorePerson.getId() }));
|
this.groupPersonRefMapper.updateImageData(groupPersonRefParam, Lists.newArrayList(imgStorePerson.getId() ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public CloudwalkResult<CloudwalkPageAble<ImageStorePersonResult>> page(QueryImageStorePersonParam queryParam, CloudwalkCallContext context) {
|
public CloudwalkResult<CloudwalkPageAble<ImageStorePersonResult>> page(QueryImageStorePersonParam queryParam, CloudwalkCallContext context) {
|
||||||
|
|||||||
+7
-7
@@ -106,9 +106,9 @@ handleGroupPersonSynTask(imageStoreId);
|
|||||||
public void addGroupPersonSynTask(String imageStoreId, String personId, boolean isAdd) {
|
public void addGroupPersonSynTask(String imageStoreId, String personId, boolean isAdd) {
|
||||||
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
||||||
if (isAdd) {
|
if (isAdd) {
|
||||||
groupPersonSynData.setAddPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
|
groupPersonSynData.setAddPersonIds(Lists.newArrayList(personId ));
|
||||||
} else {
|
} else {
|
||||||
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
|
groupPersonSynData.setDelPersonIds(Lists.newArrayList(personId ));
|
||||||
}
|
}
|
||||||
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
||||||
addWaitSynTask(imageStoreId, jsonData);
|
addWaitSynTask(imageStoreId, jsonData);
|
||||||
@@ -138,7 +138,7 @@ Map<String, GroupPersonRef> imageStoreIdsMap = this.cpImageStorePersonManager.ge
|
|||||||
List<String> imageStoreIds = Lists.newArrayList(imageStoreIdsMap.keySet());
|
List<String> imageStoreIds = Lists.newArrayList(imageStoreIdsMap.keySet());
|
||||||
if (Collections3.isNotEmpty(imageStoreIds)) {
|
if (Collections3.isNotEmpty(imageStoreIds)) {
|
||||||
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
||||||
groupPersonSynData.setAddPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
|
groupPersonSynData.setAddPersonIds(Lists.newArrayList(personId ));
|
||||||
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
||||||
for (String imageStoreId : imageStoreIds) {
|
for (String imageStoreId : imageStoreIds) {
|
||||||
addWaitSynTask(imageStoreId, jsonData);
|
addWaitSynTask(imageStoreId, jsonData);
|
||||||
@@ -171,7 +171,7 @@ List<String> imageStoreIdsNeedDelete = Lists.newArrayList(imageStoreIdsBefore);
|
|||||||
this.logger.info("addGroupPersonSynTask - 新增图库待同步任务(更新人员注册照) imageStoreIdsAfter:{};imageStoreIdsNeedDelete: {}", imageStoreIds, imageStoreIdsNeedDelete);
|
this.logger.info("addGroupPersonSynTask - 新增图库待同步任务(更新人员注册照) imageStoreIdsAfter:{};imageStoreIdsNeedDelete: {}", imageStoreIds, imageStoreIdsNeedDelete);
|
||||||
if (Collections3.isNotEmpty(imageStoreIdsNeedDelete)) {
|
if (Collections3.isNotEmpty(imageStoreIdsNeedDelete)) {
|
||||||
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
||||||
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
|
groupPersonSynData.setDelPersonIds(Lists.newArrayList(personId ));
|
||||||
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
||||||
for (String imageStoreId : imageStoreIdsNeedDelete) {
|
for (String imageStoreId : imageStoreIdsNeedDelete) {
|
||||||
addWaitSynTask(imageStoreId, jsonData);
|
addWaitSynTask(imageStoreId, jsonData);
|
||||||
@@ -408,11 +408,11 @@ List<SyncPersonDTO> syncPersonList = Lists.newArrayList();
|
|||||||
if (StringUtils.isNotBlank(synData.getPersonId())) {
|
if (StringUtils.isNotBlank(synData.getPersonId())) {
|
||||||
this.logger.info("CpImageStorePersonSynManager handleImageStoreIncrementSyn 单人员更新注册照:{},{}", synData
|
this.logger.info("CpImageStorePersonSynManager handleImageStoreIncrementSyn 单人员更新注册照:{},{}", synData
|
||||||
.getPersonId(), synData.getOldImageId());
|
.getPersonId(), synData.getOldImageId());
|
||||||
Map<String, GroupPersonRef> associatedPersonResultsAfterUpdate = this.cpImageStorePersonManager.getGroupPersonRefByPersons(waitSyncImageStore.getId(), Lists.newArrayList((Object[])new String[] { synData.getPersonId() }));
|
Map<String, GroupPersonRef> associatedPersonResultsAfterUpdate = this.cpImageStorePersonManager.getGroupPersonRefByPersons(waitSyncImageStore.getId(), Lists.newArrayList(synData.getPersonId() ));
|
||||||
Map<String, GroupPersonRef> associatedPersonResultsBeforeUpdate = this.cpImageStorePersonManager.getOldAssociatedPersonIds(waitSyncImageStore.getId(), Lists.newArrayList((Object[])new String[] { synData.getPersonId() }));
|
Map<String, GroupPersonRef> associatedPersonResultsBeforeUpdate = this.cpImageStorePersonManager.getOldAssociatedPersonIds(waitSyncImageStore.getId(), Lists.newArrayList(synData.getPersonId() ));
|
||||||
GroupPersonRef refAfterUpdate = associatedPersonResultsAfterUpdate.get(synData.getPersonId());
|
GroupPersonRef refAfterUpdate = associatedPersonResultsAfterUpdate.get(synData.getPersonId());
|
||||||
if (refAfterUpdate != null) {
|
if (refAfterUpdate != null) {
|
||||||
List<ImgStorePerson> associatedPersonExpiryDateAfterUpdate = this.imgStorePersonMapper.selectExpiryDateByIds(Lists.newArrayList((Object[])new String[] { synData.getPersonId() }));
|
List<ImgStorePerson> associatedPersonExpiryDateAfterUpdate = this.imgStorePersonMapper.selectExpiryDateByIds(Lists.newArrayList(synData.getPersonId() ));
|
||||||
if (CollectionUtil.isNotEmpty(associatedPersonExpiryDateAfterUpdate)) {
|
if (CollectionUtil.isNotEmpty(associatedPersonExpiryDateAfterUpdate)) {
|
||||||
ImgStorePerson personExpiryDate = associatedPersonExpiryDateAfterUpdate.get(0);
|
ImgStorePerson personExpiryDate = associatedPersonExpiryDateAfterUpdate.get(0);
|
||||||
if (personExpiryDate.getExpiryBeginDate() != null || personExpiryDate.getExpiryEndDate() != null) {
|
if (personExpiryDate.getExpiryBeginDate() != null || personExpiryDate.getExpiryEndDate() != null) {
|
||||||
|
|||||||
+1
-1
@@ -228,7 +228,7 @@ this.groupPersonRefMapper.logicDeleteExpireNullByParam(deleteParam);
|
|||||||
}
|
}
|
||||||
for (String deleteImageStoreId : imageStoreIdsNeedDelete) {
|
for (String deleteImageStoreId : imageStoreIdsNeedDelete) {
|
||||||
handleImageStoreImageChange(deleteImageStoreId,
|
handleImageStoreImageChange(deleteImageStoreId,
|
||||||
Sets.newHashSet((Object[])new String[] { imgStorePerson.getImageId() }), false);
|
Sets.newHashSet(imgStorePerson.getImageId() ), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Async("handleImageTaskExecutor")
|
@Async("handleImageTaskExecutor")
|
||||||
|
|||||||
+569
-481
File diff suppressed because it is too large
Load Diff
-783
@@ -1,783 +0,0 @@
|
|||||||
package cn.cloudwalk.service.organization.service;
|
|
||||||
// 业务服务
|
|
||||||
import cn.cloudwalk.client.account.account.param.GeneralQueryBusinessParam;
|
|
||||||
import cn.cloudwalk.client.account.account.result.AcBusinessDTO;
|
|
||||||
import cn.cloudwalk.client.account.account.service.AcBusinessService;
|
|
||||||
import cn.cloudwalk.client.aggregate.application.param.ApplicationImageStoreQueryParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.application.result.ApplicationImageStoreQueryResult;
|
|
||||||
import cn.cloudwalk.client.aggregate.application.service.ApplicationImageStoreService;
|
|
||||||
import cn.cloudwalk.client.aggregate.common.enums.DelStatusEnum;
|
|
||||||
import cn.cloudwalk.client.aggregate.common.enums.SyncStatusEnum;
|
|
||||||
import cn.cloudwalk.client.aggregate.device.param.DeviceImageStoreQueryParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.device.result.DeviceImageStoreQueryResult;
|
|
||||||
import cn.cloudwalk.client.aggregate.device.service.AggDeviceImageStoreService;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.param.AgImageStoreAddParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.param.AgImageStoreEditParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.param.AgImageStoreKeyParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.param.AgImageStoreQueryParam;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.result.AgImageStoreResult;
|
|
||||||
import cn.cloudwalk.client.aggregate.group.service.AgImageStoreService;
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.param.CoreDeviceQueryParam;
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.result.AtomicDeviceGetResult;
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.service.AtomicDeviceService;
|
|
||||||
import cn.cloudwalk.client.organization.common.enums.CpImageStoreMatchPatternEnum;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.AddImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.AssociatedParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.BaseImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.DelImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.DetailImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.EditImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.QueryImageStoreParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.AssociatedResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.DeviceInfoResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.ImageStoreDetailResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.ImageStoreResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.ImgStorePersonResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.LabelResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.OrganizationResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.PageImageStoreResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.service.CpImageStoreService;
|
|
||||||
import cn.cloudwalk.client.resource.application.param.ApplicationBasicParam;
|
|
||||||
import cn.cloudwalk.client.resource.application.param.ApplicationQueryParam;
|
|
||||||
import cn.cloudwalk.client.resource.application.result.ApplicationResult;
|
|
||||||
import cn.cloudwalk.client.resource.application.service.ApplicationService;
|
|
||||||
import cn.cloudwalk.client.resource.common.en.CommonStatusEnum;
|
|
||||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
|
||||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
|
||||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
|
||||||
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
|
|
||||||
import cn.cloudwalk.cloud.page.CloudwalkPageInfo;
|
|
||||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
|
||||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
|
||||||
import cn.cloudwalk.cloud.utils.CloudwalkDateUtils;
|
|
||||||
import cn.cloudwalk.data.organization.dto.DelGroupPersonDTO;
|
|
||||||
import cn.cloudwalk.data.organization.dto.GetsImageStoreAssociatedDTO;
|
|
||||||
import cn.cloudwalk.data.organization.dto.ImageStoreCountDTO;
|
|
||||||
import cn.cloudwalk.data.organization.dto.ImgStorePersonQueryDto;
|
|
||||||
import cn.cloudwalk.data.organization.dto.OrganizationImageStoreQueryDTO;
|
|
||||||
import cn.cloudwalk.data.organization.dto.QueryGroupPersonDTO;
|
|
||||||
import cn.cloudwalk.data.organization.entity.GroupPersonRef;
|
|
||||||
import cn.cloudwalk.data.organization.entity.ImgStorePerson;
|
|
||||||
import cn.cloudwalk.data.organization.entity.IsImageStoreAssociated;
|
|
||||||
import cn.cloudwalk.data.organization.entity.OrganizationImageStore;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.GroupPersonRefMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.ImgStoreLabelMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.ImgStoreOrganizationMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.ImgStorePersonMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.IsImageStoreAssociatedMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.OrganizationImageStoreMapper;
|
|
||||||
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
|
|
||||||
import cn.cloudwalk.service.organization.common.JsonUtils;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springside.modules.utils.Collections3;
|
|
||||||
@Service
|
|
||||||
public class CpImageStoreServiceImpl
|
|
||||||
extends AbstractImagStoreService
|
|
||||||
implements CpImageStoreService
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private IsImageStoreAssociatedMapper isImageStoreAssociatedMapper;
|
|
||||||
@Autowired
|
|
||||||
private ImgStoreLabelMapper imgStoreLabelMapper;
|
|
||||||
@Autowired
|
|
||||||
private ImgStoreOrganizationMapper imgStoreOrganizationMapper;
|
|
||||||
@Autowired
|
|
||||||
private ImgStorePersonMapper personMapper;
|
|
||||||
@Autowired
|
|
||||||
private GroupPersonRefMapper groupPersonRefMapper;
|
|
||||||
@Autowired
|
|
||||||
private OrganizationImageStoreMapper organizationImageStoreMapper;
|
|
||||||
@Autowired
|
|
||||||
private AcBusinessService acBusinessService;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationService applicationService;
|
|
||||||
@Autowired
|
|
||||||
private AgImageStoreService agImageStoreService;
|
|
||||||
@Autowired
|
|
||||||
private ApplicationImageStoreService applicationImageStoreService;
|
|
||||||
@Autowired
|
|
||||||
private AggDeviceImageStoreService deviceImageStoreService;
|
|
||||||
@Autowired
|
|
||||||
private CpImageStorePersonSynManager cpImageStorePersonSynManager;
|
|
||||||
@Resource
|
|
||||||
private CpImageStorePersonManager cpImageStorePersonManager;
|
|
||||||
@Resource
|
|
||||||
private AtomicDeviceService atomicDeviceService;
|
|
||||||
@Resource
|
|
||||||
private ApplicationImageStoreService appImageStoreService;
|
|
||||||
@Value("${cloudwalk.imagestore.person.searchSize:2}")
|
|
||||||
private int searchSize;
|
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<String> add(AddImageStoreParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String imageStoreId = CloudwalkDateUtils.getUUID();
|
|
||||||
AgImageStoreAddParam addParam = new AgImageStoreAddParam();
|
|
||||||
addParam.setId(imageStoreId);
|
|
||||||
addParam.setName(param.getName());
|
|
||||||
addParam.setType(param.getType());
|
|
||||||
addParam.setBusinessId(param.getBusinessId());
|
|
||||||
addParam.setSourceApplicationId(param.getSourceApplicationId());
|
|
||||||
if (StringUtils.isBlank(param.getBusinessId()))
|
|
||||||
{
|
|
||||||
addParam.setBusinessId(context.getCompany().getCompanyId());
|
|
||||||
}
|
|
||||||
List<IsImageStoreAssociated> imageStoreAssociatedList = addBaseImageStore((BaseImageStoreParam)param, context, imageStoreId, addParam.getBusinessId());
|
|
||||||
if (imageStoreAssociatedList.size() > 0) {
|
|
||||||
this.isImageStoreAssociatedMapper.batchInsert(imageStoreAssociatedList);
|
|
||||||
}
|
|
||||||
CloudwalkResult<String> addResult = this.agImageStoreService.add(addParam, context);
|
|
||||||
if (!addResult.isSuccess()) {
|
|
||||||
throw new ServiceException(addResult.getCode(), addResult.getMessage());
|
|
||||||
}
|
|
||||||
this.cpImageStorePersonSynManager.addGroupPersonSynTask(Lists.newArrayList(imageStoreId ), "isAll");
|
|
||||||
return CloudwalkResult.success(imageStoreId);
|
|
||||||
}
|
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<Boolean> edit(EditImageStoreParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
checkExistAndStatus(param.getImageStoreId());
|
|
||||||
AgImageStoreEditParam editParam = new AgImageStoreEditParam();
|
|
||||||
editParam.setId(param.getImageStoreId());
|
|
||||||
editParam.setName(param.getName());
|
|
||||||
String businessId = param.getBusinessId();
|
|
||||||
if (StringUtils.isBlank(businessId))
|
|
||||||
{
|
|
||||||
businessId = context.getCompany().getCompanyId();
|
|
||||||
}
|
|
||||||
List<IsImageStoreAssociated> imageStoreAssociatedList = addBaseImageStore((BaseImageStoreParam)param, context, param.getImageStoreId(), businessId);
|
|
||||||
if (checkAssociatedIsChange(param.getImageStoreId(), imageStoreAssociatedList)) {
|
|
||||||
this.isImageStoreAssociatedMapper.deleteAllByImageId(param.getImageStoreId());
|
|
||||||
if (imageStoreAssociatedList.size() > 0) {
|
|
||||||
this.isImageStoreAssociatedMapper.batchInsert(imageStoreAssociatedList);
|
|
||||||
}
|
|
||||||
editParam.setStatus(SyncStatusEnum.SYNC_WAIT.getCode());
|
|
||||||
}
|
|
||||||
CloudwalkResult<Boolean> editResult = this.agImageStoreService.edit(editParam, context);
|
|
||||||
if (!editResult.isSuccess()) {
|
|
||||||
throw new ServiceException(editResult.getCode(), editResult.getMessage());
|
|
||||||
}
|
|
||||||
this.cpImageStorePersonSynManager.addGroupPersonSynTask(Lists.newArrayList(param.getImageStoreId() ), "isAll");
|
|
||||||
return CloudwalkResult.success(Boolean.TRUE);
|
|
||||||
}
|
|
||||||
private boolean checkAssociatedIsChange(String imageStoreId, List<IsImageStoreAssociated> associatedListAfterUpdate) {
|
|
||||||
GetsImageStoreAssociatedDTO queryDTO = new GetsImageStoreAssociatedDTO();
|
|
||||||
queryDTO.setImageStoreId(imageStoreId);
|
|
||||||
List<IsImageStoreAssociated> associatedListBeforeUpdate = this.isImageStoreAssociatedMapper.gets(queryDTO);
|
|
||||||
if (CollectionUtils.isEmpty(associatedListBeforeUpdate) &&
|
|
||||||
CollectionUtils.isEmpty(associatedListAfterUpdate)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (associatedListBeforeUpdate.size() != associatedListAfterUpdate.size()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Set<String> associatedStrBeforeUpdate = new HashSet<>(associatedListBeforeUpdate.size());
|
|
||||||
for (IsImageStoreAssociated associateBefore : associatedListBeforeUpdate) {
|
|
||||||
String action = (associateBefore.getAssociatedAction() != null) ? String.valueOf(associateBefore.getAssociatedAction()) : "";
|
|
||||||
associatedStrBeforeUpdate.add(action + associateBefore.getAssociatedObjectIdType() + associateBefore.getAssociatedObjectId() + associateBefore
|
|
||||||
.getExpiryBeginDate() + associateBefore.getExpiryEndDate() + associateBefore.getValidDateCron());
|
|
||||||
}
|
|
||||||
Set<String> associatedStrAfterUpdate = new HashSet<>(associatedListAfterUpdate.size());
|
|
||||||
for (IsImageStoreAssociated associateBeforeAfter : associatedListAfterUpdate) {
|
|
||||||
String action = (associateBeforeAfter.getAssociatedAction() != null) ? String.valueOf(associateBeforeAfter.getAssociatedAction()) : "";
|
|
||||||
associatedStrAfterUpdate.add(action + associateBeforeAfter.getAssociatedObjectIdType() + associateBeforeAfter.getAssociatedObjectId() + associateBeforeAfter
|
|
||||||
.getExpiryBeginDate() + associateBeforeAfter.getExpiryEndDate() + associateBeforeAfter.getValidDateCron());
|
|
||||||
}
|
|
||||||
associatedStrBeforeUpdate.removeAll(associatedStrAfterUpdate);
|
|
||||||
return !CollectionUtils.isEmpty(associatedStrBeforeUpdate);
|
|
||||||
}
|
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<Boolean> delete(DelImageStoreParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
checkAppRefByImageStoreIdForDelete(param.getId(), context);
|
|
||||||
checkExistAndStatus(param.getId());
|
|
||||||
QueryGroupPersonDTO queryDTO = new QueryGroupPersonDTO();
|
|
||||||
queryDTO.setImageStoreId(param.getId());
|
|
||||||
queryDTO.setIsDel(Short.valueOf(DelStatusEnum.NORAML.getCode().shortValue()));
|
|
||||||
List<GroupPersonRef> groupPersonList = this.groupPersonRefMapper.query(queryDTO);
|
|
||||||
this.isImageStoreAssociatedMapper.deleteAllByImageId(param.getId());
|
|
||||||
DelGroupPersonDTO delGroupPersonDTO = new DelGroupPersonDTO();
|
|
||||||
delGroupPersonDTO.setImageStoreId(param.getId());
|
|
||||||
delGroupPersonDTO.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
|
||||||
delGroupPersonDTO.setLastUpdateUserId(context.getUser().getCaller());
|
|
||||||
this.groupPersonRefMapper.logicDeleteByParam(delGroupPersonDTO);
|
|
||||||
CloudwalkResult<Boolean> delete = this.agImageStoreService.delete((AgImageStoreKeyParam)BeanCopyUtils.copyProperties(param, AgImageStoreKeyParam.class), context);
|
|
||||||
if (!delete.isSuccess()) {
|
|
||||||
throw new ServiceException(delete.getCode(), delete.getMessage());
|
|
||||||
}
|
|
||||||
return CloudwalkResult.success(Boolean.TRUE);
|
|
||||||
}
|
|
||||||
private void checkAppRefByImageStoreIdForDelete(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
ApplicationImageStoreQueryParam queryParam = new ApplicationImageStoreQueryParam();
|
|
||||||
queryParam.setImageStoreId(imageStoreId);
|
|
||||||
CloudwalkResult<List<ApplicationImageStoreQueryResult>> queryResult = this.applicationImageStoreService.query(queryParam, context);
|
|
||||||
if (!queryResult.isSuccess()) {
|
|
||||||
throw new ServiceException(queryResult.getCode(), queryResult.getMessage());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty((Collection)queryResult.getData())) {
|
|
||||||
throw new ServiceException("53013545",
|
|
||||||
getMessage("53013545"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public CloudwalkResult<CloudwalkPageAble<PageImageStoreResult>> page(QueryImageStoreParam queryImageStoreParam, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
boolean isEnd = handleQueryParam(queryImageStoreParam);
|
|
||||||
if (isEnd) {
|
|
||||||
return CloudwalkResult.success(new CloudwalkPageAble(new ArrayList(), new CloudwalkPageInfo(queryImageStoreParam
|
|
||||||
.getCurrentPage(), queryImageStoreParam.getRowsOfPage()), 0L));
|
|
||||||
}
|
|
||||||
AgImageStoreQueryParam queryParam = (AgImageStoreQueryParam)BeanCopyUtils.copyProperties(queryImageStoreParam, AgImageStoreQueryParam.class);
|
|
||||||
if (StringUtils.isBlank(queryParam.getBusinessId()))
|
|
||||||
{
|
|
||||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
|
||||||
}
|
|
||||||
CloudwalkResult<CloudwalkPageAble<AgImageStoreResult>> agPageResult = this.agImageStoreService.page(queryParam);
|
|
||||||
if (!agPageResult.isSuccess()) {
|
|
||||||
return CloudwalkResult.fail(agPageResult.getCode(), agPageResult.getMessage());
|
|
||||||
}
|
|
||||||
if (agPageResult.getData() == null) {
|
|
||||||
return CloudwalkResult.success(new CloudwalkPageAble(new ArrayList(), new CloudwalkPageInfo(queryParam
|
|
||||||
.getCurrentPage(), queryParam.getRowsOfPage()), 0L));
|
|
||||||
}
|
|
||||||
List<PageImageStoreResult> resultList = packageCpResult(((CloudwalkPageAble)agPageResult.getData()).getDatas(), queryParam.getBusinessId());
|
|
||||||
return CloudwalkResult.success(new CloudwalkPageAble(resultList, new CloudwalkPageInfo(
|
|
||||||
(int)((CloudwalkPageAble)agPageResult.getData()).getCurrentPage(), (int)((CloudwalkPageAble)agPageResult.getData()).getPageSize()), ((CloudwalkPageAble)agPageResult
|
|
||||||
.getData()).getTotalRows()));
|
|
||||||
}
|
|
||||||
public CloudwalkResult<List<ImageStoreResult>> list(QueryImageStoreParam queryImageStoreParam, CloudwalkCallContext cloudwalkContext) throws ServiceException {
|
|
||||||
List<ImageStoreResult> resultList = new ArrayList<>();
|
|
||||||
boolean isEnd = handleQueryParam(queryImageStoreParam);
|
|
||||||
if (isEnd) {
|
|
||||||
return CloudwalkResult.success(resultList);
|
|
||||||
}
|
|
||||||
AgImageStoreQueryParam queryParam = (AgImageStoreQueryParam)BeanCopyUtils.copyProperties(queryImageStoreParam, AgImageStoreQueryParam.class);
|
|
||||||
if (StringUtils.isBlank(queryParam.getBusinessId()))
|
|
||||||
{
|
|
||||||
queryParam.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
|
||||||
}
|
|
||||||
CloudwalkResult<List<AgImageStoreResult>> agQueryResult = this.agImageStoreService.query(queryParam);
|
|
||||||
if (!agQueryResult.isSuccess()) {
|
|
||||||
return CloudwalkResult.fail(agQueryResult.getCode(), agQueryResult.getMessage());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(queryImageStoreParam.getLabelIds())) {
|
|
||||||
GetsImageStoreAssociatedDTO get = new GetsImageStoreAssociatedDTO();
|
|
||||||
get.setAssociatedObjectIds(queryImageStoreParam.getLabelIds());
|
|
||||||
get.setAssociatedObjectIdType(Integer.valueOf(2));
|
|
||||||
List<IsImageStoreAssociated> associateds = this.isImageStoreAssociatedMapper.gets(get);
|
|
||||||
if (CollectionUtils.isEmpty(associateds)) {
|
|
||||||
return CloudwalkResult.success(resultList);
|
|
||||||
}
|
|
||||||
List<String> imageStoreIds = Collections3.extractToList(associateds, "imageStoreId");
|
|
||||||
List<AgImageStoreResult> collect = (List<AgImageStoreResult>)((List)agQueryResult.getData()).stream().filter(a -> imageStoreIds.contains(a.getId())).collect(
|
|
||||||
Collectors.toList());
|
|
||||||
agQueryResult.setData(collect);
|
|
||||||
}
|
|
||||||
resultList = packageImageStoreResult((Collection<AgImageStoreResult>)agQueryResult.getData(), queryParam.getBusinessId());
|
|
||||||
return CloudwalkResult.success(resultList);
|
|
||||||
}
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<ImageStoreDetailResult> detail(DetailImageStoreParam param, CloudwalkCallContext context) {
|
|
||||||
AgImageStoreQueryParam queryParam = new AgImageStoreQueryParam();
|
|
||||||
queryParam.setId(param.getId());
|
|
||||||
CloudwalkResult<List<AgImageStoreResult>> queryResult = this.agImageStoreService.query(queryParam);
|
|
||||||
if (!queryResult.isSuccess()) {
|
|
||||||
return CloudwalkResult.fail(queryResult.getCode(), queryResult.getMessage());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty((Collection)queryResult.getData())) {
|
|
||||||
return CloudwalkResult.fail("53013502",
|
|
||||||
getMessage("53013502"));
|
|
||||||
}
|
|
||||||
AgImageStoreResult agImageStoreResult = ((List<AgImageStoreResult>)queryResult.getData()).get(0);
|
|
||||||
ImageStoreDetailResult result = (ImageStoreDetailResult)BeanCopyUtils.copyProperties(agImageStoreResult, ImageStoreDetailResult.class);
|
|
||||||
result.setPersonNum(getPersonNum(agImageStoreResult.getId()));
|
|
||||||
try {
|
|
||||||
result.setBusinessName(getBusinessName(result.getBusinessId()));
|
|
||||||
} catch (ServiceException e) {
|
|
||||||
this.logger.error("查询企业名称错误e:{}", e.getMessage());
|
|
||||||
return CloudwalkResult.fail(e.getCode(), e.getMessage());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
result.setSourceApplicationName(getSourceApplicationName(result.getSourceApplicationId()));
|
|
||||||
} catch (ServiceException e) {
|
|
||||||
this.logger.error("查询来源应用名称错误e:{}", e.getMessage());
|
|
||||||
return CloudwalkResult.fail(e.getCode(), e.getMessage());
|
|
||||||
}
|
|
||||||
getAssociated(result);
|
|
||||||
DeviceImageStoreQueryParam deviceParam = new DeviceImageStoreQueryParam();
|
|
||||||
deviceParam.setImageStoreId(param.getId());
|
|
||||||
CloudwalkResult<List<DeviceImageStoreQueryResult>> deviceResult = this.deviceImageStoreService.query(deviceParam, context);
|
|
||||||
if (deviceResult.isSuccess()) {
|
|
||||||
result.setDevices(getDeviceList((List<DeviceImageStoreQueryResult>)deviceResult.getData(), context));
|
|
||||||
} else {
|
|
||||||
this.logger.error("图库详情关联设备名称获取失败,result:[{}]", JSONObject.toJSONString(deviceResult));
|
|
||||||
}
|
|
||||||
ApplicationImageStoreQueryParam appParam = new ApplicationImageStoreQueryParam();
|
|
||||||
appParam.setImageStoreId(param.getId());
|
|
||||||
CloudwalkResult<List<ApplicationImageStoreQueryResult>> appResult = this.applicationImageStoreService.query(appParam, context);
|
|
||||||
if (appResult.isSuccess()) {
|
|
||||||
result.setApplicationNames(Collections3.extractToList((Collection)appResult.getData(), "applicationName"));
|
|
||||||
} else {
|
|
||||||
this.logger.error("图库详情关联应用名称获取失败,result:[{}]", JSONObject.toJSONString(appResult));
|
|
||||||
}
|
|
||||||
return CloudwalkResult.success(result);
|
|
||||||
}
|
|
||||||
private List<DeviceInfoResult> getDeviceList(List<DeviceImageStoreQueryResult> resultList, CloudwalkCallContext context) {
|
|
||||||
List<DeviceInfoResult> list = Lists.newArrayListWithCapacity(resultList.size());
|
|
||||||
try {
|
|
||||||
List<String> deviceIds = (List<String>)resultList.stream().map(DeviceImageStoreQueryResult::getDeviceId).collect(Collectors.toList());
|
|
||||||
CoreDeviceQueryParam param = new CoreDeviceQueryParam();
|
|
||||||
param.setIds(deviceIds);
|
|
||||||
param.setBusinessId(context.getCompany().getCompanyId());
|
|
||||||
CloudwalkResult<List<AtomicDeviceGetResult>> deviceResult = this.atomicDeviceService.list(param, context);
|
|
||||||
Map<String, String> deviceMap = new HashMap<>();
|
|
||||||
if (deviceResult.isSuccess()) {
|
|
||||||
deviceMap = (Map<String, String>)((List)deviceResult.getData()).stream().collect(Collectors.toMap(device -> device.getId(), device -> device.getDeviceCode()));
|
|
||||||
}
|
|
||||||
for (DeviceImageStoreQueryResult result : resultList) {
|
|
||||||
DeviceInfoResult dr = new DeviceInfoResult();
|
|
||||||
dr.setDeviceId(result.getDeviceId());
|
|
||||||
dr.setDeviceCode(deviceMap.get(result.getDeviceId()));
|
|
||||||
dr.setDeviceName(result.getDeviceName());
|
|
||||||
dr.setIdentifyType(result.getIdentifyType());
|
|
||||||
list.add(dr);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.logger.error("exception:{}", e.getMessage());
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
private IsImageStoreAssociated getAssociated(String objectId, long time, String userId, String imageStoreId, Integer action, Integer objectType) {
|
|
||||||
IsImageStoreAssociated associated = new IsImageStoreAssociated();
|
|
||||||
associated.setId(getPrimaryId());
|
|
||||||
associated.setAssociatedAction(action);
|
|
||||||
associated.setAssociatedObjectId(objectId);
|
|
||||||
associated.setAssociatedObjectIdType(objectType);
|
|
||||||
associated.setCreateTime(Long.valueOf(time));
|
|
||||||
associated.setCreateUserId(userId);
|
|
||||||
associated.setImageStoreId(imageStoreId);
|
|
||||||
associated.setLastUpdateTime(Long.valueOf(time));
|
|
||||||
associated.setLastUpdateUserId(userId);
|
|
||||||
return associated;
|
|
||||||
}
|
|
||||||
private IsImageStoreAssociated getAssociated(AssociatedParam associatedParam, long time, String userId, String imageStoreId, Integer action, Integer objectType) {
|
|
||||||
IsImageStoreAssociated associated = getAssociated(associatedParam.getObjectId(), time, userId, imageStoreId, action, objectType);
|
|
||||||
associated.setExpiryBeginDate(associatedParam.getExpiryBeginDate());
|
|
||||||
associated.setExpiryEndDate(associatedParam.getExpiryEndDate());
|
|
||||||
associated.setValidDateCron(null);
|
|
||||||
if (!CollectionUtils.isEmpty(associatedParam.getValidDateCron())) {
|
|
||||||
associated.setValidDateCron(JSON.toJSONString(associatedParam.getValidDateCron()));
|
|
||||||
}
|
|
||||||
return associated;
|
|
||||||
}
|
|
||||||
private List<IsImageStoreAssociated> addBaseImageStore(BaseImageStoreParam param, CloudwalkCallContext context, String imageStoreId, String businessId) throws ServiceException {
|
|
||||||
List<String> includePersonIds;
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
if (CollectionUtils.isEmpty(param.getIncludePersons())) {
|
|
||||||
includePersonIds = new ArrayList<>();
|
|
||||||
} else {
|
|
||||||
includePersonIds = (List<String>)param.getIncludePersons().stream().map(AssociatedParam::getObjectId).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(param.getIncludeOrganizations()) &&
|
|
||||||
CollectionUtils.isEmpty(param.getIncludeLabels()) &&
|
|
||||||
CollectionUtils.isEmpty(includePersonIds)) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<IsImageStoreAssociated> imageStoreAssociatedList = new ArrayList<>();
|
|
||||||
if (CpImageStoreMatchPatternEnum.getByCode(param.getMatchPattern()) != null) {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(param.getMatchPattern(), time, context.getUser().getCaller(), imageStoreId, (Integer)null,
|
|
||||||
Integer.valueOf(4)));
|
|
||||||
} else {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(CpImageStoreMatchPatternEnum.MERGE.getCode(), time, context.getUser().getCaller(), imageStoreId, (Integer)null,
|
|
||||||
Integer.valueOf(4)));
|
|
||||||
}
|
|
||||||
AssociatedParam imageStoreAssociatedParam = new AssociatedParam();
|
|
||||||
imageStoreAssociatedParam.setObjectId(imageStoreId);
|
|
||||||
imageStoreAssociatedParam.setExpiryBeginDate(param.getExpiryBeginDate());
|
|
||||||
imageStoreAssociatedParam.setExpiryEndDate(param.getExpiryEndDate());
|
|
||||||
imageStoreAssociatedParam.setValidDateCron(param.getValidDateCron());
|
|
||||||
imageStoreAssociatedList.add(getAssociated(imageStoreAssociatedParam, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(0), Integer.valueOf(5)));
|
|
||||||
if (!CollectionUtils.isEmpty(param.getIncludeOrganizations())) {
|
|
||||||
if (this.imgStoreOrganizationMapper.getOrgByIds(param.getIncludeOrganizations(), businessId).size() != param
|
|
||||||
.getIncludeOrganizations().size()) {
|
|
||||||
throw new ServiceException("53013513", getMessage("53013513"));
|
|
||||||
}
|
|
||||||
for (String objectId : param.getIncludeOrganizations()) {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(objectId, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(0), Integer.valueOf(1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(param.getIncludeLabels())) {
|
|
||||||
if (this.imgStoreLabelMapper.getLabelByIds(param.getIncludeLabels(), businessId).size() != param
|
|
||||||
.getIncludeLabels().size()) {
|
|
||||||
throw new ServiceException("53013514", getMessage("53013514"));
|
|
||||||
}
|
|
||||||
for (String objectId : param.getIncludeLabels()) {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(objectId, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(0), Integer.valueOf(2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(includePersonIds)) {
|
|
||||||
ImgStorePersonQueryDto dto = new ImgStorePersonQueryDto();
|
|
||||||
dto.setIds(includePersonIds);
|
|
||||||
dto.setBusinessId(businessId);
|
|
||||||
dto.setIsDel(DelStatusEnum.NORAML.getCode());
|
|
||||||
if (this.personMapper.gets(dto).size() != includePersonIds.size()) {
|
|
||||||
throw new ServiceException("53013515", getMessage("53013515"));
|
|
||||||
}
|
|
||||||
for (AssociatedParam associatedParam : param.getIncludePersons()) {
|
|
||||||
if (!param.getNullDateIsLongTerm().booleanValue() && (null == associatedParam
|
|
||||||
.getExpiryBeginDate() || null == associatedParam.getExpiryEndDate())) {
|
|
||||||
associatedParam.setExpiryBeginDate(imageStoreAssociatedParam.getExpiryBeginDate());
|
|
||||||
associatedParam.setExpiryEndDate(imageStoreAssociatedParam.getExpiryEndDate());
|
|
||||||
associatedParam.setValidDateCron(imageStoreAssociatedParam.getValidDateCron());
|
|
||||||
}
|
|
||||||
imageStoreAssociatedList.add(getAssociated(associatedParam, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(0), Integer.valueOf(3)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(param.getExcludeLabels())) {
|
|
||||||
if (this.imgStoreLabelMapper.getLabelByIds(param.getExcludeLabels(), businessId).size() != param
|
|
||||||
.getExcludeLabels().size()) {
|
|
||||||
throw new ServiceException("53013516", getMessage("53013516"));
|
|
||||||
}
|
|
||||||
for (String objectId : param.getExcludeLabels()) {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(objectId, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(1), Integer.valueOf(2)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(param.getExcludePersons())) {
|
|
||||||
ImgStorePersonQueryDto dto = new ImgStorePersonQueryDto();
|
|
||||||
dto.setIds(param.getExcludePersons());
|
|
||||||
dto.setBusinessId(businessId);
|
|
||||||
dto.setIsDel(DelStatusEnum.NORAML.getCode());
|
|
||||||
if (this.personMapper.gets(dto).size() != param.getExcludePersons().size()) {
|
|
||||||
throw new ServiceException("53013517", getMessage("53013517"));
|
|
||||||
}
|
|
||||||
for (String objectId : param.getExcludePersons()) {
|
|
||||||
imageStoreAssociatedList.add(getAssociated(objectId, time, context.getUser().getCaller(), imageStoreId,
|
|
||||||
Integer.valueOf(1), Integer.valueOf(3)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return imageStoreAssociatedList;
|
|
||||||
}
|
|
||||||
private String getBusinessName(String businessId) throws ServiceException {
|
|
||||||
GeneralQueryBusinessParam generalQueryBusinessParam = new GeneralQueryBusinessParam();
|
|
||||||
generalQueryBusinessParam.setId(businessId);
|
|
||||||
CloudwalkResult<List<AcBusinessDTO>> cloudwalkResult = this.acBusinessService.generalQuery(generalQueryBusinessParam);
|
|
||||||
if (cloudwalkResult == null) {
|
|
||||||
throw new ServiceException("53013535",
|
|
||||||
getMessage("53013535"));
|
|
||||||
}
|
|
||||||
if (!cloudwalkResult.isSuccess()) {
|
|
||||||
throw new ServiceException(cloudwalkResult.getCode(), cloudwalkResult.getMessage());
|
|
||||||
}
|
|
||||||
if (cloudwalkResult.getData() != null && ((List)cloudwalkResult.getData()).size() > 0) {
|
|
||||||
return ((AcBusinessDTO)((List<AcBusinessDTO>)cloudwalkResult.getData()).get(0)).getName();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private String getSourceApplicationName(String sourceApplicationId) throws ServiceException {
|
|
||||||
if (StringUtils.isEmpty(sourceApplicationId)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ApplicationBasicParam applicationBasicParam = new ApplicationBasicParam();
|
|
||||||
applicationBasicParam.setIds(Arrays.asList(new String[] { sourceApplicationId }));
|
|
||||||
CloudwalkResult<List<ApplicationResult>> cloudwalkResult = this.applicationService.gets(applicationBasicParam);
|
|
||||||
if (cloudwalkResult == null) {
|
|
||||||
throw new ServiceException("53013547",
|
|
||||||
getMessage("53013547"));
|
|
||||||
}
|
|
||||||
if (!cloudwalkResult.isSuccess()) {
|
|
||||||
throw new ServiceException(cloudwalkResult.getCode(), cloudwalkResult.getMessage());
|
|
||||||
}
|
|
||||||
if (cloudwalkResult.getData() != null && ((List)cloudwalkResult.getData()).size() > 0) {
|
|
||||||
return ((ApplicationResult)((List<ApplicationResult>)cloudwalkResult.getData()).get(0)).getName();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
private void checkExistAndStatus(String iamgeStoreId) throws ServiceException {
|
|
||||||
AgImageStoreQueryParam queryParam = new AgImageStoreQueryParam();
|
|
||||||
queryParam.setId(iamgeStoreId);
|
|
||||||
CloudwalkResult<List<AgImageStoreResult>> query = this.agImageStoreService.query(queryParam);
|
|
||||||
if (!query.isSuccess()) {
|
|
||||||
throw new ServiceException(query.getCode(), query.getMessage());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty((Collection)query.getData())) {
|
|
||||||
throw new ServiceException("53013502",
|
|
||||||
getMessage("53013502"));
|
|
||||||
}
|
|
||||||
if (SyncStatusEnum.SYNC_ING.getCode().equals(((AgImageStoreResult)((List<AgImageStoreResult>)query.getData()).get(0)).getStatus())) {
|
|
||||||
throw new ServiceException("53013512",
|
|
||||||
getMessage("53013512"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private Map<String, String> getBusinessNameMap() throws ServiceException {
|
|
||||||
CloudwalkResult<List<AcBusinessDTO>> listCloudwalkResult = this.acBusinessService.generalQuery(new GeneralQueryBusinessParam());
|
|
||||||
if (!listCloudwalkResult.isSuccess()) {
|
|
||||||
throw new ServiceException(listCloudwalkResult.getCode(), listCloudwalkResult.getMessage());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty((Collection)listCloudwalkResult.getData())) {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
return Collections3.extractToMap((Collection)listCloudwalkResult.getData(), "id", "name");
|
|
||||||
}
|
|
||||||
private Map<String, String> getSourceApplicationNameMap(String businessId) throws ServiceException {
|
|
||||||
ApplicationQueryParam param = new ApplicationQueryParam();
|
|
||||||
param.setBusinessId(businessId);
|
|
||||||
param.setStatus(CommonStatusEnum.ENABLE.getCode());
|
|
||||||
CloudwalkResult<List<ApplicationResult>> listCloudwalkResult = this.applicationService.query(param);
|
|
||||||
if (!listCloudwalkResult.isSuccess()) {
|
|
||||||
throw new ServiceException(listCloudwalkResult.getCode(), listCloudwalkResult.getMessage());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty((Collection)listCloudwalkResult.getData())) {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
return Collections3.extractToMap((Collection)listCloudwalkResult.getData(), "id", "name");
|
|
||||||
}
|
|
||||||
private void getAssociated(ImageStoreDetailResult result) {
|
|
||||||
GetsImageStoreAssociatedDTO get = new GetsImageStoreAssociatedDTO();
|
|
||||||
get.setImageStoreId(result.getId());
|
|
||||||
List<IsImageStoreAssociated> associateds = this.isImageStoreAssociatedMapper.gets(get);
|
|
||||||
String matchPattern = null;
|
|
||||||
List<String> includeLabelIds = new ArrayList<>();
|
|
||||||
List<String> includeOrganizationIds = new ArrayList<>();
|
|
||||||
List<String> includePersonIds = new ArrayList<>();
|
|
||||||
Map<String, AssociatedResult> includePersonMap = new HashMap<>();
|
|
||||||
List<String> excludeLabelIds = new ArrayList<>();
|
|
||||||
List<String> excludePersonIds = new ArrayList<>();
|
|
||||||
String businessId = result.getBusinessId();
|
|
||||||
for (IsImageStoreAssociated associated : associateds) {
|
|
||||||
if (4 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
matchPattern = associated.getAssociatedObjectId(); continue;
|
|
||||||
}
|
|
||||||
if (0 == associated.getAssociatedAction().intValue()) {
|
|
||||||
if (1 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
includeOrganizationIds.add(associated.getAssociatedObjectId()); continue;
|
|
||||||
} if (2 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
includeLabelIds.add(associated.getAssociatedObjectId()); continue;
|
|
||||||
} if (3 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
includePersonIds.add(associated.getAssociatedObjectId());
|
|
||||||
AssociatedResult associatedResult = new AssociatedResult();
|
|
||||||
BeanCopyUtils.copyProperties(associated, associatedResult);
|
|
||||||
associatedResult.setObjectId(associated.getAssociatedObjectId());
|
|
||||||
includePersonMap.put(associated.getAssociatedObjectId(), associatedResult); continue;
|
|
||||||
} if (5 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
result.setExpiryBeginDate(associated.getExpiryBeginDate());
|
|
||||||
result.setExpiryEndDate(associated.getExpiryEndDate());
|
|
||||||
result.setValidDateCron(JsonUtils.toStrList(associated.getValidDateCron()));
|
|
||||||
} continue;
|
|
||||||
} if (1 == associated.getAssociatedAction().intValue()) {
|
|
||||||
if (2 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
excludeLabelIds.add(associated.getAssociatedObjectId()); continue;
|
|
||||||
} if (3 == associated.getAssociatedObjectIdType().intValue()) {
|
|
||||||
excludePersonIds.add(associated.getAssociatedObjectId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.setMatchPattern(matchPattern);
|
|
||||||
if (!CollectionUtils.isEmpty(includeLabelIds)) {
|
|
||||||
result.setIncludeLabels(BeanCopyUtils.copy(this.imgStoreLabelMapper.getLabelByIds(includeLabelIds, businessId), LabelResult.class));
|
|
||||||
} else {
|
|
||||||
result.setIncludeLabels(new ArrayList());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(includeOrganizationIds)) {
|
|
||||||
result.setIncludeOrganizations(BeanCopyUtils.copy(this.imgStoreOrganizationMapper.getOrgByIds(includeOrganizationIds, businessId), OrganizationResult.class));
|
|
||||||
} else {
|
|
||||||
result.setIncludeOrganizations(new ArrayList());
|
|
||||||
}
|
|
||||||
ImgStorePersonQueryDto getDTO = new ImgStorePersonQueryDto();
|
|
||||||
if (!CollectionUtils.isEmpty(includePersonIds)) {
|
|
||||||
getDTO.setIds(includePersonIds);
|
|
||||||
getDTO.setIsDel(DelStatusEnum.NORAML.getCode());
|
|
||||||
List<ImgStorePerson> personList = this.personMapper.gets(getDTO);
|
|
||||||
List<ImgStorePersonResult> includePersons = new ArrayList<>();
|
|
||||||
personList.forEach(imgStorePerson -> {
|
|
||||||
ImgStorePersonResult imgStorePersonResult = new ImgStorePersonResult();
|
|
||||||
BeanCopyUtils.copyProperties(imgStorePerson, imgStorePersonResult);
|
|
||||||
AssociatedResult associatedResult = (AssociatedResult)includePersonMap.get(imgStorePerson.getId());
|
|
||||||
BeanCopyUtils.copyProperties(associatedResult, imgStorePersonResult);
|
|
||||||
imgStorePersonResult.setValidDateCron(JsonUtils.toStrList(associatedResult.getValidDateCron()));
|
|
||||||
includePersons.add(imgStorePersonResult);
|
|
||||||
});
|
|
||||||
result.setIncludePersons(includePersons);
|
|
||||||
} else {
|
|
||||||
result.setIncludePersons(new ArrayList());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(excludeLabelIds)) {
|
|
||||||
result.setExcludeLabels(BeanCopyUtils.copy(this.imgStoreLabelMapper.getLabelByIds(excludeLabelIds, businessId), LabelResult.class));
|
|
||||||
} else {
|
|
||||||
result.setExcludeLabels(new ArrayList());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(excludePersonIds)) {
|
|
||||||
getDTO.setIds(excludePersonIds);
|
|
||||||
getDTO.setIsDel(DelStatusEnum.NORAML.getCode());
|
|
||||||
result.setExcludePersons(BeanCopyUtils.copy(this.personMapper.gets(getDTO), ImgStorePersonResult.class));
|
|
||||||
} else {
|
|
||||||
result.setExcludePersons(new ArrayList());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private boolean handleQueryParam(QueryImageStoreParam queryParam) {
|
|
||||||
if (StringUtils.isNotBlank(queryParam.getOrgId()) ||
|
|
||||||
!CollectionUtils.isEmpty(queryParam.getOrgIds())) {
|
|
||||||
List<OrganizationImageStore> orgImageStoreList = this.organizationImageStoreMapper.query((OrganizationImageStoreQueryDTO)BeanCopyUtils.copyProperties(queryParam, OrganizationImageStoreQueryDTO.class));
|
|
||||||
GetsImageStoreAssociatedDTO orgParam = new GetsImageStoreAssociatedDTO();
|
|
||||||
orgParam.setAssociatedObjectIdType(Integer.valueOf(1));
|
|
||||||
List<String> orgIds = new ArrayList<>(500);
|
|
||||||
if (StringUtils.isNotBlank(queryParam.getOrgId())) {
|
|
||||||
orgIds.add(queryParam.getOrgId());
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(queryParam.getOrgIds())) {
|
|
||||||
orgIds.addAll(queryParam.getOrgIds());
|
|
||||||
}
|
|
||||||
orgParam.setAssociatedObjectIds(orgIds);
|
|
||||||
List<IsImageStoreAssociated> orgResultList = this.isImageStoreAssociatedMapper.gets(orgParam);
|
|
||||||
if (CollectionUtils.isEmpty(orgImageStoreList) && CollectionUtils.isEmpty(orgResultList)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
List<String> imageStoreIds = Collections3.extractToList(orgImageStoreList, "imageStoreId");
|
|
||||||
imageStoreIds.addAll(Collections3.extractToList(orgResultList, "imageStoreId"));
|
|
||||||
if (StringUtils.isNotBlank(queryParam.getId())) {
|
|
||||||
if (!imageStoreIds.contains(queryParam.getId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (!CollectionUtils.isEmpty(queryParam.getIds())) {
|
|
||||||
imageStoreIds.retainAll(queryParam.getIds());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(imageStoreIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
queryParam.setIds(imageStoreIds);
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(queryParam.getPersonIds())) {
|
|
||||||
QueryGroupPersonDTO queryGroupPersonDTO = (QueryGroupPersonDTO)BeanCopyUtils.copyProperties(queryParam, QueryGroupPersonDTO.class);
|
|
||||||
queryGroupPersonDTO.setIsDel(DelStatusEnum.NORAML.getCode());
|
|
||||||
List<GroupPersonRef> queryResult = this.groupPersonRefMapper.query(queryGroupPersonDTO);
|
|
||||||
if (CollectionUtils.isEmpty(queryResult)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
List<String> imageStoreIds = Collections3.extractToList(queryResult, "imageStoreId");
|
|
||||||
if (StringUtils.isNotBlank(queryParam.getId())) {
|
|
||||||
if (!imageStoreIds.contains(queryParam.getId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (!CollectionUtils.isEmpty(queryParam.getIds())) {
|
|
||||||
imageStoreIds.retainAll(queryParam.getIds());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(imageStoreIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
queryParam.setIds(imageStoreIds);
|
|
||||||
}
|
|
||||||
if (!CollectionUtils.isEmpty(queryParam.getLabelIds())) {
|
|
||||||
GetsImageStoreAssociatedDTO labelParam = new GetsImageStoreAssociatedDTO();
|
|
||||||
labelParam.setAssociatedObjectIdType(Integer.valueOf(2));
|
|
||||||
labelParam.setAssociatedObjectIds(queryParam.getLabelIds());
|
|
||||||
List<IsImageStoreAssociated> labelResultList = this.isImageStoreAssociatedMapper.gets(labelParam);
|
|
||||||
if (CollectionUtils.isEmpty(labelResultList)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
List<String> imageStoreIds = Collections3.extractToList(labelResultList, "imageStoreId");
|
|
||||||
if (StringUtils.isNotBlank(queryParam.getId())) {
|
|
||||||
if (!imageStoreIds.contains(queryParam.getId())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (!CollectionUtils.isEmpty(queryParam.getIds())) {
|
|
||||||
imageStoreIds.retainAll(queryParam.getIds());
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(imageStoreIds)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
queryParam.setIds(imageStoreIds);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
private List<ImageStoreResult> packageImageStoreResult(Collection<AgImageStoreResult> agDatas, String businessId) throws ServiceException {
|
|
||||||
if (CollectionUtils.isEmpty(agDatas)) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<String> imageIds = (List<String>)agDatas.stream().map(AgImageStoreResult::getId).collect(Collectors.toList());
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
List<ImageStoreCountDTO> countByImageStoreIds = Lists.newArrayListWithCapacity(imageIds.size());
|
|
||||||
List<List<String>> partition = Lists.partition(imageIds, this.searchSize);
|
|
||||||
partition.stream().forEach(p -> {
|
|
||||||
List<ImageStoreCountDTO> list = this.groupPersonRefMapper.getCountByImageStoreIds(p);
|
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
countByImageStoreIds.addAll(list);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
long endTime = System.currentTimeMillis();
|
|
||||||
this.logger.info("图库分页查询耗时:[{}],searchSize:[{}]", Long.valueOf(endTime - startTime), Integer.valueOf(this.searchSize));
|
|
||||||
Map<String, Integer> countMap = (Map<String, Integer>)countByImageStoreIds.stream().filter(imageStoreCountDTO -> (null != imageStoreCountDTO)).collect(Collectors.toMap(ImageStoreCountDTO::getId, ImageStoreCountDTO::getCount, (k1, k2) -> k1));
|
|
||||||
Map<String, String> businessNameMap = getBusinessNameMap();
|
|
||||||
Map<String, String> sourceApplicationNameMap = getSourceApplicationNameMap(businessId);
|
|
||||||
List<ImageStoreResult> resultList = new ArrayList<>(agDatas.size());
|
|
||||||
for (AgImageStoreResult agData : agDatas) {
|
|
||||||
ImageStoreResult temp = (ImageStoreResult)BeanCopyUtils.copyProperties(agData, ImageStoreResult.class);
|
|
||||||
temp.setBusinessName(businessNameMap.get(temp.getBusinessId()));
|
|
||||||
temp.setSourceApplicationName(sourceApplicationNameMap.get(temp.getSourceApplicationId()));
|
|
||||||
temp.setPersonNum(countMap.containsKey(agData.getId()) ? countMap.get(agData.getId()) : Integer.valueOf(0));
|
|
||||||
getAssociated((ImageStoreDetailResult)temp);
|
|
||||||
resultList.add(temp);
|
|
||||||
}
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
private List<PageImageStoreResult> packageCpResult(Collection<AgImageStoreResult> agDatas, String businessId) throws ServiceException {
|
|
||||||
if (CollectionUtils.isEmpty(agDatas)) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
List<String> imageIds = (List<String>)agDatas.stream().map(AgImageStoreResult::getId).collect(Collectors.toList());
|
|
||||||
long startTime = System.currentTimeMillis();
|
|
||||||
List<ImageStoreCountDTO> countByImageStoreIds = Lists.newArrayListWithCapacity(imageIds.size());
|
|
||||||
List<List<String>> partition = Lists.partition(imageIds, this.searchSize);
|
|
||||||
partition.stream().forEach(p -> {
|
|
||||||
List<ImageStoreCountDTO> list = this.groupPersonRefMapper.getCountByImageStoreIds(p);
|
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
|
||||||
countByImageStoreIds.addAll(list);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
long endTime = System.currentTimeMillis();
|
|
||||||
this.logger.info("图库分页查询耗时:[{}],searchSize:[{}]", Long.valueOf(endTime - startTime), Integer.valueOf(this.searchSize));
|
|
||||||
Map<String, Integer> countMap = (Map<String, Integer>)countByImageStoreIds.stream().filter(imageStoreCountDTO -> (null != imageStoreCountDTO)).collect(Collectors.toMap(ImageStoreCountDTO::getId, ImageStoreCountDTO::getCount, (k1, k2) -> k1));
|
|
||||||
Map<String, String> businessNameMap = getBusinessNameMap();
|
|
||||||
Map<String, String> sourceApplicationNameMap = getSourceApplicationNameMap(businessId);
|
|
||||||
List<PageImageStoreResult> resultList = new ArrayList<>(agDatas.size());
|
|
||||||
for (AgImageStoreResult agData : agDatas) {
|
|
||||||
PageImageStoreResult temp = (PageImageStoreResult)BeanCopyUtils.copyProperties(agData, PageImageStoreResult.class);
|
|
||||||
temp.setBusinessName(businessNameMap.get(temp.getBusinessId()));
|
|
||||||
temp.setSourceApplicationName(sourceApplicationNameMap.get(temp.getSourceApplicationId()));
|
|
||||||
temp.setPersonNum(countMap.containsKey(agData.getId()) ? countMap.get(agData.getId()) : Integer.valueOf(0));
|
|
||||||
resultList.add(temp);
|
|
||||||
}
|
|
||||||
return resultList;
|
|
||||||
}
|
|
||||||
private Integer getPersonNum(String id) {
|
|
||||||
List<ImageStoreCountDTO> countByImageStoreIds = this.groupPersonRefMapper.getCountByImageStoreIds(Lists.newArrayList(id ));
|
|
||||||
if (CollectionUtils.isEmpty(countByImageStoreIds) || countByImageStoreIds.get(0) == null) {
|
|
||||||
return Integer.valueOf(0);
|
|
||||||
}
|
|
||||||
return ((ImageStoreCountDTO)countByImageStoreIds.get(0)).getCount();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/service/CpImageStoreServiceImpl.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
+195
-194
@@ -3,7 +3,6 @@ package cn.cloudwalk.service.organization.service;
|
|||||||
import cn.cloudwalk.client.aggregate.device.param.DeviceImageStoreQueryParam;
|
import cn.cloudwalk.client.aggregate.device.param.DeviceImageStoreQueryParam;
|
||||||
import cn.cloudwalk.client.aggregate.device.param.DeviceImageStoreReSyncParam;
|
import cn.cloudwalk.client.aggregate.device.param.DeviceImageStoreReSyncParam;
|
||||||
import cn.cloudwalk.client.aggregate.device.result.DeviceImageStoreQueryResult;
|
import cn.cloudwalk.client.aggregate.device.result.DeviceImageStoreQueryResult;
|
||||||
import cn.cloudwalk.client.aggregate.device.result.DeviceImageStoreReSyncResult;
|
|
||||||
import cn.cloudwalk.client.aggregate.device.service.AggDeviceImageStoreService;
|
import cn.cloudwalk.client.aggregate.device.service.AggDeviceImageStoreService;
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.param.AtomicDeviceCommonParam;
|
import cn.cloudwalk.client.device.mgn.atomic.param.AtomicDeviceCommonParam;
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.result.CoreDeviceDetailResult;
|
import cn.cloudwalk.client.device.mgn.atomic.result.CoreDeviceDetailResult;
|
||||||
@@ -21,10 +20,12 @@ import cn.cloudwalk.data.organization.mapper.DeviceImageStoreMapper;
|
|||||||
import cn.cloudwalk.data.organization.mapper.DevicePersonSyncLogMapper;
|
import cn.cloudwalk.data.organization.mapper.DevicePersonSyncLogMapper;
|
||||||
import cn.cloudwalk.data.organization.mapper.GroupPersonRefMapper;
|
import cn.cloudwalk.data.organization.mapper.GroupPersonRefMapper;
|
||||||
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
|
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
|
||||||
|
import cn.cloudwalk.service.organization.service.CpImageStoreSyncManager;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -35,200 +36,200 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DeviceGroupRefChangeEventHandler
|
public class DeviceGroupRefChangeEventHandler
|
||||||
extends AbstractImagStoreService
|
extends AbstractImagStoreService {
|
||||||
{
|
@Resource
|
||||||
@Resource
|
private AggDeviceImageStoreService aggDeviceImageStoreService;
|
||||||
private AggDeviceImageStoreService aggDeviceImageStoreService;
|
@Resource
|
||||||
@Resource
|
private AtomicDeviceService atomicDeviceService;
|
||||||
private AtomicDeviceService atomicDeviceService;
|
@Resource
|
||||||
@Resource
|
private CpImageStoreSyncManager cpImageStoreSyncManager;
|
||||||
private CpImageStoreSyncManager cpImageStoreSyncManager;
|
@Resource
|
||||||
@Resource
|
private DevicePersonSyncLogMapper devicePersonSyncLogMapper;
|
||||||
private DevicePersonSyncLogMapper devicePersonSyncLogMapper;
|
@Resource
|
||||||
@Resource
|
private DeviceImageStoreMapper deviceImageStoreMapper;
|
||||||
private DeviceImageStoreMapper deviceImageStoreMapper;
|
@Resource
|
||||||
@Resource
|
private GroupPersonRefMapper groupPersonRefMapper;
|
||||||
private GroupPersonRefMapper groupPersonRefMapper;
|
@Resource
|
||||||
@Resource
|
private UUIDSerial uuidSerial;
|
||||||
private UUIDSerial uuidSerial;
|
@Value(value="${person.partition.size:100}")
|
||||||
@Value("${person.partition.size:100}")
|
private Integer personPartitionSize;
|
||||||
private Integer personPartitionSize;
|
|
||||||
@Async("deviceGroupChangeTaskExecutor")
|
@Async(value="deviceGroupChangeTaskExecutor")
|
||||||
public void handler(DeviceGroupRefChangeEvent event) {
|
public void handler(DeviceGroupRefChangeEvent event) {
|
||||||
if (null == event) {
|
if (null == event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (StringUtils.isBlank(event.getDeviceId()) || StringUtils.isBlank(event.getGroupId())) {
|
if (StringUtils.isBlank((CharSequence)event.getDeviceId()) || StringUtils.isBlank((CharSequence)event.getGroupId())) {
|
||||||
this.logger.warn("设备[{}]或者图库[{}]为空", event.getDeviceId(), event.getGroupId());
|
this.logger.warn("设备[{}]或者图库[{}]为空", (Object)event.getDeviceId(), (Object)event.getGroupId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.logger.debug("Kafka消费设备图库变更数据:[{}]", JSON.toJSONString(event));
|
this.logger.debug("Kafka消费设备图库变更数据:[{}]", (Object)JSON.toJSONString((Object)event));
|
||||||
try {
|
try {
|
||||||
AtomicDeviceCommonParam queryDevice = new AtomicDeviceCommonParam();
|
AtomicDeviceCommonParam queryDevice = new AtomicDeviceCommonParam();
|
||||||
queryDevice.setId(event.getDeviceId());
|
queryDevice.setId(event.getDeviceId());
|
||||||
CloudwalkResult<CoreDeviceDetailResult> deviceResult = this.atomicDeviceService.detail(queryDevice, getCloudwalkContext());
|
CloudwalkResult deviceResult = this.atomicDeviceService.detail(queryDevice, this.getCloudwalkContext());
|
||||||
if (!deviceResult.isSuccess() || null == deviceResult.getData()) {
|
if (!deviceResult.isSuccess() || null == deviceResult.getData()) {
|
||||||
this.logger.warn("查询设备[{}]失败", event.getDeviceId());
|
this.logger.warn("查询设备[{}]失败", (Object)event.getDeviceId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CoreDeviceDetailResult device = (CoreDeviceDetailResult)deviceResult.getData();
|
CoreDeviceDetailResult device = (CoreDeviceDetailResult)deviceResult.getData();
|
||||||
if (device.getIdentifyType().shortValue() != 0) {
|
if (device.getIdentifyType() != 0) {
|
||||||
this.logger.warn("设备[{}]非前端识别", device.getId());
|
this.logger.warn("设备[{}]非前端识别", (Object)device.getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveDeviceImageStoreChange(event);
|
this.saveDeviceImageStoreChange(event);
|
||||||
unbindDeviceImageStore(event, device);
|
this.unbindDeviceImageStore(event, device);
|
||||||
bindDeviceImageStore(event);
|
this.bindDeviceImageStore(event);
|
||||||
} catch (Exception e) {
|
}
|
||||||
this.logger.error("执行报错 {}: {}", e.getClass().getName(), e.getMessage());
|
catch (Exception e) {
|
||||||
}
|
this.logger.error("执行报错 {}: {}", (Object)e.getClass().getName(), (Object)e.getMessage());
|
||||||
}
|
}
|
||||||
private int saveDeviceImageStoreChange(DeviceGroupRefChangeEvent event) {
|
}
|
||||||
Long time = Long.valueOf(System.currentTimeMillis());
|
|
||||||
DeviceImageStore query = new DeviceImageStore();
|
private int saveDeviceImageStoreChange(DeviceGroupRefChangeEvent event) {
|
||||||
query.setDeviceId(event.getDeviceId());
|
Long time = System.currentTimeMillis();
|
||||||
query.setImageStoreId(event.getGroupId());
|
DeviceImageStore query = new DeviceImageStore();
|
||||||
query.setType(Integer.valueOf(event.getType().shortValue()));
|
query.setDeviceId(event.getDeviceId());
|
||||||
query.setLastUpdateTime(time);
|
query.setImageStoreId(event.getGroupId());
|
||||||
List<DeviceImageStore> result = this.deviceImageStoreMapper.select(query);
|
query.setType(Integer.valueOf(event.getType().shortValue()));
|
||||||
if (CollectionUtils.isEmpty(result)) {
|
query.setLastUpdateTime(time);
|
||||||
this.logger.debug("根据设备[{}]图库[{}]未查询到变更记录,新增", event.getDeviceId(), event.getGroupId());
|
List result = this.deviceImageStoreMapper.select(query);
|
||||||
query.setId(this.uuidSerial.uuid());
|
if (CollectionUtils.isEmpty((Collection)result)) {
|
||||||
query.setCreateTime(time);
|
this.logger.debug("根据设备[{}]图库[{}]未查询到变更记录,新增", (Object)event.getDeviceId(), (Object)event.getGroupId());
|
||||||
return this.deviceImageStoreMapper.insertSelective(query);
|
query.setId(this.uuidSerial.uuid());
|
||||||
}
|
query.setCreateTime(time);
|
||||||
this.logger.debug("根据设备[{}]图库[{}]查询到变更记录[{}],修改", new Object[] { event.getDeviceId(), event.getGroupId(), ((DeviceImageStore)result.get(0)).getId() });
|
return this.deviceImageStoreMapper.insertSelective(query);
|
||||||
query.setFinishPullTime(null);
|
}
|
||||||
query.setStatus(StatusEnum.UNNOTIFY.getValue());
|
this.logger.debug("根据设备[{}]图库[{}]查询到变更记录[{}],修改", new Object[]{event.getDeviceId(), event.getGroupId(), ((DeviceImageStore)result.get(0)).getId()});
|
||||||
return this.deviceImageStoreMapper.update(query);
|
query.setFinishPullTime(null);
|
||||||
}
|
query.setStatus(StatusEnum.UNNOTIFY.getValue());
|
||||||
private void unbindDeviceImageStore(DeviceGroupRefChangeEvent event, CoreDeviceDetailResult device) {
|
return this.deviceImageStoreMapper.update(query);
|
||||||
if (event.getType().shortValue() != 2) {
|
}
|
||||||
return;
|
|
||||||
}
|
private void unbindDeviceImageStore(DeviceGroupRefChangeEvent event, CoreDeviceDetailResult device) {
|
||||||
this.logger.debug("开始处理设备[{}]图库[{}]解绑", event.getDeviceId(), event.getGroupId());
|
if (event.getType() != 2) {
|
||||||
try {
|
return;
|
||||||
DeviceImageStoreQueryParam storeQueryParam = new DeviceImageStoreQueryParam();
|
}
|
||||||
storeQueryParam.setDeviceId(event.getDeviceId());
|
this.logger.debug("开始处理设备[{}]图库[{}]解绑", (Object)event.getDeviceId(), (Object)event.getGroupId());
|
||||||
CloudwalkResult<List<DeviceImageStoreQueryResult>> imageStoreResult = this.aggDeviceImageStoreService.query(storeQueryParam, getCloudwalkContext());
|
try {
|
||||||
if (imageStoreResult.isSuccess() && !CollectionUtils.isEmpty((Collection)imageStoreResult.getData())) {
|
DeviceImageStoreQueryParam storeQueryParam = new DeviceImageStoreQueryParam();
|
||||||
this.logger.debug("设备[{}]仍绑定其他图库", event.getDeviceId());
|
storeQueryParam.setDeviceId(event.getDeviceId());
|
||||||
String deviceCode = device.getDeviceCode();
|
CloudwalkResult imageStoreResult = this.aggDeviceImageStoreService.query(storeQueryParam, this.getCloudwalkContext());
|
||||||
if (null == device.getSupportMultiPersonGroup() ||
|
if (imageStoreResult.isSuccess() && !CollectionUtils.isEmpty((Collection)((Collection)imageStoreResult.getData()))) {
|
||||||
Objects.equals(Integer.valueOf(device.getSupportMultiPersonGroup().intValue()),
|
this.logger.debug("设备[{}]仍绑定其他图库", (Object)event.getDeviceId());
|
||||||
Integer.valueOf(DeviceAbilityEnum.NOT_SUPPORT_MULTI_PERSON_GROUP.getCode()))) {
|
String deviceCode = device.getDeviceCode();
|
||||||
this.logger.debug("设备[{}]code[{}]不支持多图库,下发50009", event.getDeviceId(), deviceCode);
|
if (null == device.getSupportMultiPersonGroup() || Objects.equals(device.getSupportMultiPersonGroup().intValue(), DeviceAbilityEnum.NOT_SUPPORT_MULTI_PERSON_GROUP.getCode())) {
|
||||||
List<String> imageStoreIds = (List<String>)((List)imageStoreResult.getData()).stream().map(DeviceImageStoreQueryResult::getImageStoreId).collect(
|
this.logger.debug("设备[{}]code[{}]不支持多图库,下发50009", (Object)event.getDeviceId(), (Object)deviceCode);
|
||||||
Collectors.toList());
|
List<String> imageStoreIds = ((List)imageStoreResult.getData()).stream().map(DeviceImageStoreQueryResult::getImageStoreId).collect(Collectors.toList());
|
||||||
updateSyncLog(event, imageStoreIds);
|
this.updateSyncLog(event, imageStoreIds);
|
||||||
Set<String> changeGroupIdSet = Sets.newHashSet();
|
HashSet changeGroupIdSet = Sets.newHashSet();
|
||||||
changeGroupIdSet.add(event.getGroupId());
|
changeGroupIdSet.add(event.getGroupId());
|
||||||
((List)imageStoreResult.getData()).stream().forEach(imageStore -> changeGroupIdSet.add(imageStore.getImageStoreId()));
|
((List)imageStoreResult.getData()).stream().forEach(imageStore -> changeGroupIdSet.add(imageStore.getImageStoreId()));
|
||||||
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
|
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notify50010(event);
|
this.notify50010(event);
|
||||||
} catch (Exception e) {
|
}
|
||||||
this.logger.error("设备[{}]图库[{}]解绑执行异常:{}", new Object[] { event.getDeviceId(), event.getGroupId(), e.getMessage() });
|
catch (Exception e) {
|
||||||
}
|
this.logger.error("设备[{}]图库[{}]解绑执行异常:{}", new Object[]{event.getDeviceId(), event.getGroupId(), e.getMessage()});
|
||||||
}
|
}
|
||||||
private void updateSyncLog(DeviceGroupRefChangeEvent event, List<String> imageStoreIds) {
|
}
|
||||||
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
|
||||||
query.setDeviceId(event.getDeviceId());
|
private void updateSyncLog(DeviceGroupRefChangeEvent event, List<String> imageStoreIds) {
|
||||||
query.setImageStoreId(event.getGroupId());
|
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
||||||
List<DevicePersonSyncLog> dbSyncLogList = this.devicePersonSyncLogMapper.query(query);
|
query.setDeviceId(event.getDeviceId());
|
||||||
Set<String> personIdSet = (Set<String>)dbSyncLogList.stream().map(DevicePersonSyncLog::getPersonId).collect(
|
query.setImageStoreId(event.getGroupId());
|
||||||
Collectors.toSet());
|
List dbSyncLogList = this.devicePersonSyncLogMapper.query(query);
|
||||||
List<List<String>> personIdPartition = Lists.partition(Lists.newArrayList(personIdSet), this.personPartitionSize.intValue());
|
Set personIdSet = dbSyncLogList.stream().map(DevicePersonSyncLog::getPersonId).collect(Collectors.toSet());
|
||||||
for (List<String> personIds : personIdPartition) {
|
List personIdPartition = Lists.partition((List)Lists.newArrayList(personIdSet), (int)this.personPartitionSize);
|
||||||
query.setImageStoreIds(imageStoreIds);
|
for (List personIds : personIdPartition) {
|
||||||
query.setPersonIds(personIds);
|
query.setImageStoreIds(imageStoreIds);
|
||||||
List<String> personIdList = this.devicePersonSyncLogMapper.findPersonIds(query);
|
query.setPersonIds(personIds);
|
||||||
Long currentTime = Long.valueOf(System.currentTimeMillis());
|
List personIdList = this.devicePersonSyncLogMapper.findPersonIds(query);
|
||||||
if (!CollectionUtils.isEmpty(personIdList)) {
|
Long currentTime = System.currentTimeMillis();
|
||||||
this.logger.info("移除在其他图库中的人员:[{}]", personIdList);
|
if (!CollectionUtils.isEmpty((Collection)personIdList)) {
|
||||||
personIdSet.removeAll(personIdList);
|
this.logger.info("移除在其他图库中的人员:[{}]", (Object)personIdList);
|
||||||
query.setPersonIds(personIdList);
|
personIdSet.removeAll(personIdList);
|
||||||
query.setLastUpdateTime(currentTime);
|
query.setPersonIds(personIdList);
|
||||||
this.devicePersonSyncLogMapper.updateLastTimeOfGroupPerson(query);
|
query.setLastUpdateTime(currentTime);
|
||||||
query.setLastUpdateTime(null);
|
this.devicePersonSyncLogMapper.updateLastTimeOfGroupPerson(query);
|
||||||
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
|
query.setLastUpdateTime(null);
|
||||||
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
|
||||||
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
||||||
this.logger.info("设备[{}]图库[{}]更新[{}]条人员存在其他图库中", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
|
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
||||||
}
|
this.logger.info("设备[{}]图库[{}]更新[{}]条人员存在其他图库中", new Object[]{event.getDeviceId(), event.getGroupId(), res});
|
||||||
this.groupPersonRefMapper.updateLastUpdateTimeByPersonIds(event.getGroupId(), personIds, currentTime);
|
}
|
||||||
}
|
this.groupPersonRefMapper.updateLastUpdateTimeByPersonIds(event.getGroupId(), personIds, currentTime);
|
||||||
if (!CollectionUtils.isEmpty(personIdSet)) {
|
}
|
||||||
personIdPartition = Lists.partition(Lists.newArrayList(personIdSet), this.personPartitionSize.intValue());
|
if (!CollectionUtils.isEmpty(personIdSet)) {
|
||||||
query = new DevicePersonSyncLogDTO();
|
personIdPartition = Lists.partition((List)Lists.newArrayList(personIdSet), (int)this.personPartitionSize);
|
||||||
query.setDeviceId(event.getDeviceId());
|
query = new DevicePersonSyncLogDTO();
|
||||||
query.setImageStoreId(event.getGroupId());
|
query.setDeviceId(event.getDeviceId());
|
||||||
for (List<String> personIds : personIdPartition) {
|
query.setImageStoreId(event.getGroupId());
|
||||||
query.setPersonIds(personIds);
|
for (List personIds : personIdPartition) {
|
||||||
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
query.setPersonIds(personIds);
|
||||||
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
|
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||||
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
|
||||||
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
||||||
this.logger.info("设备[{}]图库[{}]更新[{}]条人员不存在其他图库中", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
|
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
||||||
}
|
this.logger.info("设备[{}]图库[{}]更新[{}]条人员不存在其他图库中", new Object[]{event.getDeviceId(), event.getGroupId(), res});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void notify50010(DeviceGroupRefChangeEvent event) {
|
}
|
||||||
try {
|
|
||||||
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
private void notify50010(DeviceGroupRefChangeEvent event) {
|
||||||
query.setDeviceId(event.getDeviceId());
|
try {
|
||||||
query.setImageStoreId(event.getGroupId());
|
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
||||||
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
query.setDeviceId(event.getDeviceId());
|
||||||
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
|
query.setImageStoreId(event.getGroupId());
|
||||||
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||||
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
|
||||||
this.logger.debug("设备[{}]图库[{}]解绑,逻辑删除[{}]条同步记录", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
|
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
||||||
this.logger.debug("设备[{}]图库[{}]下发50010", event.getDeviceId(), event.getGroupId());
|
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
||||||
DeviceImageStoreReSyncParam deviceImageStoreReSyncParam = new DeviceImageStoreReSyncParam();
|
this.logger.debug("设备[{}]图库[{}]解绑,逻辑删除[{}]条同步记录", new Object[]{event.getDeviceId(), event.getGroupId(), res});
|
||||||
deviceImageStoreReSyncParam.setDeviceId(event.getDeviceId());
|
this.logger.debug("设备[{}]图库[{}]下发50010", (Object)event.getDeviceId(), (Object)event.getGroupId());
|
||||||
deviceImageStoreReSyncParam.setImageStoreId(event.getGroupId());
|
DeviceImageStoreReSyncParam deviceImageStoreReSyncParam = new DeviceImageStoreReSyncParam();
|
||||||
CloudwalkResult<List<DeviceImageStoreReSyncResult>> result = this.aggDeviceImageStoreService.reSync(deviceImageStoreReSyncParam, getCloudwalkContext());
|
deviceImageStoreReSyncParam.setDeviceId(event.getDeviceId());
|
||||||
if (result.isSuccess()) {
|
deviceImageStoreReSyncParam.setImageStoreId(event.getGroupId());
|
||||||
DeviceImageStore notify = new DeviceImageStore();
|
CloudwalkResult result = this.aggDeviceImageStoreService.reSync(deviceImageStoreReSyncParam, this.getCloudwalkContext());
|
||||||
notify.setDeviceId(event.getDeviceId());
|
if (result.isSuccess()) {
|
||||||
notify.setImageStoreId(event.getGroupId());
|
DeviceImageStore notify = new DeviceImageStore();
|
||||||
List<DeviceImageStore> deviceImageStoreList = this.deviceImageStoreMapper.select(notify);
|
notify.setDeviceId(event.getDeviceId());
|
||||||
if (!CollectionUtils.isEmpty(deviceImageStoreList)) {
|
notify.setImageStoreId(event.getGroupId());
|
||||||
notify = deviceImageStoreList.get(0);
|
List deviceImageStoreList = this.deviceImageStoreMapper.select(notify);
|
||||||
notify.setStatus(StatusEnum.NOTIFY.getValue());
|
if (!CollectionUtils.isEmpty((Collection)deviceImageStoreList)) {
|
||||||
notify.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
notify = (DeviceImageStore)deviceImageStoreList.get(0);
|
||||||
this.deviceImageStoreMapper.update(notify);
|
notify.setStatus(StatusEnum.NOTIFY.getValue());
|
||||||
}
|
notify.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||||
}
|
this.deviceImageStoreMapper.update(notify);
|
||||||
} catch (Exception e) {
|
}
|
||||||
this.logger.error("设备[{}]图库[{}]解绑执行异常:{}", new Object[] { event.getDeviceId(), event.getGroupId(), e.getMessage() });
|
}
|
||||||
}
|
}
|
||||||
}
|
catch (Exception e) {
|
||||||
private void bindDeviceImageStore(DeviceGroupRefChangeEvent event) {
|
this.logger.error("设备[{}]图库[{}]解绑执行异常:{}", new Object[]{event.getDeviceId(), event.getGroupId(), e.getMessage()});
|
||||||
if (event.getType().shortValue() != 1) {
|
}
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
this.logger.debug("开始处理设备[{}]图库[{}]绑定", event.getDeviceId(), event.getGroupId());
|
private void bindDeviceImageStore(DeviceGroupRefChangeEvent event) {
|
||||||
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
if (event.getType() != 1) {
|
||||||
query.setDeviceId(event.getDeviceId());
|
return;
|
||||||
query.setImageStoreId(event.getGroupId());
|
}
|
||||||
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
this.logger.debug("开始处理设备[{}]图库[{}]绑定", (Object)event.getDeviceId(), (Object)event.getGroupId());
|
||||||
query.setIsDel(Integer.valueOf(StatusEnum.VALID.getValue().intValue()));
|
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
|
||||||
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
query.setDeviceId(event.getDeviceId());
|
||||||
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
query.setImageStoreId(event.getGroupId());
|
||||||
this.logger.debug("设备[{}]图库[{}]绑定,更新[{}]条同步记录", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
|
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||||
Set<String> changeGroupIdSet = Sets.newHashSet();
|
query.setIsDel(Integer.valueOf(StatusEnum.VALID.getValue()));
|
||||||
changeGroupIdSet.add(event.getGroupId());
|
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
|
||||||
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
|
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
|
||||||
}
|
this.logger.debug("设备[{}]图库[{}]绑定,更新[{}]条同步记录", new Object[]{event.getDeviceId(), event.getGroupId(), res});
|
||||||
|
HashSet changeGroupIdSet = Sets.newHashSet();
|
||||||
|
changeGroupIdSet.add(event.getGroupId());
|
||||||
|
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/service/DeviceGroupRefChangeEventHandler.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
+1
-1
@@ -388,7 +388,7 @@ this.imgStoreLabelMapper.deletePerson(delPersonLabelDTO);
|
|||||||
List<String> imageIdResultList = Lists.newArrayList();
|
List<String> imageIdResultList = Lists.newArrayList();
|
||||||
for (Map.Entry<String, List<String>> entry : delMap.entrySet()) {
|
for (Map.Entry<String, List<String>> entry : delMap.entrySet()) {
|
||||||
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
|
||||||
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { entry.getKey() }));
|
groupPersonSynData.setDelPersonIds(Lists.newArrayList(entry.getKey() ));
|
||||||
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
String jsonData = JsonUtils.toJson(groupPersonSynData);
|
||||||
for (String imageStoreId : entry.getValue()) {
|
for (String imageStoreId : entry.getValue()) {
|
||||||
this.cpImageStorePersonSynManager.addWaitSynTask(imageStoreId, jsonData);
|
this.cpImageStorePersonSynManager.addWaitSynTask(imageStoreId, jsonData);
|
||||||
|
|||||||
+1037
-1033
File diff suppressed because it is too large
Load Diff
+769
-775
File diff suppressed because it is too large
Load Diff
-264
@@ -1,264 +0,0 @@
|
|||||||
package cn.cloudwalk.service.organization.service;
|
|
||||||
// 业务服务
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.param.CoreDeviceQueryParam;
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.result.AtomicDeviceGetResult;
|
|
||||||
import cn.cloudwalk.client.device.mgn.atomic.service.AtomicDeviceService;
|
|
||||||
import cn.cloudwalk.client.organization.common.enums.DefaultPropertyEnum;
|
|
||||||
import cn.cloudwalk.client.organization.common.enums.RegistryTypeEnum;
|
|
||||||
import cn.cloudwalk.client.organization.common.enums.StatusEnum;
|
|
||||||
import cn.cloudwalk.client.organization.common.enums.UniquePropertyEnum;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.AddPersonRegistryParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.param.QueryPersonRegistryParam;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.DeviceResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.PersonPropertiesResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.result.PersonRegistryResult;
|
|
||||||
import cn.cloudwalk.client.organization.service.store.service.IPersonRegistryHandler;
|
|
||||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
|
||||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
|
||||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
|
||||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
|
||||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
|
||||||
import cn.cloudwalk.data.organization.entity.ImgStorePersonProperties;
|
|
||||||
import cn.cloudwalk.data.organization.entity.PersonRegistry;
|
|
||||||
import cn.cloudwalk.data.organization.entity.PersonRegistryDevice;
|
|
||||||
import cn.cloudwalk.data.organization.entity.PersonRegistryProperties;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.ImgStorePersonPropertiesMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.PersonRegistryDeviceMapper;
|
|
||||||
import cn.cloudwalk.data.organization.mapper.PersonRegistryPropertiesMapper;
|
|
||||||
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
import org.springside.modules.utils.Collections3;
|
|
||||||
@Service("SelfRegistryHandler")
|
|
||||||
public class SelfRegistryHandler
|
|
||||||
extends AbstractImagStoreService
|
|
||||||
implements IPersonRegistryHandler
|
|
||||||
{
|
|
||||||
@Resource
|
|
||||||
private CommonPersonRegistryService commonPersonRegistryService;
|
|
||||||
@Resource
|
|
||||||
private AtomicDeviceService atomicDeviceService;
|
|
||||||
@Resource
|
|
||||||
private ImgStorePersonPropertiesMapper imgStorePersonPropertiesMapper;
|
|
||||||
@Resource
|
|
||||||
private PersonRegistryPropertiesMapper personRegistryPropertiesMapper;
|
|
||||||
@Resource
|
|
||||||
private PersonRegistryDeviceMapper personRegistryDeviceMapper;
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}, value = "transactionManager")
|
|
||||||
public CloudwalkResult<Boolean> save(AddPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String businessId = context.getCompany().getCompanyId();
|
|
||||||
param.setBusinessId(businessId);
|
|
||||||
CloudwalkResult<Boolean> result = validateParams(param, context);
|
|
||||||
if (!result.isSuccess()) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
PersonRegistry personRegistry = this.commonPersonRegistryService.getByBusinessAndType(businessId, RegistryTypeEnum.SELF_REGISTRY.getValue());
|
|
||||||
if (null != personRegistry) {
|
|
||||||
param.setId(personRegistry.getId());
|
|
||||||
update(param, context);
|
|
||||||
} else {
|
|
||||||
insert(param, context);
|
|
||||||
}
|
|
||||||
return CloudwalkResult.success(Boolean.valueOf(true));
|
|
||||||
}
|
|
||||||
private CloudwalkResult<Boolean> validateParams(AddPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
if (null == param.getCodeStatus()) {
|
|
||||||
return CloudwalkResult.fail("53014502",
|
|
||||||
getMessage("53014502"));
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(param.getPropertyIdList())) {
|
|
||||||
return CloudwalkResult.fail("53014503",
|
|
||||||
getMessage("53014503"));
|
|
||||||
}
|
|
||||||
List<ImgStorePersonProperties> dbPersonProList = this.imgStorePersonPropertiesMapper.selectByIds(param.getBusinessId(), param.getPropertyIdList());
|
|
||||||
if (CollectionUtils.isEmpty(dbPersonProList) || dbPersonProList.size() != param.getPropertyIdList().size()) {
|
|
||||||
this.logger.warn("注册属性不属于人员基本属性,注册属性Id列表:[{}]", JSONObject.toJSONString(param.getPropertyIdList()));
|
|
||||||
return CloudwalkResult.fail("53014508",
|
|
||||||
getMessage("53014508"));
|
|
||||||
}
|
|
||||||
for (DefaultPropertyEnum default_property : DefaultPropertyEnum.values()) {
|
|
||||||
Optional<ImgStorePersonProperties> requiredOptional = dbPersonProList.stream().filter(property -> default_property.getValue().equals(property.getCode())).findFirst();
|
|
||||||
if (!requiredOptional.isPresent()) {
|
|
||||||
this.logger.warn("{}未勾选,注册属性Id列表:[{}]", default_property.getDescription(),
|
|
||||||
JSONObject.toJSONString(param.getPropertyIdList()));
|
|
||||||
return CloudwalkResult.fail("53014511", "注册属性" + default_property
|
|
||||||
.getDescription() + "必须勾选");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Objects.equals(param.getDeviceStatus(), StatusEnum.CLOSE.getValue()) ||
|
|
||||||
Objects.equals(param.getCodeStatus(), StatusEnum.CLOSE.getValue())) {
|
|
||||||
ImgStorePersonProperties queryPersonPro = new ImgStorePersonProperties();
|
|
||||||
queryPersonPro.setBusinessId(param.getBusinessId());
|
|
||||||
queryPersonPro.setStatus(StatusEnum.VALID.getValue());
|
|
||||||
queryPersonPro.setHasRequired(StatusEnum.REQUIRED.getValue());
|
|
||||||
List<ImgStorePersonProperties> requiredPersonProList = this.imgStorePersonPropertiesMapper.select(queryPersonPro);
|
|
||||||
if (!CollectionUtils.isEmpty(requiredPersonProList)) {
|
|
||||||
List<String> requiredPersonProIdList = Collections3.extractToList(requiredPersonProList, "id");
|
|
||||||
dbPersonProList = (List<ImgStorePersonProperties>)dbPersonProList.stream().filter(pro -> requiredPersonProIdList.contains(pro.getId())).collect(Collectors.toList());
|
|
||||||
if (dbPersonProList.size() != requiredPersonProList.size()) {
|
|
||||||
this.logger.warn("设备注册审核和扫码注册审核未同时打开,有未勾选的必填属性,注册属性Id列表:[{}]",
|
|
||||||
JSONObject.toJSONString(param.getPropertyIdList()));
|
|
||||||
return CloudwalkResult.fail("53014511",
|
|
||||||
getMessage("53014511"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.commonPersonRegistryService.validateOrg(param);
|
|
||||||
this.commonPersonRegistryService.validateLabel(param);
|
|
||||||
this.commonPersonRegistryService.validateDevice(param, context);
|
|
||||||
return CloudwalkResult.success(Boolean.valueOf(true));
|
|
||||||
}
|
|
||||||
private CloudwalkResult<Boolean> insert(AddPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String id = getPrimaryId();
|
|
||||||
this.commonPersonRegistryService.insertPersonRegistry(id, param, context);
|
|
||||||
this.commonPersonRegistryService.batchInsertPersonRegistryProperty(id, param);
|
|
||||||
this.commonPersonRegistryService.batchInsertPersonRegistryDevice(id, param, context, Boolean.valueOf(false));
|
|
||||||
return CloudwalkResult.success(Boolean.valueOf(true));
|
|
||||||
}
|
|
||||||
private CloudwalkResult<Boolean> update(AddPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
this.commonPersonRegistryService.updatePersonRegistry(param, context);
|
|
||||||
this.commonPersonRegistryService.batchUpdatePersonRegistryProperty(param);
|
|
||||||
this.commonPersonRegistryService.batchUpdatePersonRegistryDevice(param, context, Boolean.valueOf(false));
|
|
||||||
return CloudwalkResult.success(Boolean.valueOf(true));
|
|
||||||
}
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<PersonRegistryResult> detail(QueryPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String businessId = param.getBusinessId();
|
|
||||||
if (StringUtils.isBlank(businessId)) {
|
|
||||||
businessId = context.getCompany().getCompanyId();
|
|
||||||
}
|
|
||||||
PersonRegistryResult result = new PersonRegistryResult();
|
|
||||||
ImgStorePersonProperties queryPersonPro = new ImgStorePersonProperties();
|
|
||||||
queryPersonPro.setBusinessId(businessId);
|
|
||||||
queryPersonPro.setStatus(StatusEnum.VALID.getValue());
|
|
||||||
List<ImgStorePersonProperties> personPropertyList = this.imgStorePersonPropertiesMapper.select(queryPersonPro);
|
|
||||||
if (CollectionUtils.isEmpty(personPropertyList)) {
|
|
||||||
this.logger.warn("不存在人员属性");
|
|
||||||
return CloudwalkResult.fail("53014524",
|
|
||||||
getMessage("53014524"));
|
|
||||||
}
|
|
||||||
List<PersonPropertiesResult> proResultList = BeanCopyUtils.copy(personPropertyList, PersonPropertiesResult.class);
|
|
||||||
proResultList.forEach(propertyResult -> {
|
|
||||||
if (DefaultPropertyEnum.hasProperty(propertyResult.getCode())) {
|
|
||||||
propertyResult.setHasChecked(StatusEnum.CHECKED.getValue());
|
|
||||||
propertyResult.setHasDisabled(StatusEnum.DISABLED.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
proResultList = (List<PersonPropertiesResult>)proResultList.stream().sorted(Comparator.comparing(PersonPropertiesResult::getOrderNum)).collect(Collectors.toList());
|
|
||||||
result.setPropertyList(proResultList);
|
|
||||||
PersonRegistry dbPersonRegistry = this.commonPersonRegistryService.getByBusinessAndType(businessId, RegistryTypeEnum.SELF_REGISTRY.getValue());
|
|
||||||
if (null != dbPersonRegistry) {
|
|
||||||
result = (PersonRegistryResult)BeanCopyUtils.copyProperties(dbPersonRegistry, PersonRegistryResult.class);
|
|
||||||
result.setPropertyList(proResultList);
|
|
||||||
this.commonPersonRegistryService.setOrg(dbPersonRegistry, result);
|
|
||||||
this.commonPersonRegistryService.setLabel(dbPersonRegistry, result);
|
|
||||||
List<PersonRegistryDevice> dbPersonRegistryDeviceList = this.personRegistryDeviceMapper.select(dbPersonRegistry.getId(), null);
|
|
||||||
if (!CollectionUtils.isEmpty(dbPersonRegistryDeviceList)) {
|
|
||||||
CoreDeviceQueryParam coreDeviceQueryParam = new CoreDeviceQueryParam();
|
|
||||||
coreDeviceQueryParam.setBusinessId(businessId);
|
|
||||||
coreDeviceQueryParam
|
|
||||||
.setDeviceCodes(Collections3.extractToList(dbPersonRegistryDeviceList, "deviceCode"));
|
|
||||||
CloudwalkResult<List<AtomicDeviceGetResult>> deviceGetResult = this.atomicDeviceService.list(coreDeviceQueryParam, context);
|
|
||||||
if (!CollectionUtils.isEmpty((Collection)deviceGetResult.getData())) {
|
|
||||||
List<DeviceResult> deviceResultList = Lists.newArrayListWithCapacity(((List)deviceGetResult.getData()).size());
|
|
||||||
((List)deviceGetResult.getData()).forEach(device -> {
|
|
||||||
DeviceResult deviceResult = new DeviceResult();
|
|
||||||
deviceResult.setDeviceCode(device.getDeviceCode());
|
|
||||||
deviceResult.setDeviceName(device.getDeviceName());
|
|
||||||
deviceResultList.add(deviceResult);
|
|
||||||
});
|
|
||||||
result.setDeviceList(deviceResultList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
List<PersonRegistryProperties> dbPersonRegistryProList = this.personRegistryPropertiesMapper.select(dbPersonRegistry.getId(), null);
|
|
||||||
List<String> personPropertyIdList = Collections3.extractToList(dbPersonRegistryProList, "personPropertyId");
|
|
||||||
result.getPropertyList().forEach(propertyResult -> {
|
|
||||||
if (personPropertyIdList.contains(propertyResult.getId())) {
|
|
||||||
propertyResult.setHasChecked(StatusEnum.CHECKED.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return CloudwalkResult.success(result);
|
|
||||||
}
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<List<PersonPropertiesResult>> getRegistryPropertyList(QueryPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String businessId = param.getBusinessId();
|
|
||||||
if (StringUtils.isBlank(businessId)) {
|
|
||||||
businessId = context.getCompany().getCompanyId();
|
|
||||||
}
|
|
||||||
PersonRegistry dbPersonRegistry = (PersonRegistry)this.commonPersonRegistryService.getResultByBusinessAndType(businessId, RegistryTypeEnum.SELF_REGISTRY.getValue()).getData();
|
|
||||||
this.commonPersonRegistryService.validateDevice(param, dbPersonRegistry);
|
|
||||||
return CloudwalkResult.success(getPersonPropertyList(dbPersonRegistry, true));
|
|
||||||
}
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<List<PersonPropertiesResult>> getAuditPropertyList(QueryPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String businessId = param.getBusinessId();
|
|
||||||
if (StringUtils.isBlank(businessId)) {
|
|
||||||
businessId = context.getCompany().getCompanyId();
|
|
||||||
}
|
|
||||||
PersonRegistry dbPersonRegistry = (PersonRegistry)this.commonPersonRegistryService.getResultByBusinessAndType(businessId, RegistryTypeEnum.SELF_REGISTRY.getValue()).getData();
|
|
||||||
return CloudwalkResult.success(getPersonPropertyList(dbPersonRegistry, false));
|
|
||||||
}
|
|
||||||
private List<PersonPropertiesResult> getPersonPropertyList(PersonRegistry personRegistry, boolean isChecked) {
|
|
||||||
List<PersonRegistryProperties> dbPersonRegistryProList = this.personRegistryPropertiesMapper.select(personRegistry.getId(), null);
|
|
||||||
List<String> personProIdList = Collections3.extractToList(dbPersonRegistryProList, "personPropertyId");
|
|
||||||
ImgStorePersonProperties queryPersonPro = new ImgStorePersonProperties();
|
|
||||||
queryPersonPro.setBusinessId(personRegistry.getBusinessId());
|
|
||||||
queryPersonPro.setStatus(StatusEnum.VALID.getValue());
|
|
||||||
List<ImgStorePersonProperties> dbPersonProList = this.imgStorePersonPropertiesMapper.select(queryPersonPro);
|
|
||||||
List<PersonPropertiesResult> proResultList = BeanCopyUtils.copy(dbPersonProList, PersonPropertiesResult.class);
|
|
||||||
List<PersonPropertiesResult> defaultProList = BeanCopyUtils.copy(dbPersonProList, PersonPropertiesResult.class);
|
|
||||||
proResultList = (List<PersonPropertiesResult>)proResultList.stream().filter(proResult -> (personProIdList.contains(proResult.getId()) == isChecked)).collect(Collectors.toList());
|
|
||||||
defaultProList = (List<PersonPropertiesResult>)defaultProList.stream().filter(proResult -> DefaultPropertyEnum.hasProperty(proResult.getCode())).collect(Collectors.toList());
|
|
||||||
if (isChecked) {
|
|
||||||
proResultList.removeAll(defaultProList);
|
|
||||||
proResultList.addAll(defaultProList);
|
|
||||||
proResultList.forEach(proResult -> {
|
|
||||||
proResult.setHasChecked(StatusEnum.CHECKED.getValue());
|
|
||||||
if (DefaultPropertyEnum.hasProperty(proResult.getCode())) {
|
|
||||||
proResult.setHasDisabled(StatusEnum.DISABLED.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
proResultList.removeAll(defaultProList);
|
|
||||||
}
|
|
||||||
proResultList = (List<PersonPropertiesResult>)proResultList.stream().sorted(Comparator.comparing(PersonPropertiesResult::getOrderNum)).collect(Collectors.toList());
|
|
||||||
return proResultList;
|
|
||||||
}
|
|
||||||
@CloudwalkParamsValidate
|
|
||||||
public CloudwalkResult<PersonPropertiesResult> getUniqueRegistryProperty(QueryPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
String businessId = param.getBusinessId();
|
|
||||||
if (StringUtils.isBlank(businessId)) {
|
|
||||||
businessId = context.getCompany().getCompanyId();
|
|
||||||
}
|
|
||||||
PersonRegistry dbPersonRegistry = (PersonRegistry)this.commonPersonRegistryService.getResultByBusinessAndType(businessId, RegistryTypeEnum.SELF_REGISTRY.getValue()).getData();
|
|
||||||
List<PersonPropertiesResult> propertyList = getPersonPropertyList(dbPersonRegistry, true);
|
|
||||||
AtomicReference<PersonPropertiesResult> result = new AtomicReference<>();
|
|
||||||
propertyList.stream().filter(property -> UniquePropertyEnum.hasProperty(property.getCode()))
|
|
||||||
.findFirst().ifPresent(personPropertiesResult -> result.set(personPropertiesResult));
|
|
||||||
return CloudwalkResult.success(result.get());
|
|
||||||
}
|
|
||||||
public CloudwalkResult<PersonPropertiesResult> getBindProperty(QueryPersonRegistryParam param, CloudwalkCallContext context) throws ServiceException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Location: /media/zebra/9e8fa357-7db6-4d70-88ed-d5de5a059a663/星河湾星中星/部署包/ninca_common_component_organization_01-ninca_common_component_organization/ninca-common-component-organization-V2.9.2_20210730/BOOT-INF/lib/cwos-component-organization-service-v2.9.2_xinghewan.jar!/cn/cloudwalk/service/organization/service/SelfRegistryHandler.class
|
|
||||||
* Java compiler version: 8 (52.0)
|
|
||||||
* JD-Core Version: 1.1.3
|
|
||||||
*/
|
|
||||||
Reference in New Issue
Block a user