mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-12 01:40:30 +08:00
feat: 租户访客策略 SQL、访客邀约验证包、component-org 与发布脚本
- docs/sql: organization_* 与 tenant_* 访客楼层策略脚本 - docs/testing: 访客邀约页初始化验证、pack 脚本与 README(忽略 dist/__pycache__) - maven-ninca-common-component-organization: CpImageStoreServiceImpl、starter、run-verify、releases 脚本与 javap 审计 JSON - docs/superpowers: component-org 生产问题修复计划 - scripts/test-env/prepare-db.sh 更新 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+833
@@ -0,0 +1,833 @@
|
||||
/*
|
||||
* 自 vendor cwos-component-organization-service-v2.9.2_xinghewan 反编译恢复;与现场逻辑一致。
|
||||
* 原因为 reactor 曾排除 vendor jar 导致该 @Service 未打入 classpath。
|
||||
*/
|
||||
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.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.ImgStorePerson;
|
||||
import cn.cloudwalk.data.organization.entity.IsImageStoreAssociated;
|
||||
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 cn.cloudwalk.service.organization.service.CpImageStorePersonManager;
|
||||
import cn.cloudwalk.service.organization.service.CpImageStorePersonSynManager;
|
||||
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.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
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
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(value="${cloudwalk.imagestore.person.searchSize:2}")
|
||||
private int searchSize;
|
||||
|
||||
@Transactional(rollbackFor={Exception.class})
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<String> add(AddImageStoreParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult addResult;
|
||||
List<IsImageStoreAssociated> imageStoreAssociatedList;
|
||||
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((CharSequence)param.getBusinessId())) {
|
||||
addParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
}
|
||||
if ((imageStoreAssociatedList = this.addBaseImageStore((BaseImageStoreParam)param, context, imageStoreId, addParam.getBusinessId())).size() > 0) {
|
||||
this.isImageStoreAssociatedMapper.batchInsert(imageStoreAssociatedList);
|
||||
}
|
||||
if (!(addResult = this.agImageStoreService.add(addParam, context)).isSuccess()) {
|
||||
throw new ServiceException(addResult.getCode(), addResult.getMessage());
|
||||
}
|
||||
this.cpImageStorePersonSynManager.addGroupPersonSynTask(Lists.newArrayList(imageStoreId), "isAll");
|
||||
return CloudwalkResult.<String>success(imageStoreId);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor={Exception.class})
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> edit(EditImageStoreParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult editResult;
|
||||
this.checkExistAndStatus(param.getImageStoreId());
|
||||
AgImageStoreEditParam editParam = new AgImageStoreEditParam();
|
||||
editParam.setId(param.getImageStoreId());
|
||||
editParam.setName(param.getName());
|
||||
String businessId = param.getBusinessId();
|
||||
if (StringUtils.isBlank((CharSequence)businessId)) {
|
||||
businessId = context.getCompany().getCompanyId();
|
||||
}
|
||||
List<IsImageStoreAssociated> imageStoreAssociatedList = this.addBaseImageStore((BaseImageStoreParam)param, context, param.getImageStoreId(), businessId);
|
||||
if (this.checkAssociatedIsChange(param.getImageStoreId(), imageStoreAssociatedList)) {
|
||||
this.isImageStoreAssociatedMapper.deleteAllByImageId(param.getImageStoreId());
|
||||
if (imageStoreAssociatedList.size() > 0) {
|
||||
this.isImageStoreAssociatedMapper.batchInsert(imageStoreAssociatedList);
|
||||
}
|
||||
editParam.setStatus(SyncStatusEnum.SYNC_WAIT.getCode());
|
||||
}
|
||||
if (!(editResult = this.agImageStoreService.edit(editParam, context)).isSuccess()) {
|
||||
throw new ServiceException(editResult.getCode(), editResult.getMessage());
|
||||
}
|
||||
this.cpImageStorePersonSynManager.addGroupPersonSynTask(Lists.newArrayList(param.getImageStoreId()), "isAll");
|
||||
return CloudwalkResult.<Boolean>success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private boolean checkAssociatedIsChange(String imageStoreId, List<IsImageStoreAssociated> associatedListAfterUpdate) {
|
||||
GetsImageStoreAssociatedDTO queryDTO = new GetsImageStoreAssociatedDTO();
|
||||
queryDTO.setImageStoreId(imageStoreId);
|
||||
List<IsImageStoreAssociated> associatedListBeforeUpdate =
|
||||
(List<IsImageStoreAssociated>) (List) this.isImageStoreAssociatedMapper.gets(queryDTO);
|
||||
if (CollectionUtils.isEmpty((Collection)associatedListBeforeUpdate) && CollectionUtils.isEmpty(associatedListAfterUpdate)) {
|
||||
return false;
|
||||
}
|
||||
if (associatedListBeforeUpdate.size() != associatedListAfterUpdate.size()) {
|
||||
return true;
|
||||
}
|
||||
HashSet<String> associatedStrBeforeUpdate = new HashSet<String>(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());
|
||||
}
|
||||
HashSet<String> associatedStrAfterUpdate = new HashSet<String>(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 {
|
||||
this.checkAppRefByImageStoreIdForDelete(param.getId(), context);
|
||||
this.checkExistAndStatus(param.getId());
|
||||
QueryGroupPersonDTO queryDTO = new QueryGroupPersonDTO();
|
||||
queryDTO.setImageStoreId(param.getId());
|
||||
queryDTO.setIsDel(Short.valueOf(DelStatusEnum.NORAML.getCode()));
|
||||
List 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 delete = this.agImageStoreService.delete((AgImageStoreKeyParam)BeanCopyUtils.copyProperties((Object)param, AgImageStoreKeyParam.class), context);
|
||||
if (!delete.isSuccess()) {
|
||||
throw new ServiceException(delete.getCode(), delete.getMessage());
|
||||
}
|
||||
return CloudwalkResult.<Boolean>success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
private void checkAppRefByImageStoreIdForDelete(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
ApplicationImageStoreQueryParam queryParam = new ApplicationImageStoreQueryParam();
|
||||
queryParam.setImageStoreId(imageStoreId);
|
||||
CloudwalkResult queryResult = this.applicationImageStoreService.query(queryParam, context);
|
||||
if (!queryResult.isSuccess()) {
|
||||
throw new ServiceException(queryResult.getCode(), queryResult.getMessage());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)((Collection)queryResult.getData()))) {
|
||||
throw new ServiceException("53013545", this.getMessage("53013545"));
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<PageImageStoreResult>> page(QueryImageStoreParam queryImageStoreParam, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult agPageResult;
|
||||
boolean isEnd = this.handleQueryParam(queryImageStoreParam);
|
||||
if (isEnd) {
|
||||
return CloudwalkResult.success(
|
||||
new CloudwalkPageAble<PageImageStoreResult>(
|
||||
new ArrayList<PageImageStoreResult>(),
|
||||
new CloudwalkPageInfo(
|
||||
queryImageStoreParam.getCurrentPage(), queryImageStoreParam.getRowsOfPage()),
|
||||
0L));
|
||||
}
|
||||
AgImageStoreQueryParam queryParam = (AgImageStoreQueryParam)BeanCopyUtils.copyProperties((Object)queryImageStoreParam, AgImageStoreQueryParam.class);
|
||||
if (StringUtils.isBlank((CharSequence)queryParam.getBusinessId())) {
|
||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
}
|
||||
if (!(agPageResult = this.agImageStoreService.page(queryParam)).isSuccess()) {
|
||||
return CloudwalkResult.fail((String)agPageResult.getCode(), (String)agPageResult.getMessage());
|
||||
}
|
||||
if (agPageResult.getData() == null) {
|
||||
return CloudwalkResult.success(
|
||||
new CloudwalkPageAble<PageImageStoreResult>(
|
||||
new ArrayList<PageImageStoreResult>(),
|
||||
new CloudwalkPageInfo(queryParam.getCurrentPage(), queryParam.getRowsOfPage()),
|
||||
0L));
|
||||
}
|
||||
List<PageImageStoreResult> resultList = this.packageCpResult(((CloudwalkPageAble)agPageResult.getData()).getDatas(), queryParam.getBusinessId());
|
||||
CloudwalkPageAble<?> pageData = (CloudwalkPageAble<?>) agPageResult.getData();
|
||||
return CloudwalkResult.success(
|
||||
new CloudwalkPageAble<PageImageStoreResult>(
|
||||
resultList,
|
||||
new CloudwalkPageInfo((int) pageData.getCurrentPage(), (int) pageData.getPageSize()),
|
||||
pageData.getTotalRows()));
|
||||
}
|
||||
|
||||
public CloudwalkResult<List<ImageStoreResult>> list(QueryImageStoreParam queryImageStoreParam, CloudwalkCallContext cloudwalkContext) throws ServiceException {
|
||||
CloudwalkResult agQueryResult;
|
||||
List<ImageStoreResult> resultList = new ArrayList<ImageStoreResult>();
|
||||
boolean isEnd = this.handleQueryParam(queryImageStoreParam);
|
||||
if (isEnd) {
|
||||
return CloudwalkResult.success(resultList);
|
||||
}
|
||||
AgImageStoreQueryParam queryParam = (AgImageStoreQueryParam)BeanCopyUtils.copyProperties((Object)queryImageStoreParam, AgImageStoreQueryParam.class);
|
||||
if (StringUtils.isBlank((CharSequence)queryParam.getBusinessId())) {
|
||||
queryParam.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
||||
}
|
||||
if (!(agQueryResult = this.agImageStoreService.query(queryParam)).isSuccess()) {
|
||||
return CloudwalkResult.fail((String)agQueryResult.getCode(), (String)agQueryResult.getMessage());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)queryImageStoreParam.getLabelIds())) {
|
||||
GetsImageStoreAssociatedDTO get = new GetsImageStoreAssociatedDTO();
|
||||
get.setAssociatedObjectIds((Collection)queryImageStoreParam.getLabelIds());
|
||||
get.setAssociatedObjectIdType(Integer.valueOf(2));
|
||||
List<IsImageStoreAssociated> associateds =
|
||||
(List<IsImageStoreAssociated>) (List) this.isImageStoreAssociatedMapper.gets(get);
|
||||
if (CollectionUtils.isEmpty((Collection) associateds)) {
|
||||
return CloudwalkResult.success(resultList);
|
||||
}
|
||||
List<String> imageStoreIds = Collections3.extractToList(associateds, "imageStoreId");
|
||||
List<AgImageStoreResult> agList = (List<AgImageStoreResult>) agQueryResult.getData();
|
||||
List<AgImageStoreResult> collect =
|
||||
agList.stream().filter(a -> imageStoreIds.contains(a.getId())).collect(Collectors.toList());
|
||||
agQueryResult.setData(collect);
|
||||
}
|
||||
resultList =
|
||||
this.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 queryResult = this.agImageStoreService.query(queryParam);
|
||||
if (!queryResult.isSuccess()) {
|
||||
return CloudwalkResult.fail((String)queryResult.getCode(), (String)queryResult.getMessage());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)((Collection)queryResult.getData()))) {
|
||||
return CloudwalkResult.fail((String)"53013502", (String)this.getMessage("53013502"));
|
||||
}
|
||||
AgImageStoreResult agImageStoreResult = (AgImageStoreResult)((List)queryResult.getData()).get(0);
|
||||
ImageStoreDetailResult result = (ImageStoreDetailResult)BeanCopyUtils.copyProperties((Object)agImageStoreResult, ImageStoreDetailResult.class);
|
||||
result.setPersonNum(this.getPersonNum(agImageStoreResult.getId()));
|
||||
try {
|
||||
result.setBusinessName(this.getBusinessName(result.getBusinessId()));
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u67e5\u8be2\u4f01\u4e1a\u540d\u79f0\u9519\u8befe:{}", (Object)e.getMessage());
|
||||
return CloudwalkResult.fail((String)e.getCode(), (String)e.getMessage());
|
||||
}
|
||||
try {
|
||||
result.setSourceApplicationName(this.getSourceApplicationName(result.getSourceApplicationId()));
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u67e5\u8be2\u6765\u6e90\u5e94\u7528\u540d\u79f0\u9519\u8befe:{}", (Object)e.getMessage());
|
||||
return CloudwalkResult.fail((String)e.getCode(), (String)e.getMessage());
|
||||
}
|
||||
this.getAssociated(result);
|
||||
DeviceImageStoreQueryParam deviceParam = new DeviceImageStoreQueryParam();
|
||||
deviceParam.setImageStoreId(param.getId());
|
||||
CloudwalkResult deviceResult = this.deviceImageStoreService.query(deviceParam, context);
|
||||
if (deviceResult.isSuccess()) {
|
||||
result.setDevices(this.getDeviceList((List)deviceResult.getData(), context));
|
||||
} else {
|
||||
this.logger.error("\u56fe\u5e93\u8be6\u60c5\u5173\u8054\u8bbe\u5907\u540d\u79f0\u83b7\u53d6\u5931\u8d25\uff0cresult:[{}]", (Object)JSONObject.toJSONString((Object)deviceResult));
|
||||
}
|
||||
ApplicationImageStoreQueryParam appParam = new ApplicationImageStoreQueryParam();
|
||||
appParam.setImageStoreId(param.getId());
|
||||
CloudwalkResult appResult = this.applicationImageStoreService.query(appParam, context);
|
||||
if (appResult.isSuccess()) {
|
||||
result.setApplicationNames(Collections3.extractToList((Collection)((Collection)appResult.getData()), (String)"applicationName"));
|
||||
} else {
|
||||
this.logger.error("\u56fe\u5e93\u8be6\u60c5\u5173\u8054\u5e94\u7528\u540d\u79f0\u83b7\u53d6\u5931\u8d25\uff0cresult:[{}]", (Object)JSONObject.toJSONString((Object)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 =
|
||||
resultList.stream().map(DeviceImageStoreQueryResult::getDeviceId).collect(Collectors.toList());
|
||||
CoreDeviceQueryParam param = new CoreDeviceQueryParam();
|
||||
param.setIds(deviceIds);
|
||||
param.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult deviceResult = this.atomicDeviceService.list(param, context);
|
||||
Map<String, String> deviceMap = new HashMap<>();
|
||||
if (deviceResult.isSuccess()) {
|
||||
deviceMap =
|
||||
(Map<String, String>)
|
||||
((List<AtomicDeviceGetResult>) (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(this.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 = this.getAssociated(associatedParam.getObjectId(), time, userId, imageStoreId, action, objectType);
|
||||
associated.setExpiryBeginDate(associatedParam.getExpiryBeginDate());
|
||||
associated.setExpiryEndDate(associatedParam.getExpiryEndDate());
|
||||
associated.setValidDateCron(null);
|
||||
if (!CollectionUtils.isEmpty((Collection)associatedParam.getValidDateCron())) {
|
||||
associated.setValidDateCron(JSON.toJSONString((Object)associatedParam.getValidDateCron()));
|
||||
}
|
||||
return associated;
|
||||
}
|
||||
|
||||
private List<IsImageStoreAssociated> addBaseImageStore(BaseImageStoreParam param, CloudwalkCallContext context, String imageStoreId, String businessId) throws ServiceException {
|
||||
long time = System.currentTimeMillis();
|
||||
List<String> includePersonIds =
|
||||
CollectionUtils.isEmpty((Collection) param.getIncludePersons())
|
||||
? new ArrayList<String>()
|
||||
: param.getIncludePersons().stream()
|
||||
.map(AssociatedParam::getObjectId)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty((Collection)param.getIncludeOrganizations()) && CollectionUtils.isEmpty((Collection)param.getIncludeLabels()) && CollectionUtils.isEmpty(includePersonIds)) {
|
||||
return new ArrayList<IsImageStoreAssociated>();
|
||||
}
|
||||
ArrayList<IsImageStoreAssociated> imageStoreAssociatedList = new ArrayList<IsImageStoreAssociated>();
|
||||
if (CpImageStoreMatchPatternEnum.getByCode((String)param.getMatchPattern()) != null) {
|
||||
imageStoreAssociatedList.add(this.getAssociated(param.getMatchPattern(), time, context.getUser().getCaller(), imageStoreId, null, (Integer)4));
|
||||
} else {
|
||||
imageStoreAssociatedList.add(this.getAssociated(CpImageStoreMatchPatternEnum.MERGE.getCode(), time, context.getUser().getCaller(), imageStoreId, null, (Integer)4));
|
||||
}
|
||||
AssociatedParam imageStoreAssociatedParam = new AssociatedParam();
|
||||
imageStoreAssociatedParam.setObjectId(imageStoreId);
|
||||
imageStoreAssociatedParam.setExpiryBeginDate(param.getExpiryBeginDate());
|
||||
imageStoreAssociatedParam.setExpiryEndDate(param.getExpiryEndDate());
|
||||
imageStoreAssociatedParam.setValidDateCron(param.getValidDateCron());
|
||||
imageStoreAssociatedList.add(this.getAssociated(imageStoreAssociatedParam, time, context.getUser().getCaller(), imageStoreId, (Integer)0, (Integer)5));
|
||||
if (!CollectionUtils.isEmpty((Collection)param.getIncludeOrganizations())) {
|
||||
if (this.imgStoreOrganizationMapper.getOrgByIds(param.getIncludeOrganizations(), businessId).size() != param.getIncludeOrganizations().size()) {
|
||||
throw new ServiceException("53013513", this.getMessage("53013513"));
|
||||
}
|
||||
for (Object objectId : param.getIncludeOrganizations()) {
|
||||
imageStoreAssociatedList.add(this.getAssociated((String)objectId, time, context.getUser().getCaller(), imageStoreId, (Integer)0, (Integer)1));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)param.getIncludeLabels())) {
|
||||
if (this.imgStoreLabelMapper.getLabelByIds(param.getIncludeLabels(), businessId).size() != param.getIncludeLabels().size()) {
|
||||
throw new ServiceException("53013514", this.getMessage("53013514"));
|
||||
}
|
||||
for (Object objectId : param.getIncludeLabels()) {
|
||||
imageStoreAssociatedList.add(this.getAssociated((String)objectId, time, context.getUser().getCaller(), imageStoreId, (Integer)0, (Integer)2));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(includePersonIds)) {
|
||||
ImgStorePersonQueryDto personQuery = new ImgStorePersonQueryDto();
|
||||
personQuery.setIds(includePersonIds);
|
||||
personQuery.setBusinessId(businessId);
|
||||
personQuery.setIsDel(DelStatusEnum.NORAML.getCode());
|
||||
if (this.personMapper.gets(personQuery).size() != includePersonIds.size()) {
|
||||
throw new ServiceException("53013515", this.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(this.getAssociated(associatedParam, time, context.getUser().getCaller(), imageStoreId, (Integer)0, (Integer)3));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)param.getExcludeLabels())) {
|
||||
if (this.imgStoreLabelMapper.getLabelByIds(param.getExcludeLabels(), businessId).size() != param.getExcludeLabels().size()) {
|
||||
throw new ServiceException("53013516", this.getMessage("53013516"));
|
||||
}
|
||||
for (Object objectId : param.getExcludeLabels()) {
|
||||
imageStoreAssociatedList.add(this.getAssociated((String)objectId, time, context.getUser().getCaller(), imageStoreId, (Integer)1, (Integer)2));
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection) param.getExcludePersons())) {
|
||||
ImgStorePersonQueryDto excludePersonQuery = new ImgStorePersonQueryDto();
|
||||
excludePersonQuery.setIds((Collection) param.getExcludePersons());
|
||||
excludePersonQuery.setBusinessId(businessId);
|
||||
excludePersonQuery.setIsDel(DelStatusEnum.NORAML.getCode());
|
||||
if (this.personMapper.gets(excludePersonQuery).size() != param.getExcludePersons().size()) {
|
||||
throw new ServiceException("53013517", this.getMessage("53013517"));
|
||||
}
|
||||
for (String objectId : param.getExcludePersons()) {
|
||||
imageStoreAssociatedList.add(this.getAssociated(objectId, time, context.getUser().getCaller(), imageStoreId, (Integer)1, (Integer)3));
|
||||
}
|
||||
}
|
||||
return imageStoreAssociatedList;
|
||||
}
|
||||
|
||||
private String getBusinessName(String businessId) throws ServiceException {
|
||||
GeneralQueryBusinessParam generalQueryBusinessParam = new GeneralQueryBusinessParam();
|
||||
generalQueryBusinessParam.setId(businessId);
|
||||
CloudwalkResult cloudwalkResult = this.acBusinessService.generalQuery(generalQueryBusinessParam);
|
||||
if (cloudwalkResult == null) {
|
||||
throw new ServiceException("53013535", this.getMessage("53013535"));
|
||||
}
|
||||
if (!cloudwalkResult.isSuccess()) {
|
||||
throw new ServiceException(cloudwalkResult.getCode(), cloudwalkResult.getMessage());
|
||||
}
|
||||
if (cloudwalkResult.getData() != null && ((List)cloudwalkResult.getData()).size() > 0) {
|
||||
return ((AcBusinessDTO)((List)cloudwalkResult.getData()).get(0)).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getSourceApplicationName(String sourceApplicationId) throws ServiceException {
|
||||
if (StringUtils.isEmpty((CharSequence)sourceApplicationId)) {
|
||||
return null;
|
||||
}
|
||||
ApplicationBasicParam applicationBasicParam = new ApplicationBasicParam();
|
||||
applicationBasicParam.setIds(Arrays.asList(sourceApplicationId));
|
||||
CloudwalkResult cloudwalkResult = this.applicationService.gets(applicationBasicParam);
|
||||
if (cloudwalkResult == null) {
|
||||
throw new ServiceException("53013547", this.getMessage("53013547"));
|
||||
}
|
||||
if (!cloudwalkResult.isSuccess()) {
|
||||
throw new ServiceException(cloudwalkResult.getCode(), cloudwalkResult.getMessage());
|
||||
}
|
||||
if (cloudwalkResult.getData() != null && ((List)cloudwalkResult.getData()).size() > 0) {
|
||||
return ((ApplicationResult)((List)cloudwalkResult.getData()).get(0)).getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void checkExistAndStatus(String iamgeStoreId) throws ServiceException {
|
||||
AgImageStoreQueryParam queryParam = new AgImageStoreQueryParam();
|
||||
queryParam.setId(iamgeStoreId);
|
||||
CloudwalkResult query = this.agImageStoreService.query(queryParam);
|
||||
if (!query.isSuccess()) {
|
||||
throw new ServiceException(query.getCode(), query.getMessage());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)((Collection)query.getData()))) {
|
||||
throw new ServiceException("53013502", this.getMessage("53013502"));
|
||||
}
|
||||
if (SyncStatusEnum.SYNC_ING.getCode().equals(((AgImageStoreResult)((List)query.getData()).get(0)).getStatus())) {
|
||||
throw new ServiceException("53013512", this.getMessage("53013512"));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> getBusinessNameMap() throws ServiceException {
|
||||
CloudwalkResult listCloudwalkResult = this.acBusinessService.generalQuery(new GeneralQueryBusinessParam());
|
||||
if (!listCloudwalkResult.isSuccess()) {
|
||||
throw new ServiceException(listCloudwalkResult.getCode(), listCloudwalkResult.getMessage());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)((Collection)listCloudwalkResult.getData()))) {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
return Collections3.extractToMap((Collection)((Collection)listCloudwalkResult.getData()), (String)"id", (String)"name");
|
||||
}
|
||||
|
||||
private Map<String, String> getSourceApplicationNameMap(String businessId) throws ServiceException {
|
||||
ApplicationQueryParam param = new ApplicationQueryParam();
|
||||
param.setBusinessId(businessId);
|
||||
param.setStatus(CommonStatusEnum.ENABLE.getCode());
|
||||
CloudwalkResult listCloudwalkResult = this.applicationService.query(param);
|
||||
if (!listCloudwalkResult.isSuccess()) {
|
||||
throw new ServiceException(listCloudwalkResult.getCode(), listCloudwalkResult.getMessage());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)((Collection)listCloudwalkResult.getData()))) {
|
||||
return new HashMap<String, String>();
|
||||
}
|
||||
return Collections3.extractToMap((Collection)((Collection)listCloudwalkResult.getData()), (String)"id", (String)"name");
|
||||
}
|
||||
|
||||
private void getAssociated(ImageStoreDetailResult result) {
|
||||
GetsImageStoreAssociatedDTO get = new GetsImageStoreAssociatedDTO();
|
||||
get.setImageStoreId(result.getId());
|
||||
List<IsImageStoreAssociated> associateds =
|
||||
(List<IsImageStoreAssociated>) (List) this.isImageStoreAssociatedMapper.gets(get);
|
||||
String matchPattern = null;
|
||||
List<String> includeLabelIds = new ArrayList<String>();
|
||||
List<String> includeOrganizationIds = new ArrayList<String>();
|
||||
List<String> includePersonIds = new ArrayList<String>();
|
||||
Map<String, AssociatedResult> includePersonMap = new HashMap<String, AssociatedResult>();
|
||||
List<String> excludeLabelIds = new ArrayList<String>();
|
||||
List<String> excludePersonIds = new ArrayList<String>();
|
||||
String businessId = result.getBusinessId();
|
||||
for (IsImageStoreAssociated associated : associateds) {
|
||||
if (4 == associated.getAssociatedObjectIdType()) {
|
||||
matchPattern = associated.getAssociatedObjectId();
|
||||
continue;
|
||||
}
|
||||
if (0 == associated.getAssociatedAction()) {
|
||||
if (1 == associated.getAssociatedObjectIdType()) {
|
||||
includeOrganizationIds.add(associated.getAssociatedObjectId());
|
||||
continue;
|
||||
}
|
||||
if (2 == associated.getAssociatedObjectIdType()) {
|
||||
includeLabelIds.add(associated.getAssociatedObjectId());
|
||||
continue;
|
||||
}
|
||||
if (3 == associated.getAssociatedObjectIdType()) {
|
||||
includePersonIds.add(associated.getAssociatedObjectId());
|
||||
AssociatedResult associatedResult = new AssociatedResult();
|
||||
BeanCopyUtils.copyProperties((Object)associated, (Object)associatedResult);
|
||||
associatedResult.setObjectId(associated.getAssociatedObjectId());
|
||||
includePersonMap.put(associated.getAssociatedObjectId(), associatedResult);
|
||||
continue;
|
||||
}
|
||||
if (5 != associated.getAssociatedObjectIdType()) continue;
|
||||
result.setExpiryBeginDate(associated.getExpiryBeginDate());
|
||||
result.setExpiryEndDate(associated.getExpiryEndDate());
|
||||
result.setValidDateCron(JsonUtils.toStrList((String)associated.getValidDateCron()));
|
||||
continue;
|
||||
}
|
||||
if (1 != associated.getAssociatedAction()) continue;
|
||||
if (2 == associated.getAssociatedObjectIdType()) {
|
||||
excludeLabelIds.add(associated.getAssociatedObjectId());
|
||||
continue;
|
||||
}
|
||||
if (3 != associated.getAssociatedObjectIdType()) continue;
|
||||
excludePersonIds.add(associated.getAssociatedObjectId());
|
||||
}
|
||||
result.setMatchPattern(matchPattern);
|
||||
if (!CollectionUtils.isEmpty(includeLabelIds)) {
|
||||
result.setIncludeLabels(BeanCopyUtils.copy((Collection)this.imgStoreLabelMapper.getLabelByIds(includeLabelIds, businessId), LabelResult.class));
|
||||
} else {
|
||||
result.setIncludeLabels(new ArrayList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(includeOrganizationIds)) {
|
||||
result.setIncludeOrganizations(BeanCopyUtils.copy((Collection)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<ImgStorePersonResult>();
|
||||
personList.forEach(imgStorePerson -> {
|
||||
ImgStorePersonResult imgStorePersonResult = new ImgStorePersonResult();
|
||||
BeanCopyUtils.copyProperties((Object)imgStorePerson, (Object)imgStorePersonResult);
|
||||
AssociatedResult associatedResult = (AssociatedResult)includePersonMap.get(imgStorePerson.getId());
|
||||
BeanCopyUtils.copyProperties((Object)associatedResult, (Object)imgStorePersonResult);
|
||||
imgStorePersonResult.setValidDateCron(JsonUtils.toStrList((String)associatedResult.getValidDateCron()));
|
||||
includePersons.add(imgStorePersonResult);
|
||||
});
|
||||
result.setIncludePersons(includePersons);
|
||||
} else {
|
||||
result.setIncludePersons(new ArrayList());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(excludeLabelIds)) {
|
||||
result.setExcludeLabels(BeanCopyUtils.copy((Collection)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((Collection)this.personMapper.gets(getDTO), ImgStorePersonResult.class));
|
||||
} else {
|
||||
result.setExcludePersons(new ArrayList());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleQueryParam(QueryImageStoreParam queryParam) {
|
||||
List imageStoreIds;
|
||||
if (StringUtils.isNotBlank((CharSequence)queryParam.getOrgId()) || !CollectionUtils.isEmpty((Collection)queryParam.getOrgIds())) {
|
||||
List orgImageStoreList = this.organizationImageStoreMapper.query((OrganizationImageStoreQueryDTO)BeanCopyUtils.copyProperties((Object)queryParam, OrganizationImageStoreQueryDTO.class));
|
||||
GetsImageStoreAssociatedDTO orgParam = new GetsImageStoreAssociatedDTO();
|
||||
orgParam.setAssociatedObjectIdType(Integer.valueOf(1));
|
||||
ArrayList<String> orgIds = new ArrayList<String>(500);
|
||||
if (StringUtils.isNotBlank((CharSequence)queryParam.getOrgId())) {
|
||||
orgIds.add(queryParam.getOrgId());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)queryParam.getOrgIds())) {
|
||||
orgIds.addAll(queryParam.getOrgIds());
|
||||
}
|
||||
orgParam.setAssociatedObjectIds(orgIds);
|
||||
List orgResultList = this.isImageStoreAssociatedMapper.gets(orgParam);
|
||||
if (CollectionUtils.isEmpty((Collection)orgImageStoreList) && CollectionUtils.isEmpty((Collection)orgResultList)) {
|
||||
return true;
|
||||
}
|
||||
List imageStoreIds2 = Collections3.extractToList((Collection)orgImageStoreList, (String)"imageStoreId");
|
||||
imageStoreIds2.addAll(Collections3.extractToList((Collection)orgResultList, (String)"imageStoreId"));
|
||||
if (StringUtils.isNotBlank((CharSequence)queryParam.getId())) {
|
||||
if (!imageStoreIds2.contains(queryParam.getId())) {
|
||||
return true;
|
||||
}
|
||||
} else if (!CollectionUtils.isEmpty((Collection)queryParam.getIds())) {
|
||||
imageStoreIds2.retainAll(queryParam.getIds());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)imageStoreIds2)) {
|
||||
return true;
|
||||
}
|
||||
queryParam.setIds(imageStoreIds2);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)queryParam.getPersonIds())) {
|
||||
QueryGroupPersonDTO queryGroupPersonDTO = (QueryGroupPersonDTO)BeanCopyUtils.copyProperties((Object)queryParam, QueryGroupPersonDTO.class);
|
||||
queryGroupPersonDTO.setIsDel(DelStatusEnum.NORAML.getCode());
|
||||
List queryResult = this.groupPersonRefMapper.query(queryGroupPersonDTO);
|
||||
if (CollectionUtils.isEmpty((Collection)queryResult)) {
|
||||
return true;
|
||||
}
|
||||
imageStoreIds = Collections3.extractToList((Collection)queryResult, (String)"imageStoreId");
|
||||
if (StringUtils.isNotBlank((CharSequence)queryParam.getId())) {
|
||||
if (!imageStoreIds.contains(queryParam.getId())) {
|
||||
return true;
|
||||
}
|
||||
} else if (!CollectionUtils.isEmpty((Collection)queryParam.getIds())) {
|
||||
imageStoreIds.retainAll(queryParam.getIds());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)imageStoreIds)) {
|
||||
return true;
|
||||
}
|
||||
queryParam.setIds(imageStoreIds);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)queryParam.getLabelIds())) {
|
||||
GetsImageStoreAssociatedDTO labelParam = new GetsImageStoreAssociatedDTO();
|
||||
labelParam.setAssociatedObjectIdType(Integer.valueOf(2));
|
||||
labelParam.setAssociatedObjectIds((Collection)queryParam.getLabelIds());
|
||||
List labelResultList = this.isImageStoreAssociatedMapper.gets(labelParam);
|
||||
if (CollectionUtils.isEmpty((Collection)labelResultList)) {
|
||||
return true;
|
||||
}
|
||||
imageStoreIds = Collections3.extractToList((Collection)labelResultList, (String)"imageStoreId");
|
||||
if (StringUtils.isNotBlank((CharSequence)queryParam.getId())) {
|
||||
if (!imageStoreIds.contains(queryParam.getId())) {
|
||||
return true;
|
||||
}
|
||||
} else if (!CollectionUtils.isEmpty((Collection)queryParam.getIds())) {
|
||||
imageStoreIds.retainAll(queryParam.getIds());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)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<ImageStoreResult>();
|
||||
}
|
||||
List<String> imageIds = agDatas.stream().map(AgImageStoreResult::getId).collect(Collectors.toList());
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<ImageStoreCountDTO> countByImageStoreIds =
|
||||
new ArrayList<ImageStoreCountDTO>(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("\u56fe\u5e93\u5206\u9875\u67e5\u8be2\u8017\u65f6:[{}],searchSize:[{}]", (Object)(endTime - startTime), (Object)this.searchSize);
|
||||
Map<String, Integer> countMap =
|
||||
countByImageStoreIds.stream()
|
||||
.filter(imageStoreCountDTO -> null != imageStoreCountDTO)
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
ImageStoreCountDTO::getId,
|
||||
ImageStoreCountDTO::getCount,
|
||||
(k1, k2) -> k1));
|
||||
Map<String, String> businessNameMap = this.getBusinessNameMap();
|
||||
Map<String, String> sourceApplicationNameMap = this.getSourceApplicationNameMap(businessId);
|
||||
List<ImageStoreResult> resultList = new ArrayList<ImageStoreResult>(agDatas.size());
|
||||
for (AgImageStoreResult agData : agDatas) {
|
||||
ImageStoreResult temp = (ImageStoreResult)BeanCopyUtils.copyProperties((Object)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));
|
||||
this.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<PageImageStoreResult>();
|
||||
}
|
||||
List<String> imageIds = agDatas.stream().map(AgImageStoreResult::getId).collect(Collectors.toList());
|
||||
long startTime = System.currentTimeMillis();
|
||||
List<ImageStoreCountDTO> countByImageStoreIds =
|
||||
new ArrayList<ImageStoreCountDTO>(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("\u56fe\u5e93\u5206\u9875\u67e5\u8be2\u8017\u65f6:[{}],searchSize:[{}]", (Object)(endTime - startTime), (Object)this.searchSize);
|
||||
Map<String, Integer> countMap =
|
||||
countByImageStoreIds.stream()
|
||||
.filter(imageStoreCountDTO -> null != imageStoreCountDTO)
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
ImageStoreCountDTO::getId,
|
||||
ImageStoreCountDTO::getCount,
|
||||
(k1, k2) -> k1));
|
||||
Map<String, String> businessNameMap = this.getBusinessNameMap();
|
||||
Map<String, String> sourceApplicationNameMap = this.getSourceApplicationNameMap(businessId);
|
||||
List<PageImageStoreResult> resultList = new ArrayList<PageImageStoreResult>(agDatas.size());
|
||||
for (AgImageStoreResult agData : agDatas) {
|
||||
PageImageStoreResult temp = (PageImageStoreResult)BeanCopyUtils.copyProperties((Object)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 countByImageStoreIds = this.groupPersonRefMapper.getCountByImageStoreIds((List)Lists.newArrayList((Object[])new String[]{id}));
|
||||
if (CollectionUtils.isEmpty((Collection)countByImageStoreIds) || countByImageStoreIds.get(0) == null) {
|
||||
return 0;
|
||||
}
|
||||
return ((ImageStoreCountDTO)countByImageStoreIds.get(0)).getCount();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user