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:
反编译工作区
2026-05-06 00:32:57 +08:00
parent 5f22d6f8f7
commit 6376384672
14 changed files with 3141 additions and 4072 deletions
@@ -1,4 +1,5 @@
package cn.cloudwalk.service.organization.export;
// 业务服务
import cn.cloudwalk.client.organization.batch.param.download.FilePartFinishPara;
import cn.cloudwalk.client.organization.batch.param.download.FilePartInitResult;
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.ICommonAppFileManageService;
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.store.result.OrganizationResult;
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
import cn.cloudwalk.cloud.result.CloudwalkResult;
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.MultipartFileUtils;
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 java.io.File;
import java.io.IOException;
@@ -34,437 +42,451 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
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.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.util.Base64Utils;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
@Service
@EnableAsync
public class CommonAppExportExecuteTask extends AbstractImagStoreService {
private static final Logger log = LoggerFactory.getLogger(CommonAppExportExecuteTask.class);
@Autowired
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
@Autowired
private CommonDownloadDataConfig commonDownloadDataConfig;
@Autowired
private ICommonStorageService commonAppStorageService;
@Autowired
private ImgStorePersonService imgStorePersonService;
@Autowired
private OrganizationService organizationService;
@Autowired
private LabelService labelService;
@Autowired
private ImgStorePersonPropertiesService imgStorePersonPropertiesService;
@Autowired
private ICommonAppFileManageService iCommonAppFileManageService;
@Autowired
private FilePartManager filePartManager;
@Autowired
private FileStorageManager fileStorageManager;
@Value("${cloudwalk.common-app.download.shardingSize}")
private Integer shardingSize;
String fileName = "人员信息";
String orgFileName = "机构信息";
String labelFileName = "标签信息";
@Async
public void execute(ExportRecordTaskParam task, CloudwalkCallContext cloudwalkCallContext) {
this.logger.info("开始执行人员信息导出功能");
QueryImgPersonParam queryImgPersonParam = new QueryImgPersonParam();
BeanUtils.copyProperties(task, queryImgPersonParam);
try {
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = getPersonData(queryImgPersonParam, cloudwalkCallContext);
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
Map<String, List<ImgStorePersonGetResult>> dataMap = new HashMap<>();
dataMap.put(this.fileName, recordList.getData());
PersonProListResult personProListResult = (PersonProListResult)this.imgStorePersonPropertiesService.getList(task.getBusinessId()).getData();
List<ImgPersonProGetResult> properties = personProListResult.getProperties();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("门禁设备(在线)");
result1.setCode("onlineDevices");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(17));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("门禁设备(离线)");
result2.setCode("offlineDevices");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(18));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("派梯楼层权限");
result3.setCode("floorNames");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(19));
result3.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
this.commonDownloadDataConfig.setHasContainImage(task.getHasContainImage());
Path zipPath = (new CommonAppExportFileHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出人员任务失败:{}", 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();
BeanUtils.copyProperties(task, queryImgPersonParam);
try {
CloudwalkResult<List<OrganizationResult>> recordList = getOrgData(queryImgPersonParam, context);
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
Map<String, List<OrganizationResult>> dataMap = new HashMap<>();
dataMap.put(this.orgFileName, recordList.getData());
PersonProListResult personProListResult = new PersonProListResult();
List<ImgPersonProGetResult> properties = new ArrayList<>();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("机构名称");
result1.setCode("name");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(1));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("机构id");
result2.setCode("id");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(2));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("机构类型");
result3.setCode("type");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(3));
result3.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
result4.setId("4");
result4.setName("人员数量");
result4.setCode("personCount");
result4.setStatus(Integer.valueOf(0));
result4.setType(Short.valueOf((short)1));
result4.setOrderNum(Integer.valueOf(4));
result4.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
result5.setId("5");
result5.setName("状态:0-已启用");
result5.setCode("isDel");
result5.setStatus(Integer.valueOf(0));
result5.setType(Short.valueOf((short)1));
result5.setOrderNum(Integer.valueOf(5));
result5.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
result6.setId("6");
result6.setName("门禁设备(在线)");
result6.setCode("onlineDevices");
result6.setStatus(Integer.valueOf(0));
result6.setType(Short.valueOf((short)1));
result6.setOrderNum(Integer.valueOf(6));
result6.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
result7.setId("7");
result7.setName("门禁设备(离线)");
result7.setCode("offlineDevices");
result7.setStatus(Integer.valueOf(0));
result7.setType(Short.valueOf((short)1));
result7.setOrderNum(Integer.valueOf(7));
result7.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
result8.setId("8");
result8.setName("派梯楼层权限");
result8.setCode("floorNames");
result8.setStatus(Integer.valueOf(0));
result8.setType(Short.valueOf((short)1));
result8.setOrderNum(Integer.valueOf(8));
result8.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
properties.add(result4);
properties.add(result5);
properties.add(result6);
properties.add(result7);
properties.add(result8);
personProListResult.setProperties(properties);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
Path zipPath = (new CommonAppExportFileByOrgHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出机构任务失败:{}", e);
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
throw new RuntimeException("执行导出机构信息任务异常");
}
}
@Async
public void executeLabel(ExportLabelTaskParam task, CloudwalkCallContext context) {
this.logger.info("开始执行标签信息导出功能");
PageLabelParam pageLabelParam = new PageLabelParam();
BeanUtils.copyProperties(task, pageLabelParam);
try {
CloudwalkResult<List<PageLabelResult>> recordList = getLabelData(pageLabelParam, context);
if (CollectionUtils.isEmpty((Collection)recordList.getData())) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", task.getBusinessId(), task);
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", Integer.valueOf(((List)recordList.getData()).size()));
Map<String, List<PageLabelResult>> dataMap = new HashMap<>();
dataMap.put(this.labelFileName, recordList.getData());
PersonProListResult personProListResult = new PersonProListResult();
List<ImgPersonProGetResult> properties = new ArrayList<>();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("标签名称");
result1.setCode("name");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(1));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("标签id");
result2.setCode("id");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(2));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("标签编号");
result3.setCode("code");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(3));
result3.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
result4.setId("4");
result4.setName("人员数量");
result4.setCode("personCount");
result4.setStatus(Integer.valueOf(0));
result4.setType(Short.valueOf((short)1));
result4.setOrderNum(Integer.valueOf(4));
result4.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
result5.setId("5");
result5.setName("标签类型:0-手动创建,1-应用初始,2-应用创建");
result5.setCode("addType");
result5.setStatus(Integer.valueOf(0));
result5.setType(Short.valueOf((short)1));
result5.setOrderNum(Integer.valueOf(5));
result5.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
result6.setId("6");
result6.setName("门禁设备(在线)");
result6.setCode("onlineDevices");
result6.setStatus(Integer.valueOf(0));
result6.setType(Short.valueOf((short)1));
result6.setOrderNum(Integer.valueOf(6));
result6.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
result7.setId("7");
result7.setName("门禁设备(离线)");
result7.setCode("offlineDevices");
result7.setStatus(Integer.valueOf(0));
result7.setType(Short.valueOf((short)1));
result7.setOrderNum(Integer.valueOf(7));
result7.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
result8.setId("8");
result8.setName("派梯楼层权限");
result8.setCode("floorNames");
result8.setStatus(Integer.valueOf(0));
result8.setType(Short.valueOf((short)1));
result8.setOrderNum(Integer.valueOf(8));
result8.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
properties.add(result4);
properties.add(result5);
properties.add(result6);
properties.add(result7);
properties.add(result8);
personProListResult.setProperties(properties);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows().intValue());
Path zipPath = (new CommonAppExportFileByLabelHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult)).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", task.getFileId());
exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出标签任务失败:{}", e);
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
throw new RuntimeException("执行导出标签信息任务异常");
}
}
private CloudwalkResult<List<ImgStorePersonGetResult>> getPersonData(QueryImgPersonParam queryImgPersonParam, CloudwalkCallContext cloudwalkCallContext) {
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = new CloudwalkResult();
try {
recordList = this.imgStorePersonService.listByPage(queryImgPersonParam, cloudwalkCallContext);
} catch (Exception e) {
this.logger.error("查询记录数据失败");
}
return recordList;
}
private CloudwalkResult<List<OrganizationResult>> getOrgData(QueryOrganizationParam param, CloudwalkCallContext context) {
CloudwalkResult<List<OrganizationResult>> recordList = new CloudwalkResult();
try {
recordList = this.organizationService.listByPage(param, context);
} catch (Exception e) {
this.logger.error("查询机构记录数据失败");
}
return recordList;
}
private CloudwalkResult<List<PageLabelResult>> getLabelData(PageLabelParam param, CloudwalkCallContext cloudwalkCallContext) {
CloudwalkResult<List<PageLabelResult>> recordList = new CloudwalkResult();
try {
recordList = this.labelService.listByPage(param, cloudwalkCallContext);
} catch (Exception e) {
this.logger.error("查询标签记录数据失败");
}
return recordList;
}
private void exportUpload(String businessId, String fileId, String zipPathStr) throws IOException {
try {
if (StringUtils.isNotBlank(zipPathStr)) {
uploadFile(businessId, fileId, zipPathStr);
} else {
byte[] data = Base64Utils.decodeFromString("UEsDBBQACAgIAAuPmlAAAAAAAAAAAAAAAAAGAAAAZW1wdHkvAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQAFAAICAgAC4+aUAAAAAACAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAGVtcHR5L1BLBQYAAAAAAQABADQAAAA2AAAAAAA=");
uploadFile(businessId, fileId, data, data.length);
}
} catch (Exception e) {
this.logger.error("将导出文件生成的zip上传到文件管理中心发生异常:{}", e.getMessage());
throw new RuntimeException("将导出文件生成的zip上传到文件管理中心发生异常");
} finally {
this.logger.debug("删除压缩包:{}", zipPathStr);
File file = new File(zipPathStr);
if (file.exists()) {
Files.delete(file.toPath());
}
}
}
private void uploadFile(String businessId, String fileId, byte[] data, long fileSize) {
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
String name = uuidCode + this.commonDownloadDataConfig.getCompressionType();
String filePath = this.commonAppStorageService.saveFileBySharding(name, data);
this.logger.info("存储文件名:fileId = {}, filePath = {}", fileId, filePath);
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
if (status == FileStatusEnum.PRODUCING.getCode().intValue() || status == FileStatusEnum.ERROR.getCode().intValue()) {
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
} else {
this.commonAppStorageService.deleteFile(filePath);
}
}
private void uploadFile(String businessId, String fileId, String zipPathStr) throws IOException {
ChannelFileReader reader = new ChannelFileReader(zipPathStr, this.shardingSize.intValue());
try {
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
String name = uuidCode + this.commonDownloadDataConfig.getCompressionType();
FilePartInitResult resp = this.iCommonAppFileManageService.filePartInit(name);
if (resp == null) {
this.logger.info("分片上传文件初始化返回值为空");
return;
}
AtomicInteger i = new AtomicInteger(1);
long fileSize = 0L;
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)));
}
String filePath = filePartFinish(fileSize, resp);
if (filePath == null) {
this.logger.info("分片上传文件完成接口返回值为空");
return;
}
this.logger.info("分片上传文件完成接口返回值 filePath = {}", filePath);
this.logger.info("存储文件名:fileId = {}, filePath = {}", fileId, filePath);
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
if (status == FileStatusEnum.PRODUCING.getCode().intValue() || status == FileStatusEnum.ERROR.getCode().intValue()) {
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
} else {
this.commonAppStorageService.deleteFile(filePath);
}
this.logger.info("完成上传任务 fileId = {}", fileId);
} catch (Exception e) {
this.logger.error("分片上传文件报错 {}: {}", e.getClass().getName(), e.getMessage());
} finally {
reader.close();
}
}
private String filePartFinish(long fileSize, FilePartInitResult resp) {
FilePartFinishPara para = new FilePartFinishPara();
BeanUtils.copyProperties(resp, 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("分片更新文件错误{}:{}", e.getClass().getName(), e.getMessage());
}
}
}
public class CommonAppExportExecuteTask
extends AbstractImagStoreService {
private static final Logger log = LoggerFactory.getLogger(CommonAppExportExecuteTask.class);
@Autowired
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
@Autowired
private CommonDownloadDataConfig commonDownloadDataConfig;
@Autowired
private ICommonStorageService commonAppStorageService;
@Autowired
private ImgStorePersonService imgStorePersonService;
@Autowired
private OrganizationService organizationService;
@Autowired
private LabelService labelService;
@Autowired
private ImgStorePersonPropertiesService imgStorePersonPropertiesService;
@Autowired
private ICommonAppFileManageService iCommonAppFileManageService;
@Autowired
private FilePartManager filePartManager;
@Autowired
private FileStorageManager fileStorageManager;
@Value(value="${cloudwalk.common-app.download.shardingSize}")
private Integer shardingSize;
String fileName = "人员信息";
String orgFileName = "机构信息";
String labelFileName = "标签信息";
@Async
public void execute(ExportRecordTaskParam task, CloudwalkCallContext cloudwalkCallContext) {
this.logger.info("开始执行人员信息导出功能");
QueryImgPersonParam queryImgPersonParam = new QueryImgPersonParam();
BeanUtils.copyProperties((Object)task, (Object)queryImgPersonParam);
try {
CloudwalkResult<List<ImgStorePersonGetResult>> recordList = this.getPersonData(queryImgPersonParam, cloudwalkCallContext);
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
HashMap<String, List<ImgStorePersonGetResult>> dataMap = new HashMap<String, List<ImgStorePersonGetResult>>();
dataMap.put(this.fileName, (List<ImgStorePersonGetResult>)recordList.getData());
PersonProListResult personProListResult = (PersonProListResult)this.imgStorePersonPropertiesService.getList(task.getBusinessId()).getData();
List properties = personProListResult.getProperties();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("门禁设备(在线)");
result1.setCode("onlineDevices");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(17));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("门禁设备(离线)");
result2.setCode("offlineDevices");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(18));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("派梯楼层权限");
result3.setCode("floorNames");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(19));
result3.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON((Object)properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
this.commonDownloadDataConfig.setHasContainImage(task.getHasContainImage());
Path zipPath = new CommonAppExportFileHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出人员任务失败:{}", (Object)e.getMessage());
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
throw new RuntimeException("执行导出人员记录任务异常");
}
}
/* 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
@Async
public void executeOrg(ExportOrgTaskParam task, CloudwalkCallContext context) {
this.logger.info("开始执行机构信息导出功能");
QueryOrganizationParam queryImgPersonParam = new QueryOrganizationParam();
BeanUtils.copyProperties((Object)task, (Object)queryImgPersonParam);
try {
CloudwalkResult<List<OrganizationResult>> recordList = this.getOrgData(queryImgPersonParam, context);
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
HashMap<String, List<OrganizationResult>> dataMap = new HashMap<String, List<OrganizationResult>>();
dataMap.put(this.orgFileName, (List<OrganizationResult>)recordList.getData());
PersonProListResult personProListResult = new PersonProListResult();
ArrayList<ImgPersonProGetResult> properties = new ArrayList<ImgPersonProGetResult>();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("机构名称");
result1.setCode("name");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(1));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("机构id");
result2.setCode("id");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(2));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("机构类型");
result3.setCode("type");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(3));
result3.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
result4.setId("4");
result4.setName("人员数量");
result4.setCode("personCount");
result4.setStatus(Integer.valueOf(0));
result4.setType(Short.valueOf((short)1));
result4.setOrderNum(Integer.valueOf(4));
result4.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
result5.setId("5");
result5.setName("状态:0-已启用");
result5.setCode("isDel");
result5.setStatus(Integer.valueOf(0));
result5.setType(Short.valueOf((short)1));
result5.setOrderNum(Integer.valueOf(5));
result5.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
result6.setId("6");
result6.setName("门禁设备(在线)");
result6.setCode("onlineDevices");
result6.setStatus(Integer.valueOf(0));
result6.setType(Short.valueOf((short)1));
result6.setOrderNum(Integer.valueOf(6));
result6.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
result7.setId("7");
result7.setName("门禁设备(离线)");
result7.setCode("offlineDevices");
result7.setStatus(Integer.valueOf(0));
result7.setType(Short.valueOf((short)1));
result7.setOrderNum(Integer.valueOf(7));
result7.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
result8.setId("8");
result8.setName("派梯楼层权限");
result8.setCode("floorNames");
result8.setStatus(Integer.valueOf(0));
result8.setType(Short.valueOf((short)1));
result8.setOrderNum(Integer.valueOf(8));
result8.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
properties.add(result4);
properties.add(result5);
properties.add(result6);
properties.add(result7);
properties.add(result8);
personProListResult.setProperties(properties);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
Path zipPath = new CommonAppExportFileByOrgHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出机构任务失败:{}", e);
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
throw new RuntimeException("执行导出机构信息任务异常");
}
}
@Async
public void executeLabel(ExportLabelTaskParam task, CloudwalkCallContext context) {
this.logger.info("开始执行标签信息导出功能");
PageLabelParam pageLabelParam = new PageLabelParam();
BeanUtils.copyProperties((Object)task, (Object)pageLabelParam);
try {
CloudwalkResult<List<PageLabelResult>> recordList = this.getLabelData(pageLabelParam, context);
if (CollectionUtils.isEmpty((Collection)((Collection)recordList.getData()))) {
this.logger.info("查询导出记录为空, businessId = {}, task = {}", (Object)task.getBusinessId(), (Object)task);
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.logger.info("导出记录总数为{}", (Object)((List)recordList.getData()).size());
HashMap<String, List<PageLabelResult>> dataMap = new HashMap<String, List<PageLabelResult>>();
dataMap.put(this.labelFileName, (List<PageLabelResult>)recordList.getData());
PersonProListResult personProListResult = new PersonProListResult();
ArrayList<ImgPersonProGetResult> properties = new ArrayList<ImgPersonProGetResult>();
ImgPersonProGetResult result1 = new ImgPersonProGetResult();
result1.setId("1");
result1.setName("标签名称");
result1.setCode("name");
result1.setStatus(Integer.valueOf(0));
result1.setType(Short.valueOf((short)1));
result1.setOrderNum(Integer.valueOf(1));
result1.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result2 = new ImgPersonProGetResult();
result2.setId("2");
result2.setName("标签id");
result2.setCode("id");
result2.setStatus(Integer.valueOf(0));
result2.setType(Short.valueOf((short)1));
result2.setOrderNum(Integer.valueOf(2));
result2.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result3 = new ImgPersonProGetResult();
result3.setId("3");
result3.setName("标签编号");
result3.setCode("code");
result3.setStatus(Integer.valueOf(0));
result3.setType(Short.valueOf((short)1));
result3.setOrderNum(Integer.valueOf(3));
result3.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result4 = new ImgPersonProGetResult();
result4.setId("4");
result4.setName("人员数量");
result4.setCode("personCount");
result4.setStatus(Integer.valueOf(0));
result4.setType(Short.valueOf((short)1));
result4.setOrderNum(Integer.valueOf(4));
result4.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result5 = new ImgPersonProGetResult();
result5.setId("5");
result5.setName("标签类型:0-手动创建,1-应用初始,2-应用创建");
result5.setCode("addType");
result5.setStatus(Integer.valueOf(0));
result5.setType(Short.valueOf((short)1));
result5.setOrderNum(Integer.valueOf(5));
result5.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result6 = new ImgPersonProGetResult();
result6.setId("6");
result6.setName("门禁设备(在线)");
result6.setCode("onlineDevices");
result6.setStatus(Integer.valueOf(0));
result6.setType(Short.valueOf((short)1));
result6.setOrderNum(Integer.valueOf(6));
result6.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result7 = new ImgPersonProGetResult();
result7.setId("7");
result7.setName("门禁设备(离线)");
result7.setCode("offlineDevices");
result7.setStatus(Integer.valueOf(0));
result7.setType(Short.valueOf((short)1));
result7.setOrderNum(Integer.valueOf(7));
result7.setHasDefault(Integer.valueOf(1));
ImgPersonProGetResult result8 = new ImgPersonProGetResult();
result8.setId("8");
result8.setName("派梯楼层权限");
result8.setCode("floorNames");
result8.setStatus(Integer.valueOf(0));
result8.setType(Short.valueOf((short)1));
result8.setOrderNum(Integer.valueOf(8));
result8.setHasDefault(Integer.valueOf(1));
properties.add(result1);
properties.add(result2);
properties.add(result3);
properties.add(result4);
properties.add(result5);
properties.add(result6);
properties.add(result7);
properties.add(result8);
personProListResult.setProperties(properties);
this.logger.info("导出的字段属性为:{}", JSONObject.toJSON(properties));
this.commonDownloadDataConfig.setExcelMaxRows(task.getExcelMaxRows());
Path zipPath = new CommonAppExportFileByLabelHandler(task.getBusinessId(), this.fileName, task.getFileId(), dataMap, this.commonDownloadDataConfig, this.fileStorageManager, this.commonAppDownloadCenterService, personProListResult).process();
int status = this.commonAppDownloadCenterService.queryDownloadStatus(task.getBusinessId(), task.getFileId());
if (status > 1) {
this.logger.info("下载中心已取消下载文件,fileId = {}", (Object)task.getFileId());
this.exportUpload(task.getBusinessId(), task.getFileId(), null);
return;
}
this.exportUpload(task.getBusinessId(), task.getFileId(), zipPath.toString());
}
catch (Exception e) {
this.logger.error("导出标签任务失败:{}", e);
this.commonAppDownloadCenterService.finishDownload(task.getBusinessId(), task.getFileId(), null, null, FileStatusEnum.ERROR.getCode());
throw new RuntimeException("执行导出标签信息任务异常");
}
}
private CloudwalkResult<List<ImgStorePersonGetResult>> getPersonData(QueryImgPersonParam queryImgPersonParam, CloudwalkCallContext cloudwalkCallContext) {
CloudwalkResult recordList = new CloudwalkResult();
try {
recordList = this.imgStorePersonService.listByPage(queryImgPersonParam, cloudwalkCallContext);
}
catch (Exception e) {
this.logger.error("查询记录数据失败");
}
return recordList;
}
private CloudwalkResult<List<OrganizationResult>> getOrgData(QueryOrganizationParam param, CloudwalkCallContext context) {
CloudwalkResult recordList = new CloudwalkResult();
try {
recordList = this.organizationService.listByPage(param, context);
}
catch (Exception e) {
this.logger.error("查询机构记录数据失败");
}
return recordList;
}
private CloudwalkResult<List<PageLabelResult>> getLabelData(PageLabelParam param, CloudwalkCallContext cloudwalkCallContext) {
CloudwalkResult recordList = new CloudwalkResult();
try {
recordList = this.labelService.listByPage(param, cloudwalkCallContext);
}
catch (Exception e) {
this.logger.error("查询标签记录数据失败");
}
return recordList;
}
private void exportUpload(String businessId, String fileId, String zipPathStr) throws IOException {
try {
if (StringUtils.isNotBlank((CharSequence)zipPathStr)) {
this.uploadFile(businessId, fileId, zipPathStr);
} else {
byte[] data = Base64Utils.decodeFromString((String)"UEsDBBQACAgIAAuPmlAAAAAAAAAAAAAAAAAGAAAAZW1wdHkvAwBQSwcIAAAAAAIAAAAAAAAAUEsBAhQAFAAICAgAC4+aUAAAAAACAAAAAAAAAAYAAAAAAAAAAAAAAAAAAAAAAGVtcHR5L1BLBQYAAAAAAQABADQAAAA2AAAAAAA=");
this.uploadFile(businessId, fileId, data, data.length);
}
}
catch (Exception e) {
this.logger.error("将导出文件生成的zip上传到文件管理中心发生异常:{}", (Object)e.getMessage());
throw new RuntimeException("将导出文件生成的zip上传到文件管理中心发生异常");
}
finally {
this.logger.debug("删除压缩包:{}", (Object)zipPathStr);
File file = new File(zipPathStr);
if (file.exists()) {
Files.delete(file.toPath());
}
}
}
private void uploadFile(String businessId, String fileId, byte[] data, long fileSize) {
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
String name = new StringBuffer(uuidCode).append(this.commonDownloadDataConfig.getCompressionType()).toString();
String filePath = this.commonAppStorageService.saveFileBySharding(name, data);
this.logger.info("存储文件名:fileId = {}, filePath = {}", (Object)fileId, (Object)filePath);
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
if (status == FileStatusEnum.PRODUCING.getCode() || status == FileStatusEnum.ERROR.getCode()) {
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
} else {
this.commonAppStorageService.deleteFile(filePath);
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private void uploadFile(String businessId, String fileId, String zipPathStr) throws IOException {
try (ChannelFileReader reader = new ChannelFileReader(zipPathStr, this.shardingSize);){
String uuidCode = UUID.randomUUID().toString().replaceAll("-", "");
String name = new StringBuffer(uuidCode).append(this.commonDownloadDataConfig.getCompressionType()).toString();
FilePartInitResult resp = this.iCommonAppFileManageService.filePartInit(name);
if (resp == null) {
this.logger.info("分片上传文件初始化返回值为空");
return;
}
AtomicInteger i = new AtomicInteger(1);
long fileSize = 0L;
while (reader.read() != -1) {
this.logger.info("分片上传第{}次", (Object)i.get());
fileSize += (long)reader.getArray().length;
this.uploadFileBySharding(reader.getArray(), resp.getFilePath(), resp.getUploadId(), this.fileName, String.valueOf(i.getAndAdd(1)));
}
String filePath = this.filePartFinish(fileSize, resp);
if (filePath == null) {
this.logger.info("分片上传文件完成接口返回值为空");
return;
}
this.logger.info("分片上传文件完成接口返回值 filePath = {}", (Object)filePath);
this.logger.info("存储文件名:fileId = {}, filePath = {}", (Object)fileId, (Object)filePath);
int status = this.commonAppDownloadCenterService.queryDownloadStatus(businessId, fileId);
if (status == FileStatusEnum.PRODUCING.getCode() || status == FileStatusEnum.ERROR.getCode()) {
this.commonAppDownloadCenterService.finishDownload(businessId, fileId, filePath, Long.valueOf(fileSize), FileStatusEnum.FINISH.getCode());
} else {
this.commonAppStorageService.deleteFile(filePath);
}
this.logger.info("完成上传任务 fileId = {}", (Object)fileId);
}
}
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());
}
}
}
@@ -203,7 +203,7 @@ PersonBatchImportTask.BATCH_SEMAPHORE.release();
private void cleanFiles(BatchImportContext context) {
try {
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"));
} catch (Exception ex) {
logger.error("", ex);
@@ -19,81 +19,85 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
@Service
@EnableAsync
public class CommonAppExportTaskServiceImpl extends AbstractImagStoreService implements ICommonAppExportTaskService {
private static final Logger log = LoggerFactory.getLogger(CommonAppExportTaskServiceImpl.class);
@Autowired
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
@Autowired
private ImgStorePersonService imgStorePersonService;
@Autowired
private CommonAppExportExecuteTask commonAppExportExecuteTask;
@Autowired
private CommonDownloadDataConfig commonAppRecordDataConfig;
@Autowired
private ComponentInnerKafkaConfig componentInnerKafkaConfig;
String fileName = "人员信息";
String orgFileName = "机构信息";
String labelFileName = "标签信息";
public String add(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) throws ServiceException {
String name = createFileName(this.fileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
updateCloudwalkContext(cloudwalkCallContext, task);
String fileId = this.commonAppDownloadCenterService.createDownload(cloudwalkCallContext, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.execute(task, cloudwalkCallContext);
return fileId;
}
public String addOrgExport(CloudwalkCallContext context, ExportOrgTaskParam task) throws ServiceException {
String name = createFileName(this.orgFileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
taskParam.setBusinessId(task.getBusinessId());
updateCloudwalkContext(context, taskParam);
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.executeOrg(task, context);
return fileId;
}
public String addLabelExport(CloudwalkCallContext context, ExportLabelTaskParam task) throws ServiceException {
String name = createFileName(this.labelFileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", name);
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
taskParam.setBusinessId(task.getBusinessId());
updateCloudwalkContext(context, taskParam);
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.executeLabel(task, context);
return fileId;
}
private void updateCloudwalkContext(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) {
cloudwalkCallContext.setServiceCode(this.componentInnerKafkaConfig.getServiceCode());
UserContext userContext = new UserContext();
userContext.setCaller(cloudwalkCallContext.getUser().getCaller());
userContext.setCallerName(cloudwalkCallContext.getUser().getCallerName());
cloudwalkCallContext.setUser(userContext);
CompanyContext companyContext = new CompanyContext();
companyContext.setCompanyId(task.getBusinessId());
cloudwalkCallContext.setCompany(companyContext);
}
private String createFileName(String type) {
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();
}
public class CommonAppExportTaskServiceImpl
extends AbstractImagStoreService
implements ICommonAppExportTaskService {
private static final Logger log = LoggerFactory.getLogger(CommonAppExportTaskServiceImpl.class);
@Autowired
private ICommonAppDownloadCenterService commonAppDownloadCenterService;
@Autowired
private ImgStorePersonService imgStorePersonService;
@Autowired
private CommonAppExportExecuteTask commonAppExportExecuteTask;
@Autowired
private CommonDownloadDataConfig commonAppRecordDataConfig;
@Autowired
private ComponentInnerKafkaConfig componentInnerKafkaConfig;
String fileName = "人员信息";
String orgFileName = "机构信息";
String labelFileName = "标签信息";
public String add(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) throws ServiceException {
String name = this.createFileName(this.fileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
this.updateCloudwalkContext(cloudwalkCallContext, task);
String fileId = this.commonAppDownloadCenterService.createDownload(cloudwalkCallContext, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.execute(task, cloudwalkCallContext);
return fileId;
}
public String addOrgExport(CloudwalkCallContext context, ExportOrgTaskParam task) throws ServiceException {
String name = this.createFileName(this.orgFileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
taskParam.setBusinessId(task.getBusinessId());
this.updateCloudwalkContext(context, taskParam);
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.executeOrg(task, context);
return fileId;
}
public String addLabelExport(CloudwalkCallContext context, ExportLabelTaskParam task) throws ServiceException {
String name = this.createFileName(this.labelFileName);
this.logger.info("创建下载任务,任务文件名称:name = {}", (Object)name);
ExportRecordTaskParam taskParam = new ExportRecordTaskParam();
taskParam.setBusinessId(task.getBusinessId());
this.updateCloudwalkContext(context, taskParam);
String fileId = this.commonAppDownloadCenterService.createDownload(context, name, task.getBusinessId());
task.setFileId(fileId);
task.setFileName(name);
this.commonAppExportExecuteTask.executeLabel(task, context);
return fileId;
}
private void updateCloudwalkContext(CloudwalkCallContext cloudwalkCallContext, ExportRecordTaskParam task) {
cloudwalkCallContext.setServiceCode(this.componentInnerKafkaConfig.getServiceCode());
UserContext userContext = new UserContext();
userContext.setCaller(cloudwalkCallContext.getUser().getCaller());
userContext.setCallerName(cloudwalkCallContext.getUser().getCallerName());
cloudwalkCallContext.setUser(userContext);
CompanyContext companyContext = new CompanyContext();
companyContext.setCompanyId(task.getBusinessId());
cloudwalkCallContext.setCompany(companyContext);
}
private String createFileName(String type) {
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
*/
@@ -13,44 +13,47 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CommonAppFileManageServiceImpl implements ICommonAppFileManageService {
private static final Logger log = LoggerFactory.getLogger(CommonAppFileManageServiceImpl.class);
@Autowired
private FilePartManager filePartManager;
public FilePartInitResult filePartInit(String fileName) {
FilePartInitResult result = new FilePartInitResult();
PartInitDTO dto = new PartInitDTO();
dto.setFileName(fileName);
PartInitResultDTO partInitResultDTO = new PartInitResultDTO();
try {
partInitResultDTO = this.filePartManager.init(dto);
} catch (DavinciServiceException e) {
log.error("分片上传文件初始化接口错误 request = {}", fileName);
}
BeanUtils.copyProperties(partInitResultDTO, result);
return result;
}
public FilePartInitResult filePartAppend(FilePartAppendPara para) {
return null;
}
public String filePartFinish(FilePartFinishPara para) {
PartFinishDTO partFinishDTO = new PartFinishDTO();
partFinishDTO.setFilePath(para.getFilePath());
partFinishDTO.setFileSize(para.getFileSize());
partFinishDTO.setReturnType(para.getReturnType());
partFinishDTO.setUploadId(para.getUploadId());
try {
return this.filePartManager.finish(partFinishDTO);
} catch (DavinciServiceException e) {
log.error("分片上传文件完成接口错误{}:{}", e.getClass().getName(), e.getMessage());
return null;
}
}
public class CommonAppFileManageServiceImpl
implements ICommonAppFileManageService {
private static final Logger log = LoggerFactory.getLogger(CommonAppFileManageServiceImpl.class);
@Autowired
private FilePartManager filePartManager;
public FilePartInitResult filePartInit(String fileName) {
FilePartInitResult result = new FilePartInitResult();
PartInitDTO dto = new PartInitDTO();
dto.setFileName(fileName);
PartInitResultDTO partInitResultDTO = new PartInitResultDTO();
try {
partInitResultDTO = this.filePartManager.init(dto);
}
catch (DavinciServiceException e) {
log.error("分片上传文件初始化接口错误 request = {}", (Object)fileName);
}
BeanUtils.copyProperties((Object)partInitResultDTO, (Object)result);
return result;
}
public FilePartInitResult filePartAppend(FilePartAppendPara para) {
return null;
}
public String filePartFinish(FilePartFinishPara para) {
PartFinishDTO partFinishDTO = new PartFinishDTO();
partFinishDTO.setFilePath(para.getFilePath());
partFinishDTO.setFileSize(para.getFileSize());
partFinishDTO.setReturnType(para.getReturnType());
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
*/
@@ -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) {
@@ -106,9 +106,9 @@ handleGroupPersonSynTask(imageStoreId);
public void addGroupPersonSynTask(String imageStoreId, String personId, boolean isAdd) {
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
if (isAdd) {
groupPersonSynData.setAddPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
groupPersonSynData.setAddPersonIds(Lists.newArrayList(personId ));
} else {
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
groupPersonSynData.setDelPersonIds(Lists.newArrayList(personId ));
}
String jsonData = JsonUtils.toJson(groupPersonSynData);
addWaitSynTask(imageStoreId, jsonData);
@@ -138,7 +138,7 @@ Map<String, GroupPersonRef> imageStoreIdsMap = this.cpImageStorePersonManager.ge
List<String> imageStoreIds = Lists.newArrayList(imageStoreIdsMap.keySet());
if (Collections3.isNotEmpty(imageStoreIds)) {
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
groupPersonSynData.setAddPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
groupPersonSynData.setAddPersonIds(Lists.newArrayList(personId ));
String jsonData = JsonUtils.toJson(groupPersonSynData);
for (String imageStoreId : imageStoreIds) {
addWaitSynTask(imageStoreId, jsonData);
@@ -171,7 +171,7 @@ List<String> imageStoreIdsNeedDelete = Lists.newArrayList(imageStoreIdsBefore);
this.logger.info("addGroupPersonSynTask - 新增图库待同步任务(更新人员注册照) imageStoreIdsAfter{}imageStoreIdsNeedDelete: {}", imageStoreIds, imageStoreIdsNeedDelete);
if (Collections3.isNotEmpty(imageStoreIdsNeedDelete)) {
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { personId }));
groupPersonSynData.setDelPersonIds(Lists.newArrayList(personId ));
String jsonData = JsonUtils.toJson(groupPersonSynData);
for (String imageStoreId : imageStoreIdsNeedDelete) {
addWaitSynTask(imageStoreId, jsonData);
@@ -408,11 +408,11 @@ List<SyncPersonDTO> syncPersonList = Lists.newArrayList();
if (StringUtils.isNotBlank(synData.getPersonId())) {
this.logger.info("CpImageStorePersonSynManager handleImageStoreIncrementSyn 单人员更新注册照:{}{}", synData
.getPersonId(), synData.getOldImageId());
Map<String, GroupPersonRef> associatedPersonResultsAfterUpdate = this.cpImageStorePersonManager.getGroupPersonRefByPersons(waitSyncImageStore.getId(), Lists.newArrayList((Object[])new String[] { synData.getPersonId() }));
Map<String, GroupPersonRef> associatedPersonResultsBeforeUpdate = this.cpImageStorePersonManager.getOldAssociatedPersonIds(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(synData.getPersonId() ));
GroupPersonRef refAfterUpdate = associatedPersonResultsAfterUpdate.get(synData.getPersonId());
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)) {
ImgStorePerson personExpiryDate = associatedPersonExpiryDateAfterUpdate.get(0);
if (personExpiryDate.getExpiryBeginDate() != null || personExpiryDate.getExpiryEndDate() != null) {
@@ -228,7 +228,7 @@ this.groupPersonRefMapper.logicDeleteExpireNullByParam(deleteParam);
}
for (String deleteImageStoreId : imageStoreIdsNeedDelete) {
handleImageStoreImageChange(deleteImageStoreId,
Sets.newHashSet((Object[])new String[] { imgStorePerson.getImageId() }), false);
Sets.newHashSet(imgStorePerson.getImageId() ), false);
}
}
@Async("handleImageTaskExecutor")
@@ -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
*/
@@ -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.DeviceImageStoreReSyncParam;
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.device.mgn.atomic.param.AtomicDeviceCommonParam;
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.GroupPersonRefMapper;
import cn.cloudwalk.service.organization.common.AbstractImagStoreService;
import cn.cloudwalk.service.organization.service.CpImageStoreSyncManager;
import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
@@ -35,200 +36,200 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@Component
public class DeviceGroupRefChangeEventHandler
extends AbstractImagStoreService
{
@Resource
private AggDeviceImageStoreService aggDeviceImageStoreService;
@Resource
private AtomicDeviceService atomicDeviceService;
@Resource
private CpImageStoreSyncManager cpImageStoreSyncManager;
@Resource
private DevicePersonSyncLogMapper devicePersonSyncLogMapper;
@Resource
private DeviceImageStoreMapper deviceImageStoreMapper;
@Resource
private GroupPersonRefMapper groupPersonRefMapper;
@Resource
private UUIDSerial uuidSerial;
@Value("${person.partition.size:100}")
private Integer personPartitionSize;
@Async("deviceGroupChangeTaskExecutor")
public void handler(DeviceGroupRefChangeEvent event) {
if (null == event) {
return;
}
if (StringUtils.isBlank(event.getDeviceId()) || StringUtils.isBlank(event.getGroupId())) {
this.logger.warn("设备[{}]或者图库[{}]为空", event.getDeviceId(), event.getGroupId());
return;
}
this.logger.debug("Kafka消费设备图库变更数据:[{}]", JSON.toJSONString(event));
try {
AtomicDeviceCommonParam queryDevice = new AtomicDeviceCommonParam();
queryDevice.setId(event.getDeviceId());
CloudwalkResult<CoreDeviceDetailResult> deviceResult = this.atomicDeviceService.detail(queryDevice, getCloudwalkContext());
if (!deviceResult.isSuccess() || null == deviceResult.getData()) {
this.logger.warn("查询设备[{}]失败", event.getDeviceId());
return;
}
CoreDeviceDetailResult device = (CoreDeviceDetailResult)deviceResult.getData();
if (device.getIdentifyType().shortValue() != 0) {
this.logger.warn("设备[{}]非前端识别", device.getId());
return;
}
saveDeviceImageStoreChange(event);
unbindDeviceImageStore(event, device);
bindDeviceImageStore(event);
} catch (Exception e) {
this.logger.error("执行报错 {}: {}", e.getClass().getName(), e.getMessage());
}
}
private int saveDeviceImageStoreChange(DeviceGroupRefChangeEvent event) {
Long time = Long.valueOf(System.currentTimeMillis());
DeviceImageStore query = new DeviceImageStore();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setType(Integer.valueOf(event.getType().shortValue()));
query.setLastUpdateTime(time);
List<DeviceImageStore> result = this.deviceImageStoreMapper.select(query);
if (CollectionUtils.isEmpty(result)) {
this.logger.debug("根据设备[{}]图库[{}]未查询到变更记录,新增", event.getDeviceId(), event.getGroupId());
query.setId(this.uuidSerial.uuid());
query.setCreateTime(time);
return this.deviceImageStoreMapper.insertSelective(query);
}
this.logger.debug("根据设备[{}]图库[{}]查询到变更记录[{}],修改", new Object[] { event.getDeviceId(), event.getGroupId(), ((DeviceImageStore)result.get(0)).getId() });
query.setFinishPullTime(null);
query.setStatus(StatusEnum.UNNOTIFY.getValue());
return this.deviceImageStoreMapper.update(query);
}
private void unbindDeviceImageStore(DeviceGroupRefChangeEvent event, CoreDeviceDetailResult device) {
if (event.getType().shortValue() != 2) {
return;
}
this.logger.debug("开始处理设备[{}]图库[{}]解绑", event.getDeviceId(), event.getGroupId());
try {
DeviceImageStoreQueryParam storeQueryParam = new DeviceImageStoreQueryParam();
storeQueryParam.setDeviceId(event.getDeviceId());
CloudwalkResult<List<DeviceImageStoreQueryResult>> imageStoreResult = this.aggDeviceImageStoreService.query(storeQueryParam, getCloudwalkContext());
if (imageStoreResult.isSuccess() && !CollectionUtils.isEmpty((Collection)imageStoreResult.getData())) {
this.logger.debug("设备[{}]仍绑定其他图库", event.getDeviceId());
String deviceCode = device.getDeviceCode();
if (null == device.getSupportMultiPersonGroup() ||
Objects.equals(Integer.valueOf(device.getSupportMultiPersonGroup().intValue()),
Integer.valueOf(DeviceAbilityEnum.NOT_SUPPORT_MULTI_PERSON_GROUP.getCode()))) {
this.logger.debug("设备[{}]code[{}]不支持多图库,下发50009", event.getDeviceId(), deviceCode);
List<String> imageStoreIds = (List<String>)((List)imageStoreResult.getData()).stream().map(DeviceImageStoreQueryResult::getImageStoreId).collect(
Collectors.toList());
updateSyncLog(event, imageStoreIds);
Set<String> changeGroupIdSet = Sets.newHashSet();
changeGroupIdSet.add(event.getGroupId());
((List)imageStoreResult.getData()).stream().forEach(imageStore -> changeGroupIdSet.add(imageStore.getImageStoreId()));
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
return;
}
}
notify50010(event);
} 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());
query.setImageStoreId(event.getGroupId());
List<DevicePersonSyncLog> dbSyncLogList = this.devicePersonSyncLogMapper.query(query);
Set<String> personIdSet = (Set<String>)dbSyncLogList.stream().map(DevicePersonSyncLog::getPersonId).collect(
Collectors.toSet());
List<List<String>> personIdPartition = Lists.partition(Lists.newArrayList(personIdSet), this.personPartitionSize.intValue());
for (List<String> personIds : personIdPartition) {
query.setImageStoreIds(imageStoreIds);
query.setPersonIds(personIds);
List<String> personIdList = this.devicePersonSyncLogMapper.findPersonIds(query);
Long currentTime = Long.valueOf(System.currentTimeMillis());
if (!CollectionUtils.isEmpty(personIdList)) {
this.logger.info("移除在其他图库中的人员:[{}]", personIdList);
personIdSet.removeAll(personIdList);
query.setPersonIds(personIdList);
query.setLastUpdateTime(currentTime);
this.devicePersonSyncLogMapper.updateLastTimeOfGroupPerson(query);
query.setLastUpdateTime(null);
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.info("设备[{}]图库[{}]更新[{}]条人员存在其他图库中", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
}
this.groupPersonRefMapper.updateLastUpdateTimeByPersonIds(event.getGroupId(), personIds, currentTime);
}
if (!CollectionUtils.isEmpty(personIdSet)) {
personIdPartition = Lists.partition(Lists.newArrayList(personIdSet), this.personPartitionSize.intValue());
query = new DevicePersonSyncLogDTO();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
for (List<String> personIds : personIdPartition) {
query.setPersonIds(personIds);
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.info("设备[{}]图库[{}]更新[{}]条人员不存在其他图库中", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
}
}
}
private void notify50010(DeviceGroupRefChangeEvent event) {
try {
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue().intValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.debug("设备[{}]图库[{}]解绑,逻辑删除[{}]条同步记录", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
this.logger.debug("设备[{}]图库[{}]下发50010", event.getDeviceId(), event.getGroupId());
DeviceImageStoreReSyncParam deviceImageStoreReSyncParam = new DeviceImageStoreReSyncParam();
deviceImageStoreReSyncParam.setDeviceId(event.getDeviceId());
deviceImageStoreReSyncParam.setImageStoreId(event.getGroupId());
CloudwalkResult<List<DeviceImageStoreReSyncResult>> result = this.aggDeviceImageStoreService.reSync(deviceImageStoreReSyncParam, getCloudwalkContext());
if (result.isSuccess()) {
DeviceImageStore notify = new DeviceImageStore();
notify.setDeviceId(event.getDeviceId());
notify.setImageStoreId(event.getGroupId());
List<DeviceImageStore> deviceImageStoreList = this.deviceImageStoreMapper.select(notify);
if (!CollectionUtils.isEmpty(deviceImageStoreList)) {
notify = deviceImageStoreList.get(0);
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() });
}
}
private void bindDeviceImageStore(DeviceGroupRefChangeEvent event) {
if (event.getType().shortValue() != 1) {
return;
}
this.logger.debug("开始处理设备[{}]图库[{}]绑定", event.getDeviceId(), event.getGroupId());
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.VALID.getValue().intValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.debug("设备[{}]图库[{}]绑定,更新[{}]条同步记录", new Object[] { event.getDeviceId(), event.getGroupId(), Integer.valueOf(res) });
Set<String> changeGroupIdSet = Sets.newHashSet();
changeGroupIdSet.add(event.getGroupId());
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
}
extends AbstractImagStoreService {
@Resource
private AggDeviceImageStoreService aggDeviceImageStoreService;
@Resource
private AtomicDeviceService atomicDeviceService;
@Resource
private CpImageStoreSyncManager cpImageStoreSyncManager;
@Resource
private DevicePersonSyncLogMapper devicePersonSyncLogMapper;
@Resource
private DeviceImageStoreMapper deviceImageStoreMapper;
@Resource
private GroupPersonRefMapper groupPersonRefMapper;
@Resource
private UUIDSerial uuidSerial;
@Value(value="${person.partition.size:100}")
private Integer personPartitionSize;
@Async(value="deviceGroupChangeTaskExecutor")
public void handler(DeviceGroupRefChangeEvent event) {
if (null == event) {
return;
}
if (StringUtils.isBlank((CharSequence)event.getDeviceId()) || StringUtils.isBlank((CharSequence)event.getGroupId())) {
this.logger.warn("设备[{}]或者图库[{}]为空", (Object)event.getDeviceId(), (Object)event.getGroupId());
return;
}
this.logger.debug("Kafka消费设备图库变更数据:[{}]", (Object)JSON.toJSONString((Object)event));
try {
AtomicDeviceCommonParam queryDevice = new AtomicDeviceCommonParam();
queryDevice.setId(event.getDeviceId());
CloudwalkResult deviceResult = this.atomicDeviceService.detail(queryDevice, this.getCloudwalkContext());
if (!deviceResult.isSuccess() || null == deviceResult.getData()) {
this.logger.warn("查询设备[{}]失败", (Object)event.getDeviceId());
return;
}
CoreDeviceDetailResult device = (CoreDeviceDetailResult)deviceResult.getData();
if (device.getIdentifyType() != 0) {
this.logger.warn("设备[{}]非前端识别", (Object)device.getId());
return;
}
this.saveDeviceImageStoreChange(event);
this.unbindDeviceImageStore(event, device);
this.bindDeviceImageStore(event);
}
catch (Exception e) {
this.logger.error("执行报错 {}: {}", (Object)e.getClass().getName(), (Object)e.getMessage());
}
}
private int saveDeviceImageStoreChange(DeviceGroupRefChangeEvent event) {
Long time = System.currentTimeMillis();
DeviceImageStore query = new DeviceImageStore();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setType(Integer.valueOf(event.getType().shortValue()));
query.setLastUpdateTime(time);
List result = this.deviceImageStoreMapper.select(query);
if (CollectionUtils.isEmpty((Collection)result)) {
this.logger.debug("根据设备[{}]图库[{}]未查询到变更记录,新增", (Object)event.getDeviceId(), (Object)event.getGroupId());
query.setId(this.uuidSerial.uuid());
query.setCreateTime(time);
return this.deviceImageStoreMapper.insertSelective(query);
}
this.logger.debug("根据设备[{}]图库[{}]查询到变更记录[{}],修改", new Object[]{event.getDeviceId(), event.getGroupId(), ((DeviceImageStore)result.get(0)).getId()});
query.setFinishPullTime(null);
query.setStatus(StatusEnum.UNNOTIFY.getValue());
return this.deviceImageStoreMapper.update(query);
}
private void unbindDeviceImageStore(DeviceGroupRefChangeEvent event, CoreDeviceDetailResult device) {
if (event.getType() != 2) {
return;
}
this.logger.debug("开始处理设备[{}]图库[{}]解绑", (Object)event.getDeviceId(), (Object)event.getGroupId());
try {
DeviceImageStoreQueryParam storeQueryParam = new DeviceImageStoreQueryParam();
storeQueryParam.setDeviceId(event.getDeviceId());
CloudwalkResult imageStoreResult = this.aggDeviceImageStoreService.query(storeQueryParam, this.getCloudwalkContext());
if (imageStoreResult.isSuccess() && !CollectionUtils.isEmpty((Collection)((Collection)imageStoreResult.getData()))) {
this.logger.debug("设备[{}]仍绑定其他图库", (Object)event.getDeviceId());
String deviceCode = device.getDeviceCode();
if (null == device.getSupportMultiPersonGroup() || Objects.equals(device.getSupportMultiPersonGroup().intValue(), DeviceAbilityEnum.NOT_SUPPORT_MULTI_PERSON_GROUP.getCode())) {
this.logger.debug("设备[{}]code[{}]不支持多图库,下发50009", (Object)event.getDeviceId(), (Object)deviceCode);
List<String> imageStoreIds = ((List)imageStoreResult.getData()).stream().map(DeviceImageStoreQueryResult::getImageStoreId).collect(Collectors.toList());
this.updateSyncLog(event, imageStoreIds);
HashSet changeGroupIdSet = Sets.newHashSet();
changeGroupIdSet.add(event.getGroupId());
((List)imageStoreResult.getData()).stream().forEach(imageStore -> changeGroupIdSet.add(imageStore.getImageStoreId()));
this.cpImageStoreSyncManager.sendChangeToDevice(event.getDeviceId(), changeGroupIdSet, false);
return;
}
}
this.notify50010(event);
}
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());
query.setImageStoreId(event.getGroupId());
List dbSyncLogList = this.devicePersonSyncLogMapper.query(query);
Set personIdSet = dbSyncLogList.stream().map(DevicePersonSyncLog::getPersonId).collect(Collectors.toSet());
List personIdPartition = Lists.partition((List)Lists.newArrayList(personIdSet), (int)this.personPartitionSize);
for (List personIds : personIdPartition) {
query.setImageStoreIds(imageStoreIds);
query.setPersonIds(personIds);
List personIdList = this.devicePersonSyncLogMapper.findPersonIds(query);
Long currentTime = System.currentTimeMillis();
if (!CollectionUtils.isEmpty((Collection)personIdList)) {
this.logger.info("移除在其他图库中的人员:[{}]", (Object)personIdList);
personIdSet.removeAll(personIdList);
query.setPersonIds(personIdList);
query.setLastUpdateTime(currentTime);
this.devicePersonSyncLogMapper.updateLastTimeOfGroupPerson(query);
query.setLastUpdateTime(null);
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.info("设备[{}]图库[{}]更新[{}]条人员存在其他图库中", new Object[]{event.getDeviceId(), event.getGroupId(), res});
}
this.groupPersonRefMapper.updateLastUpdateTimeByPersonIds(event.getGroupId(), personIds, currentTime);
}
if (!CollectionUtils.isEmpty(personIdSet)) {
personIdPartition = Lists.partition((List)Lists.newArrayList(personIdSet), (int)this.personPartitionSize);
query = new DevicePersonSyncLogDTO();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
for (List personIds : personIdPartition) {
query.setPersonIds(personIds);
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
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();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.INVALID.getValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
int res = this.devicePersonSyncLogMapper.updateIsDel(query);
this.logger.debug("设备[{}]图库[{}]解绑,逻辑删除[{}]条同步记录", new Object[]{event.getDeviceId(), event.getGroupId(), res});
this.logger.debug("设备[{}]图库[{}]下发50010", (Object)event.getDeviceId(), (Object)event.getGroupId());
DeviceImageStoreReSyncParam deviceImageStoreReSyncParam = new DeviceImageStoreReSyncParam();
deviceImageStoreReSyncParam.setDeviceId(event.getDeviceId());
deviceImageStoreReSyncParam.setImageStoreId(event.getGroupId());
CloudwalkResult result = this.aggDeviceImageStoreService.reSync(deviceImageStoreReSyncParam, this.getCloudwalkContext());
if (result.isSuccess()) {
DeviceImageStore notify = new DeviceImageStore();
notify.setDeviceId(event.getDeviceId());
notify.setImageStoreId(event.getGroupId());
List deviceImageStoreList = this.deviceImageStoreMapper.select(notify);
if (!CollectionUtils.isEmpty((Collection)deviceImageStoreList)) {
notify = (DeviceImageStore)deviceImageStoreList.get(0);
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()});
}
}
private void bindDeviceImageStore(DeviceGroupRefChangeEvent event) {
if (event.getType() != 1) {
return;
}
this.logger.debug("开始处理设备[{}]图库[{}]绑定", (Object)event.getDeviceId(), (Object)event.getGroupId());
DevicePersonSyncLogDTO query = new DevicePersonSyncLogDTO();
query.setDeviceId(event.getDeviceId());
query.setImageStoreId(event.getGroupId());
query.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
query.setIsDel(Integer.valueOf(StatusEnum.VALID.getValue()));
query.setStatus(Integer.valueOf(SyncStatusEnum.NOT_PULL.getValue()));
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
*/
@@ -388,7 +388,7 @@ this.imgStoreLabelMapper.deletePerson(delPersonLabelDTO);
List<String> imageIdResultList = Lists.newArrayList();
for (Map.Entry<String, List<String>> entry : delMap.entrySet()) {
GroupPersonSynData groupPersonSynData = new GroupPersonSynData();
groupPersonSynData.setDelPersonIds(Lists.newArrayList((Object[])new String[] { entry.getKey() }));
groupPersonSynData.setDelPersonIds(Lists.newArrayList(entry.getKey() ));
String jsonData = JsonUtils.toJson(groupPersonSynData);
for (String imageStoreId : entry.getValue()) {
this.cpImageStorePersonSynManager.addWaitSynTask(imageStoreId, jsonData);
@@ -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
*/