mirror of
https://github.com/hpd840321/starRiverProperty.git
synced 2026-06-09 08:20:31 +08:00
feat: add service config templates and extraction script
Former-commit-id: 1de24b7eb79676d1aba9d799a58c5a753290cf52
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>cn.cloudwalk.ninca</groupId>
|
||||
<artifactId>ninca-crk-from-lib-reactor</artifactId>
|
||||
<version>2.9.1_210630-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<artifactId>ninca-crk-access-control-service</artifactId>
|
||||
<name>ninca-crk-access-control-service</name>
|
||||
<description>CFR from ninca-crk-access-control-service-2.9.1_210630-SNAPSHOT.jar (embedded pom: none)</description>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.ninca</groupId>
|
||||
<artifactId>ninca-crk-access-control-interface</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.ninca</groupId>
|
||||
<artifactId>ninca-crk-access-control-biz</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.ninca</groupId>
|
||||
<artifactId>ninca-crk-access-control-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.intelligent</groupId>
|
||||
<artifactId>intelligent-cwoscomponent-interface</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.cloud</groupId>
|
||||
<artifactId>cloudwalk-common-result</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-tx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.ninca</groupId>
|
||||
<artifactId>ninca-crk-portal-resource-stubs</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.openfeign</groupId>
|
||||
<artifactId>feign-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.cloudwalk.intelligent</groupId>
|
||||
<artifactId>davinci-manager-storage</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.cloud.context.CloudwalkSessionContextHolder
|
||||
* cn.cloudwalk.cloud.context.CloudwalkSessionObject
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* feign.RequestInterceptor
|
||||
* feign.RequestTemplate
|
||||
* javax.servlet.http.HttpServletRequest
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.context.annotation.Configuration
|
||||
* org.springframework.web.context.request.RequestContextHolder
|
||||
* org.springframework.web.context.request.ServletRequestAttributes
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol;
|
||||
|
||||
import cn.cloudwalk.cloud.context.CloudwalkSessionContextHolder;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkSessionObject;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import feign.RequestInterceptor;
|
||||
import feign.RequestTemplate;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
@Configuration
|
||||
public class AcsFeignConfiguration
|
||||
implements RequestInterceptor {
|
||||
protected final Logger logger = LoggerFactory.getLogger(AcsFeignConfiguration.class);
|
||||
@Autowired
|
||||
private CloudwalkSessionContextHolder cloudwalkSessionContextHolder;
|
||||
|
||||
public void apply(RequestTemplate requestTemplate) {
|
||||
Map map = FeignThreadLocalUtil.get();
|
||||
if (map != null && !map.isEmpty()) {
|
||||
requestTemplate.header("platformuserid", new String[]{(String)map.get("platformuserid")});
|
||||
requestTemplate.header("loginid", new String[]{(String)map.get("loginid")});
|
||||
requestTemplate.header("businessid", new String[]{(String)map.get("businessid")});
|
||||
requestTemplate.header("username", new String[]{(String)map.get("username")});
|
||||
requestTemplate.header("applicationid", new String[]{(String)map.get("applicationid")});
|
||||
requestTemplate.header("authorization", new String[]{(String)map.get("authorization")});
|
||||
this.logger.info("feign\u8c03\u7528\u914d\u7f6eheader\u53c2\u6570, businessId={}, threadId={}", requestTemplate.headers().get("businessid"), (Object)Thread.currentThread().getId());
|
||||
} else {
|
||||
Map headerMap = requestTemplate.headers();
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
|
||||
if (null != attributes) {
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
if (!headerMap.containsKey("platformuserid")) {
|
||||
requestTemplate.header("platformuserid", new String[]{request.getHeader("platformuserid")});
|
||||
}
|
||||
if (!headerMap.containsKey("loginid")) {
|
||||
requestTemplate.header("loginid", new String[]{request.getHeader("loginid")});
|
||||
}
|
||||
if (!headerMap.containsKey("businessid")) {
|
||||
requestTemplate.header("businessid", new String[]{request.getHeader("businessid")});
|
||||
}
|
||||
if (!headerMap.containsKey("username")) {
|
||||
requestTemplate.header("username", new String[]{request.getHeader("username")});
|
||||
}
|
||||
if (!headerMap.containsKey("applicationid")) {
|
||||
requestTemplate.header("applicationid", new String[]{request.getHeader("applicationid")});
|
||||
}
|
||||
if (!headerMap.containsKey("authorization")) {
|
||||
requestTemplate.header("authorization", new String[]{request.getHeader("authorization")});
|
||||
}
|
||||
CloudwalkSessionObject session = this.cloudwalkSessionContextHolder.getSession();
|
||||
if (StringUtils.isBlank((String)request.getHeader("businessid")) && session != null) {
|
||||
requestTemplate.header("businessid", new String[]{session.getCompany().getCompanyId()});
|
||||
}
|
||||
if (StringUtils.isBlank((String)request.getHeader("applicationid")) && session != null) {
|
||||
requestTemplate.header("applicationid", new String[]{session.getApplicationId()});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+447
@@ -0,0 +1,447 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsEvacuateRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.EntranceGuardControlParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.EntranceGuardControlResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsOperateRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsSwitchParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.service.AcsSwitchService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseTimes
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordPageDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsGroupSwitchEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsSwitchEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsUrgentDeviceGroupStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSON
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.acsswitch;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsEvacuateRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.EntranceGuardControlParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.EntranceGuardControlResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsOperateRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsSwitchParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.service.AcsSwitchService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordPageDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsGroupSwitchEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsSwitchEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsUrgentDeviceGroupStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsSwitchServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsSwitchService {
|
||||
@Autowired
|
||||
private DeviceNotifyService deviceNotifyService;
|
||||
@Autowired
|
||||
private AcsUrgentDeviceManager acsUrgentDeviceManager;
|
||||
@Autowired
|
||||
private AcsDeviceService acsDeviceService;
|
||||
@Autowired
|
||||
private AcsOperateRecordManager acsOperateRecordManager;
|
||||
@Autowired
|
||||
private AcsUrgentGroupDeviceManager acsUrgentGroupDeviceManager;
|
||||
@Autowired
|
||||
private AcsUrgentDeviceGroupManager acsUrgentDeviceGroupManager;
|
||||
@Autowired
|
||||
private AcsEvacuateRecordManager acsEvacuateRecordManager;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> on(AcsSwitchParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
return this.notify(param.getDeviceId(), AcsSwitchEnum.ON, param.getOperateType(), param.getOperateName(), context);
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> recovery(CloudwalkCallContext context) throws ServiceException {
|
||||
List<String> deviceIds = this.getUrgentDeviceIds(context);
|
||||
this.batchNotify(deviceIds, AcsSwitchEnum.ALWAYS_OFF, context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> alwaysOn(CloudwalkCallContext context) throws ServiceException {
|
||||
List<String> deviceIds = this.getUrgentDeviceIds(context);
|
||||
this.batchNotify(deviceIds, AcsSwitchEnum.ALWAYS_ON, context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void batchNotify(List<String> deviceIds, AcsSwitchEnum switchEnum, CloudwalkCallContext context) {
|
||||
if (CollectionUtils.isNotEmpty(deviceIds)) {
|
||||
for (String deviceId : deviceIds) {
|
||||
try {
|
||||
this.notify(deviceId, switchEnum, null, null, context);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u4e0b\u53d1\u6307\u4ee4\u5f02\u5e38\uff0c\u539f\u56e0\uff1a{}", (Object)e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> groupOn(AcsSwitchParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u6267\u884c\u7d27\u6025\u758f\u6563\u5165\u53c2\uff1aAcsSwitchParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
List<AcsUrgentGroupDeviceResultDTO> result = this.getDeviceRef(param, context);
|
||||
if (CollectionUtils.isEmpty(result)) {
|
||||
return CloudwalkResult.fail((String)"76260141", (String)this.getMessage("76260141"));
|
||||
}
|
||||
List<String> deviceIds = result.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
this.batchNotify(deviceIds, AcsSwitchEnum.ALWAYS_ON, context);
|
||||
List<String> groupIds = result.stream().map(AcsUrgentGroupDeviceResultDTO::getGroupId).distinct().collect(Collectors.toList());
|
||||
Map<String, List<AcsUrgentGroupDeviceResultDTO>> map = result.stream().collect(Collectors.groupingBy(AcsUrgentGroupDeviceResultDTO::getGroupId));
|
||||
List<AcsUrgentDeviceGroupResultDTO> groupResultList = this.getGroupByIds(groupIds, context);
|
||||
this.addEvacuateRecord(groupResultList, context, map);
|
||||
this.editGroupStatus(groupIds, AcsUrgentDeviceGroupStatusEnum.EVACUATING.getCode(), context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u7d27\u6025\u758f\u6563\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7d27\u6025\u758f\u6563\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void addEvacuateRecord(List<AcsUrgentDeviceGroupResultDTO> groupResultList, CloudwalkCallContext context, Map<String, List<AcsUrgentGroupDeviceResultDTO>> map) throws ServiceException, DataAccessException {
|
||||
ArrayList<AcsEvacuateRecordAddDTO> list = new ArrayList<AcsEvacuateRecordAddDTO>();
|
||||
for (AcsUrgentDeviceGroupResultDTO groupResult : groupResultList) {
|
||||
this.logger.info("\u589e\u52a0\u758f\u6563\u8bb0\u5f55");
|
||||
if (groupResult.getGroupStatus().equals(AcsUrgentDeviceGroupStatusEnum.EVACUATING.getCode())) continue;
|
||||
AcsEvacuateRecordAddDTO evacuateRecordAddDTO = new AcsEvacuateRecordAddDTO();
|
||||
evacuateRecordAddDTO.setId(this.genUUID());
|
||||
evacuateRecordAddDTO.setGroupId(groupResult.getId());
|
||||
evacuateRecordAddDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
evacuateRecordAddDTO.setGroupName(groupResult.getGroupName());
|
||||
evacuateRecordAddDTO.setCreateUserId(context.getUser().getCaller());
|
||||
evacuateRecordAddDTO.setCreateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
evacuateRecordAddDTO.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
evacuateRecordAddDTO.setLastUpdateUserId(context.getUser().getCaller());
|
||||
evacuateRecordAddDTO.setUserName(context.getUser().getCallerName());
|
||||
List<String> groupDeviceIds = map.get(groupResult.getId()).stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
List<String> deviceName = this.getDevice(groupDeviceIds, context);
|
||||
evacuateRecordAddDTO.setDeviceName(JSON.toJSON(deviceName).toString());
|
||||
list.add(evacuateRecordAddDTO);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
this.acsEvacuateRecordManager.batchAdd(list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Enabled force condition propagation
|
||||
* Lifted jumps to return sites
|
||||
*/
|
||||
private List<AcsUrgentGroupDeviceResultDTO> getDeviceRef(AcsSwitchParam param, CloudwalkCallContext context) throws ServiceException, DataAccessException {
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
AcsUrgentGroupDeviceQueryDTO dto = new AcsUrgentGroupDeviceQueryDTO();
|
||||
dto.setBusinessId(businessId);
|
||||
if (param.getSwitchOn() != null && param.getSwitchOn().equals(AcsGroupSwitchEnum.SWITCH.getCode())) {
|
||||
this.logger.info(AcsGroupSwitchEnum.SWITCH.getMessage());
|
||||
dto.setGroupId(param.getGroupId());
|
||||
return this.acsUrgentGroupDeviceManager.query(dto);
|
||||
} else if (param.getSwitchOn() != null && param.getSwitchOn().equals(AcsGroupSwitchEnum.DEFAULT.getCode())) {
|
||||
this.logger.info(AcsGroupSwitchEnum.DEFAULT.getMessage());
|
||||
AcsUrgentDeviceGroupQueryDTO queryDTO = new AcsUrgentDeviceGroupQueryDTO();
|
||||
queryDTO.setIsDefaultGroup(YesNoTypeEnum.Y.getCode());
|
||||
List res = this.acsUrgentDeviceGroupManager.query(queryDTO);
|
||||
if (res == null || res.isEmpty()) throw new ServiceException("76260140", this.getMessage("76260140"));
|
||||
List groupIds = res.stream().map(CloudwalkBaseIdentify::getId).collect(Collectors.toList());
|
||||
BeanCopyUtils.copyProperties((Object)context, (Object)dto);
|
||||
dto.setGroupIds(groupIds);
|
||||
return this.acsUrgentGroupDeviceManager.query(dto);
|
||||
} else {
|
||||
this.logger.info(AcsGroupSwitchEnum.ALL.getMessage());
|
||||
}
|
||||
return this.acsUrgentGroupDeviceManager.query(dto);
|
||||
}
|
||||
|
||||
private List<String> getDevice(List<String> deviceIds, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceQueryParam param = new DeviceQueryParam();
|
||||
param.setIds(deviceIds);
|
||||
CloudwalkResult deviceResults = this.deviceService.list(param, context);
|
||||
List<String> deviceName = ((List)deviceResults.getData()).stream().map(DeviceResult::getDeviceName).collect(Collectors.toList());
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> groupRecovery(AcsSwitchParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u6062\u590d\u5165\u53c2\uff1aAcsSwitchParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
List result;
|
||||
AcsUrgentGroupDeviceQueryDTO dto = new AcsUrgentGroupDeviceQueryDTO();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
if (param.getGroupId() != null) {
|
||||
dto.setGroupId(param.getGroupId());
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)(result = this.acsUrgentGroupDeviceManager.query(dto)))) {
|
||||
return CloudwalkResult.fail((String)"76260141", (String)this.getMessage("76260141"));
|
||||
}
|
||||
List<String> deviceIds = result.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
this.batchNotify(deviceIds, AcsSwitchEnum.ALWAYS_OFF, context);
|
||||
List<String> groupIds = result.stream().map(AcsUrgentGroupDeviceResultDTO::getGroupId).distinct().collect(Collectors.toList());
|
||||
List<AcsUrgentDeviceGroupResultDTO> groupResultList = this.getGroupByIds(groupIds, context);
|
||||
AcsEvacuateRecordQueryDTO queryDTO = new AcsEvacuateRecordQueryDTO();
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
List recordList = this.acsEvacuateRecordManager.query(queryDTO);
|
||||
Map<String, List<AcsEvacuateRecordResultDTO>> recordMap = recordList.stream().collect(Collectors.groupingBy(AcsEvacuateRecordResultDTO::getGroupId));
|
||||
for (AcsUrgentDeviceGroupResultDTO groupResult : groupResultList) {
|
||||
List<AcsEvacuateRecordResultDTO> records;
|
||||
if (!groupResult.getGroupStatus().equals(AcsUrgentDeviceGroupStatusEnum.EVACUATING.getCode()) || (records = recordMap.get(groupResult.getId())) == null || records.isEmpty()) continue;
|
||||
records.sort(Comparator.comparing(CloudwalkBaseTimes::getCreateTime).reversed());
|
||||
AcsEvacuateRecordEditDTO evacuateRecordEditDTO = new AcsEvacuateRecordEditDTO();
|
||||
this.logger.info("\u758f\u6563\u8bb0\u5f55\uff1arecord=[{}]", (Object)JSONObject.toJSONString((Object)records.get(0)));
|
||||
evacuateRecordEditDTO.setId(records.get(0).getId());
|
||||
evacuateRecordEditDTO.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
evacuateRecordEditDTO.setRecoveryTime(evacuateRecordEditDTO.getLastUpdateTime());
|
||||
evacuateRecordEditDTO.setLastUpdateUserId(context.getUser().getCaller());
|
||||
evacuateRecordEditDTO.setUserName(context.getUser().getCallerName());
|
||||
Long duration = evacuateRecordEditDTO.getRecoveryTime() - records.get(0).getCreateTime();
|
||||
evacuateRecordEditDTO.setDuration(DateUtils.formatTimeDuration((long)duration, (int)13));
|
||||
this.acsEvacuateRecordManager.update(evacuateRecordEditDTO);
|
||||
}
|
||||
this.editGroupStatus(groupIds, AcsUrgentDeviceGroupStatusEnum.NORMAL.getCode(), context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u7d27\u6025\u758f\u6563\u6062\u590d\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7d27\u6025\u758f\u6563\u6062\u590d\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsOperateRecordResultDTO>> pageRecord(AcsOperateRecordPageParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsOperateRecordPageDTO queryDTO = (AcsOperateRecordPageDTO)BeanCopyUtils.copyProperties((Object)param, AcsOperateRecordPageDTO.class);
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
if (!ObjectUtils.isEmpty((Object)param.getDeviceName())) {
|
||||
ArrayList deviceIds = new ArrayList();
|
||||
DeviceQueryParam queryParam = new DeviceQueryParam();
|
||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
queryParam.setDeviceName(param.getDeviceName());
|
||||
CloudwalkResult deviceList = this.deviceService.list(queryParam, context);
|
||||
((List)deviceList.getData()).forEach(device -> deviceIds.add(device.getId()));
|
||||
queryDTO.setDeviceIds(deviceIds);
|
||||
}
|
||||
CloudwalkPageAble pageRecord = this.acsOperateRecordManager.pageRecord(queryDTO, pageInfo);
|
||||
ArrayList<AcsOperateRecordResultDTO> returnList = new ArrayList<AcsOperateRecordResultDTO>();
|
||||
if (!CollectionUtils.isEmpty((Collection)pageRecord.getDatas())) {
|
||||
List list = (List)pageRecord.getDatas();
|
||||
ArrayList deviceIds = new ArrayList();
|
||||
list.forEach(record -> deviceIds.add(record.getDeviceId()));
|
||||
DeviceQueryParam queryParam = new DeviceQueryParam();
|
||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
queryParam.setIds(deviceIds);
|
||||
CloudwalkResult deviceList = this.deviceService.list(queryParam, context);
|
||||
HashMap deviceMap = new HashMap();
|
||||
((List)deviceList.getData()).forEach(device -> deviceMap.put(device.getId(), device));
|
||||
for (AcsOperateRecordResultDTO dto : list) {
|
||||
DeviceResult deviceResult = (DeviceResult)deviceMap.get(dto.getDeviceId());
|
||||
if (!ObjectUtils.isEmpty((Object)deviceResult)) {
|
||||
dto.setDeviceName(deviceResult.getDeviceName());
|
||||
}
|
||||
returnList.add(dto);
|
||||
}
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(returnList, pageInfo, pageRecord.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7acb\u5373\u5f00\u95e8\u8bb0\u5f55\u8be6\u60c5\u67e5\u8be2\u5931\u8d25,\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private void editGroupStatus(List<String> groupIds, Integer code, CloudwalkCallContext context) throws DataAccessException {
|
||||
for (String groupId : groupIds) {
|
||||
AcsUrgentDeviceGroupEditDTO editDTO = new AcsUrgentDeviceGroupEditDTO();
|
||||
editDTO.setId(groupId);
|
||||
editDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
editDTO.setGroupStatus(code);
|
||||
this.acsUrgentDeviceGroupManager.edit(editDTO);
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsUrgentDeviceGroupResultDTO> getGroupByIds(List<String> groupIds, CloudwalkCallContext context) throws DataAccessException {
|
||||
AcsUrgentDeviceGroupQueryDTO groupQueryDTO = new AcsUrgentDeviceGroupQueryDTO();
|
||||
groupQueryDTO.setIds(groupIds);
|
||||
groupQueryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
return this.acsUrgentDeviceGroupManager.query(groupQueryDTO);
|
||||
}
|
||||
|
||||
private List<String> getUrgentDeviceIds(CloudwalkCallContext context) throws ServiceException {
|
||||
AcsUrgentDeviceQueryDTO acsUrgentDeviceQueryDTO = new AcsUrgentDeviceQueryDTO();
|
||||
acsUrgentDeviceQueryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
List urgentDevices = this.acsUrgentDeviceManager.gets(acsUrgentDeviceQueryDTO);
|
||||
if (CollectionUtils.isNotEmpty((Collection)urgentDevices)) {
|
||||
return urgentDevices.stream().map(AcsUrgentDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u7d27\u6025\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> off(AcsSwitchParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
return this.notify(param.getDeviceId(), AcsSwitchEnum.OFF, null, null, context);
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> notify(String deviceId, AcsSwitchEnum switchEnum, String operateType, String operateName, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsDeviceDetailResult deviceDetail;
|
||||
AcsdeviceDetailQueryParam queryParam = new AcsdeviceDetailQueryParam();
|
||||
queryParam.setDeviceId(deviceId);
|
||||
CloudwalkResult deviceDetailResult = this.acsDeviceService.detail(queryParam, context);
|
||||
if (!deviceDetailResult.isSuccess() || (deviceDetail = (AcsDeviceDetailResult)deviceDetailResult.getData()) == null) {
|
||||
return CloudwalkResult.fail((String)"76260115", (String)this.getMessage("76260115"));
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty((Collection)deviceDetail.getSubDevices())) {
|
||||
StringBuilder errorMsg = new StringBuilder();
|
||||
errorMsg.append("\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u5931\u8d25\uff0c\u8bbe\u5907\u7f16\u7801\u4e3a\uff1a");
|
||||
Boolean isSuccess = Boolean.TRUE;
|
||||
for (AcsDeviceDetailResult acsDeviceDetailResult : deviceDetail.getSubDevices()) {
|
||||
this.saveOperateRecord(deviceId, context, acsDeviceDetailResult.getDeviceCode(), operateType, operateName);
|
||||
CloudwalkResult<EntranceGuardControlResult> notifyResult = this.deviceNotify(switchEnum, acsDeviceDetailResult.getDeviceCode());
|
||||
if (notifyResult.isSuccess()) continue;
|
||||
this.logger.error("\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u5931\u8d25\uff0c\u8bbe\u5907id=[{}], \u8bbe\u5907\u7f16\u7801=[{}], \u539f\u56e0=[{}]", new Object[]{acsDeviceDetailResult.getDeviceId(), acsDeviceDetailResult.getDeviceCode(), notifyResult.getMessage()});
|
||||
errorMsg.append(acsDeviceDetailResult.getDeviceCode());
|
||||
errorMsg.append(" ");
|
||||
isSuccess = Boolean.FALSE;
|
||||
}
|
||||
if (!isSuccess.booleanValue()) {
|
||||
return CloudwalkResult.fail((String)"76260200", (String)(this.getMessage("76260200") + "." + errorMsg.toString()));
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
this.saveOperateRecord(deviceId, context, deviceDetail.getDeviceCode(), operateType, operateName);
|
||||
CloudwalkResult<EntranceGuardControlResult> result = this.deviceNotify(switchEnum, deviceDetail.getDeviceCode());
|
||||
if (result.isSuccess()) {
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
return CloudwalkResult.fail((String)result.getCode(), (String)result.getMessage());
|
||||
}
|
||||
|
||||
private void saveOperateRecord(String deviceId, CloudwalkCallContext context, String deviceCode, String operateType, String operateName) {
|
||||
try {
|
||||
AcsOperateRecordAddDTO operateRecordAddDTO = new AcsOperateRecordAddDTO();
|
||||
BeanCopyUtils.copyProperties((CloudwalkBaseTimes)operateRecordAddDTO, (CloudwalkCallContext)context);
|
||||
if (StringUtils.isNotBlank((String)operateType) && AcsOperateTypeEnum.QRCODE_OPEN_DOOR.equals((Object)AcsOperateTypeEnum.getEnumByCode((String)operateType))) {
|
||||
operateRecordAddDTO.setOperateTypeCode(AcsOperateTypeEnum.QRCODE_OPEN_DOOR.getCode());
|
||||
operateRecordAddDTO.setOperateName(operateName);
|
||||
} else {
|
||||
operateRecordAddDTO.setOperateTypeCode(AcsOperateTypeEnum.REMOTE_OPEN_DOOR.getCode());
|
||||
operateRecordAddDTO.setOperateName(context.getUser().getCallerName());
|
||||
}
|
||||
operateRecordAddDTO.setId(this.genUUID());
|
||||
operateRecordAddDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
operateRecordAddDTO.setDeviceId(deviceId);
|
||||
operateRecordAddDTO.setDeviceCode(deviceCode);
|
||||
operateRecordAddDTO.setOperateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
operateRecordAddDTO.setStatus(AcsOperateStatusEnum.INIT.getCode());
|
||||
this.acsOperateRecordManager.add(operateRecordAddDTO);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u4fdd\u5b58\u95e8\u7981\u64cd\u4f5c\u8bb0\u5f55\u6570\u636e\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
}
|
||||
}
|
||||
|
||||
private CloudwalkResult<EntranceGuardControlResult> deviceNotify(AcsSwitchEnum switchEnum, String deviceCode) throws ServiceException {
|
||||
EntranceGuardControlParam notifyEntranceGuardControlParam = new EntranceGuardControlParam();
|
||||
notifyEntranceGuardControlParam.setDeviceId(deviceCode);
|
||||
notifyEntranceGuardControlParam.setLogId(this.genUUID());
|
||||
notifyEntranceGuardControlParam.setGuardSwitch(switchEnum.getCode());
|
||||
this.logger.info("\u5f00\u59cb\u4e0b\u53d1\u5f00\u5173\u95e8\u6307\u4ee4:{}", (Object)JSONObject.toJSONString((Object)notifyEntranceGuardControlParam));
|
||||
return this.deviceNotifyService.entranceGuardControl(notifyEntranceGuardControlParam);
|
||||
}
|
||||
}
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.service.SysettingAreaService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.cache.annotation.Cacheable
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.cacheable;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.service.SysettingAreaService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsAreaTreeCacheableService {
|
||||
@Autowired
|
||||
private SysettingAreaService sysettingAreaService;
|
||||
|
||||
@Cacheable(cacheNames={"ACS_AreaTreeCache"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_ACS_AREA_TREE_PREFIX + #param.businessId")
|
||||
public CloudwalkResult<List<AreaTreeResult>> tree(DeviceAreaTreeParam param, CloudwalkCallContext context) {
|
||||
return this.sysettingAreaService.tree(param, context);
|
||||
}
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceAttrManager
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrEditDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.cache.annotation.CacheEvict
|
||||
* org.springframework.cache.annotation.Cacheable
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.cacheable;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceAttrManager;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrEditDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceAttrCacheableService {
|
||||
@Autowired
|
||||
private AcsDeviceAttrManager acsDeviceAttrManager;
|
||||
|
||||
@Cacheable(cacheNames={"ACS_DeviceAttrsCache"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_ACS_DEVICE_ATTRS_PREFIX + #dto.deviceId")
|
||||
public List<AcsDeviceAttrResultDto> query(AcsDeviceAttrQueryDto dto) throws DataAccessException {
|
||||
AcsDeviceAttrQueryDto acsDeviceAttrQueryDto = new AcsDeviceAttrQueryDto();
|
||||
acsDeviceAttrQueryDto.setBusinessId(dto.getBusinessId());
|
||||
acsDeviceAttrQueryDto.setDeviceId(dto.getDeviceId());
|
||||
return this.acsDeviceAttrManager.query(acsDeviceAttrQueryDto);
|
||||
}
|
||||
|
||||
@CacheEvict(cacheNames={"ACS_DeviceAttrsCache"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_ACS_DEVICE_ATTRS_PREFIX + #dto.deviceId")
|
||||
public Integer insert(AcsDeviceAttrAddDto dto) throws DataAccessException {
|
||||
return this.acsDeviceAttrManager.insert(dto);
|
||||
}
|
||||
|
||||
@CacheEvict(cacheNames={"ACS_DeviceAttrsCache"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_ACS_DEVICE_ATTRS_PREFIX + #dto.deviceId")
|
||||
public Integer update(AcsDeviceAttrEditDto dto) throws DataAccessException {
|
||||
return this.acsDeviceAttrManager.update(dto);
|
||||
}
|
||||
}
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceTypeQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceTypeResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceTypeService
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.cacheable;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceTypeQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceTypeResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceTypeService;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceTypeCacheableService {
|
||||
private static final Logger log = LoggerFactory.getLogger(AcsDeviceTypeCacheableService.class);
|
||||
@Resource
|
||||
private DeviceTypeService deviceTypeService;
|
||||
|
||||
public CloudwalkResult<List<DeviceTypeResult>> get() throws ServiceException {
|
||||
CloudwalkResult result = this.deviceTypeService.get(new DeviceTypeQueryParam());
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("get result {}", (Object)JSONObject.toJSONString((Object)result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordStatisticsManager
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsByDay
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.cache.annotation.Cacheable
|
||||
* org.springframework.data.redis.core.RedisTemplate
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.cacheable;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordStatisticsManager;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsByDay;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsRecordStatisticsCacheableService {
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private AcsRecordStatisticsManager acsRecordStatisticsManager;
|
||||
|
||||
@Cacheable(cacheNames={"ACS_RecordStatisticsCache"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_ACS_RECORD_STATISTICS_PREFIX + #date.concat('_').concat(#businessId)")
|
||||
public List<AcsRecordStatisticsByDay> list(String date, String businessId) throws DataAccessException {
|
||||
Date startDay = DateUtils.customFormat((String)DateUtils.formatDate((Date)DateUtils.getDateSubDay((int)-6), (String)"yyyy-MM-dd"), (String)"yyyy-MM-dd");
|
||||
Date endDay = DateUtils.customFormat((String)DateUtils.parseDate((Date)new Date(), (String)"yyyy-MM-dd"), (String)"yyyy-MM-dd");
|
||||
AcsRecordStatisticsQueryDTO statisticsQueryDTO = new AcsRecordStatisticsQueryDTO();
|
||||
statisticsQueryDTO.setBusinessId(businessId);
|
||||
statisticsQueryDTO.setStartStatisticsDate(startDay);
|
||||
statisticsQueryDTO.setEndStatisticsDate(endDay);
|
||||
List recordStatisticsList = this.acsRecordStatisticsManager.query(statisticsQueryDTO);
|
||||
Map<String, AcsRecordStatisticsResultDTO> recordStatisticsMap = recordStatisticsList.stream().collect(Collectors.toMap(AcsRecordStatisticsResultDTO::statisticsDateString, recordStatistics -> recordStatistics));
|
||||
ArrayList<AcsRecordStatisticsByDay> recordStatisticsByDays = new ArrayList<AcsRecordStatisticsByDay>();
|
||||
for (int day = 0; day < 6; ++day) {
|
||||
long openDoorCount = 0L;
|
||||
long recogCount = 0L;
|
||||
Date queryDate = DateUtils.getDateSubDay((Date)startDay, (int)day);
|
||||
String queryDateString = DateUtils.parseDate((Date)queryDate, (String)"yyyy-MM-dd");
|
||||
Object openDoorCountObj = this.redisTemplate.opsForValue().get((Object)AcsCacheKeyUtil.getOpenDoorCountKey((String)queryDateString, (String)businessId));
|
||||
Object recogCountObj = this.redisTemplate.opsForValue().get((Object)AcsCacheKeyUtil.getRecogCountKey((String)queryDateString, (String)businessId));
|
||||
if (openDoorCountObj != null) {
|
||||
openDoorCount = Long.parseLong(openDoorCountObj.toString());
|
||||
} else if (recordStatisticsMap.containsKey(queryDateString)) {
|
||||
openDoorCount = recordStatisticsMap.get(queryDateString).getOpenDoorCount();
|
||||
}
|
||||
if (recogCountObj != null) {
|
||||
recogCount = Long.parseLong(recogCountObj.toString());
|
||||
} else if (recordStatisticsMap.containsKey(queryDateString)) {
|
||||
recogCount = recordStatisticsMap.get(queryDateString).getRecogCount();
|
||||
}
|
||||
AcsRecordStatisticsByDay acsRecordStatisticsByDay = new AcsRecordStatisticsByDay();
|
||||
acsRecordStatisticsByDay.setDays(queryDateString);
|
||||
acsRecordStatisticsByDay.setOpenDoorFlow(openDoorCount);
|
||||
acsRecordStatisticsByDay.setRecogFlow(recogCount);
|
||||
recordStatisticsByDays.add(acsRecordStatisticsByDay);
|
||||
}
|
||||
return recordStatisticsByDays;
|
||||
}
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.cloud.serial.UUIDSerial
|
||||
* cn.cloudwalk.cloud.utils.CloudwalkDateUtils
|
||||
* cn.cloudwalk.serial.code.AbstractGeneralCode
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.context.MessageSource
|
||||
* org.springframework.context.i18n.LocaleContextHolder
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.cloud.serial.UUIDSerial;
|
||||
import cn.cloudwalk.cloud.utils.CloudwalkDateUtils;
|
||||
import cn.cloudwalk.serial.code.AbstractGeneralCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
public class AbstractCloudwalkService {
|
||||
@Autowired
|
||||
protected DeviceService deviceService;
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private static final int GENGRAL_CODE_LENGTH = 8;
|
||||
@Autowired
|
||||
private MessageSource messageSource;
|
||||
@Autowired
|
||||
protected AbstractGeneralCode generalCode;
|
||||
@Autowired(required=false)
|
||||
private UUIDSerial uuidSerial;
|
||||
|
||||
public String getMessage(String code) {
|
||||
return this.messageSource.getMessage(code, null, "", LocaleContextHolder.getLocale());
|
||||
}
|
||||
|
||||
public String createGeneralCode() {
|
||||
return this.generalCode.generalCode(CloudwalkDateUtils.getDate8YMD(), Integer.valueOf(8));
|
||||
}
|
||||
|
||||
public String genUUID() {
|
||||
if (null != this.uuidSerial) {
|
||||
return this.uuidSerial.uuid();
|
||||
}
|
||||
return CloudwalkDateUtils.getUUID();
|
||||
}
|
||||
}
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService
|
||||
* cn.cloudwalk.client.resource.application.param.ApplicationQueryParam
|
||||
* cn.cloudwalk.client.resource.application.result.ApplicationResult
|
||||
* cn.cloudwalk.client.resource.application.service.ApplicationService
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* javax.annotation.Resource
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.cache.annotation.Cacheable
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService;
|
||||
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.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsApplicationServiceImpl
|
||||
implements AcsApplicationService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AcsApplicationServiceImpl.class);
|
||||
@Resource
|
||||
private ApplicationService applicationService;
|
||||
|
||||
@Cacheable(cacheNames={"ACS_Applicationids"}, key="T(cn.cloudwalk.biz.ninca.accesscontrol.cache.CacheOverrideConfig).CACHE_KEY_APPLICATION_IDS_PREFIX + #businessId")
|
||||
public String getApplicationId(String businessId) throws ServiceException {
|
||||
ApplicationQueryParam param = new ApplicationQueryParam();
|
||||
param.setBusinessId(businessId);
|
||||
param.setServiceCode("access-control");
|
||||
CloudwalkResult cloudwalkResult = this.applicationService.query(param);
|
||||
if (cloudwalkResult.isSuccess()) {
|
||||
if (CollectionUtils.isNotEmpty((Collection)((Collection)cloudwalkResult.getData()))) {
|
||||
return ((ApplicationResult)((List)cloudwalkResult.getData()).get(0)).getId();
|
||||
}
|
||||
logger.info("\u672a\u67e5\u5230applicationId");
|
||||
throw new ServiceException("76260005", "\u672a\u67e5\u5230applicationId");
|
||||
}
|
||||
logger.info("\u67e5\u8be2applicationId\u5931\u8d25");
|
||||
throw new ServiceException("76260006", "\u67e5\u8be2applicationId\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.task.listener.CommonJobListener
|
||||
* cn.cloudwalk.task.sdk.client.TaskExecClient
|
||||
* cn.cloudwalk.task.sdk.dto.JobDetailParam
|
||||
* cn.cloudwalk.task.sdk.dto.JobDetailResult
|
||||
* org.quartz.JobListener
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.boot.CommandLineRunner
|
||||
* org.springframework.stereotype.Component
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job;
|
||||
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.job.config.AcsJobProperties;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.job.config.JobSetting;
|
||||
import cn.cloudwalk.task.listener.CommonJobListener;
|
||||
import cn.cloudwalk.task.sdk.client.TaskExecClient;
|
||||
import cn.cloudwalk.task.sdk.dto.JobDetailParam;
|
||||
import cn.cloudwalk.task.sdk.dto.JobDetailResult;
|
||||
import java.util.Map;
|
||||
import org.quartz.JobListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AcsJobInit
|
||||
implements CommandLineRunner {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private static final String ERROR_STATE = "ERROR";
|
||||
@Autowired
|
||||
private TaskExecClient client;
|
||||
@Autowired
|
||||
private AcsJobProperties acsJobProperties;
|
||||
@Autowired
|
||||
private CommonJobListener jobListener;
|
||||
|
||||
public void run(String ... strings) throws Exception {
|
||||
Map<String, JobSetting> jobs = this.acsJobProperties.getJobs();
|
||||
if (CollectionUtils.isNotEmpty(jobs)) {
|
||||
this.logger.info("\u5f00\u59cb\u521d\u59cb\u5316\u5b9a\u65f6\u4efb\u52a1...");
|
||||
for (Map.Entry<String, JobSetting> entry : jobs.entrySet()) {
|
||||
JobDetailResult job;
|
||||
JobSetting setting = entry.getValue();
|
||||
JobDetailParam param = new JobDetailParam();
|
||||
param.setJobName(setting.getName());
|
||||
param.setJobGroup(setting.getGroup());
|
||||
if (setting.isDelete()) {
|
||||
try {
|
||||
this.client.removeJob(param);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.warn("delete job error.", (Throwable)e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
param.setClazz(Class.forName(setting.getExecutableClass()));
|
||||
param.setJobListener((JobListener)this.jobListener);
|
||||
param.setStartTime(Long.valueOf(System.currentTimeMillis()));
|
||||
param.setJobDescription(setting.getDescription());
|
||||
param.setRetry(Boolean.valueOf(true));
|
||||
param.setPriority(setting.getPriority());
|
||||
param.setExpression(setting.getCronExpression());
|
||||
if (setting.getDataMap() != null && setting.getDataMap().size() > 0) {
|
||||
param.setDataMap(setting.getDataMap());
|
||||
}
|
||||
if ((job = this.client.getJob(param)) == null) {
|
||||
this.client.addJob(param, true);
|
||||
this.logger.info("\u4efb\u52a1[{}] \u6dfb\u52a0\u6210\u529f.", (Object)param.getJobName());
|
||||
continue;
|
||||
}
|
||||
if (ERROR_STATE.equals(job.getState())) {
|
||||
this.logger.warn("\u4efb\u52a1[{}] \u72b6\u6001\u4e0d\u6b63\u786e\uff0c\u91cd\u65b0\u6dfb\u52a0...", (Object)param.getJobName());
|
||||
this.client.addJob(param, true);
|
||||
continue;
|
||||
}
|
||||
this.client.addListener(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.springframework.boot.context.properties.ConfigurationProperties
|
||||
* org.springframework.stereotype.Component
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.config;
|
||||
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.job.config.JobSetting;
|
||||
import java.util.Map;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix="cloudwalk.access-control.schedual")
|
||||
public class AcsJobProperties {
|
||||
private Map<String, JobSetting> jobs;
|
||||
|
||||
public Map<String, JobSetting> getJobs() {
|
||||
return this.jobs;
|
||||
}
|
||||
|
||||
public void setJobs(Map<String, JobSetting> jobs) {
|
||||
this.jobs = jobs;
|
||||
}
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class JobSetting {
|
||||
private String name;
|
||||
private String group;
|
||||
private String executableClass;
|
||||
private String description;
|
||||
private String cronExpression;
|
||||
private Integer priority;
|
||||
private HashMap<String, Object> dataMap;
|
||||
private boolean delete;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getGroup() {
|
||||
return this.group;
|
||||
}
|
||||
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public String getExecutableClass() {
|
||||
return this.executableClass;
|
||||
}
|
||||
|
||||
public void setExecutableClass(String executableClass) {
|
||||
this.executableClass = executableClass;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCronExpression() {
|
||||
return this.cronExpression;
|
||||
}
|
||||
|
||||
public void setCronExpression(String cronExpression) {
|
||||
this.cronExpression = cronExpression;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getDataMap() {
|
||||
return this.dataMap;
|
||||
}
|
||||
|
||||
public void setDataMap(HashMap<String, Object> dataMap) {
|
||||
this.dataMap = dataMap;
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return this.priority;
|
||||
}
|
||||
|
||||
public void setPriority(Integer priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public boolean isDelete() {
|
||||
return this.delete;
|
||||
}
|
||||
|
||||
public void setDelete(boolean delete) {
|
||||
this.delete = delete;
|
||||
}
|
||||
}
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.springframework.boot.context.properties.ConfigurationProperties
|
||||
* org.springframework.context.annotation.Configuration
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix="ninca.update.device.pool")
|
||||
public class UpdateDevicesPoolProperties {
|
||||
private int corePoolSize = 3;
|
||||
private int maxPoolSize = 5;
|
||||
private int keepAliveSeconds = 150;
|
||||
private int queueCapacity = 100;
|
||||
private boolean allowCoreThreadTimeOut = true;
|
||||
|
||||
public int getCorePoolSize() {
|
||||
return this.corePoolSize;
|
||||
}
|
||||
|
||||
public void setCorePoolSize(int corePoolSize) {
|
||||
this.corePoolSize = corePoolSize;
|
||||
}
|
||||
|
||||
public int getMaxPoolSize() {
|
||||
return this.maxPoolSize;
|
||||
}
|
||||
|
||||
public void setMaxPoolSize(int maxPoolSize) {
|
||||
this.maxPoolSize = maxPoolSize;
|
||||
}
|
||||
|
||||
public int getKeepAliveSeconds() {
|
||||
return this.keepAliveSeconds;
|
||||
}
|
||||
|
||||
public void setKeepAliveSeconds(int keepAliveSeconds) {
|
||||
this.keepAliveSeconds = keepAliveSeconds;
|
||||
}
|
||||
|
||||
public int getQueueCapacity() {
|
||||
return this.queueCapacity;
|
||||
}
|
||||
|
||||
public void setQueueCapacity(int queueCapacity) {
|
||||
this.queueCapacity = queueCapacity;
|
||||
}
|
||||
|
||||
public boolean isAllowCoreThreadTimeOut() {
|
||||
return this.allowCoreThreadTimeOut;
|
||||
}
|
||||
|
||||
public void setAllowCoreThreadTimeOut(boolean allowCoreThreadTimeOut) {
|
||||
this.allowCoreThreadTimeOut = allowCoreThreadTimeOut;
|
||||
}
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.context.annotation.Bean
|
||||
* org.springframework.context.annotation.Configuration
|
||||
* org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.config;
|
||||
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.job.config.UpdateDevicesPoolProperties;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
@Configuration
|
||||
public class UpdateDevicesTaskExecutor {
|
||||
@Autowired
|
||||
private UpdateDevicesPoolProperties updateDevicesPoolProperties;
|
||||
|
||||
@Bean(name={"updateDevicesExecutor"})
|
||||
public ThreadPoolTaskExecutor pictureRevisionTaskExecutor() {
|
||||
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
|
||||
threadPoolTaskExecutor.setCorePoolSize(this.updateDevicesPoolProperties.getCorePoolSize());
|
||||
threadPoolTaskExecutor.setAllowCoreThreadTimeOut(this.updateDevicesPoolProperties.isAllowCoreThreadTimeOut());
|
||||
threadPoolTaskExecutor.setMaxPoolSize(this.updateDevicesPoolProperties.getMaxPoolSize());
|
||||
threadPoolTaskExecutor.setQueueCapacity(this.updateDevicesPoolProperties.getQueueCapacity());
|
||||
threadPoolTaskExecutor.setThreadNamePrefix("update-devices-pool-");
|
||||
threadPoolTaskExecutor.setRejectedExecutionHandler((RejectedExecutionHandler)new ThreadPoolExecutor.AbortPolicy());
|
||||
threadPoolTaskExecutor.initialize();
|
||||
return threadPoolTaskExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.task.sdk.starter.job.AbstractJob
|
||||
* org.quartz.JobExecutionContext
|
||||
* org.quartz.JobExecutionException
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.executable;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.task.sdk.starter.job.AbstractJob;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class AcsRecordStatisticsByDayJob
|
||||
extends AbstractJob {
|
||||
private Logger logger = LoggerFactory.getLogger(((Object)((Object)this)).getClass());
|
||||
@Autowired
|
||||
private DoorOpenRecordService doorOpenRecordService;
|
||||
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
this.logger.info("\u6309\u65e5\u7edf\u8ba1\u95e8\u7981\u8bb0\u5f55 [AcsRecordStatisticsByDayJob] \u4efb\u52a1\u5f00\u59cb\u8fd0\u884c");
|
||||
CloudwalkResult result = this.doorOpenRecordService.statistics();
|
||||
Integer addCount = 0;
|
||||
if (result.isSuccess()) {
|
||||
addCount = (Integer)result.getData();
|
||||
}
|
||||
this.logger.info("\u6309\u65e5\u7edf\u8ba1\u95e8\u7981\u8bb0\u5f55 [AcsRecordStatisticsByDayJob] \u4efb\u52a1\u7ed3\u675f\u8fd0\u884c\uff0c\u6dfb\u52a0\u6761\u6570:[{}]", (Object)addCount);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u6309\u65e5\u7edf\u8ba1\u95e8\u7981\u8bb0\u5f55\u51fa\u73b0\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new JobExecutionException((Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService
|
||||
* cn.cloudwalk.task.sdk.starter.job.AbstractJob
|
||||
* org.quartz.JobExecutionContext
|
||||
* org.quartz.JobExecutionException
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.common.job.executable;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService;
|
||||
import cn.cloudwalk.task.sdk.starter.job.AbstractJob;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneOffset;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class UpdateRecogRecordOpenDoorTypeJob
|
||||
extends AbstractJob {
|
||||
private static final Logger log = LoggerFactory.getLogger(UpdateRecogRecordOpenDoorTypeJob.class);
|
||||
@Autowired
|
||||
private AcsOpenDoorRecordService acsDoorOpenRecordService;
|
||||
|
||||
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
||||
try {
|
||||
log.info("\u66f4\u65b0\u8bc6\u522b\u8bb0\u5f55\u5f00\u95e8\u7c7b\u578b\u5b57\u6bb5 [UpdateRecogRecordOpenDoorTypeJob] \u4efb\u52a1\u5f00\u59cb\u8fd0\u884c");
|
||||
LocalDateTime startDateTime = LocalDateTime.of(LocalDate.now(), LocalTime.MIN);
|
||||
long startTime = startDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
||||
int year = startDateTime.getYear();
|
||||
Integer count = this.acsDoorOpenRecordService.updateRecogOpenDoorType("it_acs_open_door_record_" + year, "it_acs_recog_record_" + year, Long.valueOf(startTime));
|
||||
log.info("\u66f4\u65b0\u8bc6\u522b\u8bb0\u5f55\u5f00\u95e8\u7c7b\u578b\u5b57\u6bb5 [UpdateRecogRecordOpenDoorTypeJob] \u4efb\u52a1\u7ed3\u675f\u8fd0\u884c\uff0c\u66f4\u65b0\u6761\u6570:[{}]", (Object)count);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("\u66f4\u65b0\u8bc6\u522b\u8bb0\u5f55\u5f00\u95e8\u7c7b\u578b\u5b57\u6bb5 [UpdateRecogRecordOpenDoorTypeJob]\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new JobExecutionException((Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+179
@@ -0,0 +1,179 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsApplicationSourceEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsApplicationSourceEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.cacheable.AcsAreaTreeCacheableService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class AbstractAcsDeviceService
|
||||
extends AbstractCloudwalkService {
|
||||
@Autowired
|
||||
protected AccessControlProperties accessControlProperties;
|
||||
@Autowired
|
||||
private AcsUrgentGroupDeviceManager acsUrgentGroupDeviceManager;
|
||||
@Resource
|
||||
private AcsAreaTreeCacheableService acsAreaTreeCacheableService;
|
||||
|
||||
protected DeviceResult getDevice(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setId(deviceId);
|
||||
CloudwalkResult deviceQueryResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (deviceQueryResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)((Collection)deviceQueryResult.getData()))) {
|
||||
return (DeviceResult)((List)deviceQueryResult.getData()).get(0);
|
||||
}
|
||||
throw new ServiceException("\u672a\u67e5\u5230\u8be5\u8bbe\u5907\u4fe1\u606f");
|
||||
}
|
||||
|
||||
protected DeviceResult getDeviceByCode(String deviceCode, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setDeviceCode(deviceCode);
|
||||
CloudwalkResult deviceQueryResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (deviceQueryResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)((Collection)deviceQueryResult.getData()))) {
|
||||
return (DeviceResult)((List)deviceQueryResult.getData()).get(0);
|
||||
}
|
||||
this.logger.error("\u672a\u67e5\u5230\u8bbe\u5907[{}]\u7684\u4fe1\u606f", (Object)deviceCode);
|
||||
throw new ServiceException("\u672a\u67e5\u5230\u8be5\u8bbe\u5907\u4fe1\u606f");
|
||||
}
|
||||
|
||||
protected List<DeviceResult> getDeviceList(List<String> deviceIds, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setIds(deviceIds);
|
||||
CloudwalkResult deviceQueryResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (deviceQueryResult.isSuccess()) {
|
||||
return (List)deviceQueryResult.getData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getAddress(DeviceResult data) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (StringUtils.isNotBlank((String)data.getDistrictMergeName())) {
|
||||
sb.append(data.getDistrictMergeName());
|
||||
}
|
||||
if (StringUtils.isNotBlank((String)data.getAreaName())) {
|
||||
sb.append(" ");
|
||||
sb.append(data.getAreaName());
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
protected void getAreaMap(List<AreaTreeResult> areaTreeResultList, Map<String, String> areaMap) {
|
||||
for (AreaTreeResult areaTree : areaTreeResultList) {
|
||||
areaMap.put(areaTree.getId(), areaTree.getName());
|
||||
if (areaTree.getChildren() == null) continue;
|
||||
this.getAreaMap(areaTree.getChildren(), areaMap);
|
||||
}
|
||||
}
|
||||
|
||||
protected List<AcsSettingAttr> setAcsDeviceAttrList(String deviceId, Map<String, AcsDeviceAttrResultDto> deviceAttrMap, YesNoTypeEnum isDefault) {
|
||||
ArrayList<AcsSettingAttr> attrs = new ArrayList<AcsSettingAttr>();
|
||||
for (AcsDeviceSettingEnum acsDeviceSettingEnum : AcsDeviceSettingEnum.getEnumBySource((String)AcsApplicationSourceEnum.ACCESS_CONTROL.getCode())) {
|
||||
AcsSettingAttr attr = new AcsSettingAttr();
|
||||
attr.setCode(acsDeviceSettingEnum.getCode());
|
||||
attr.setName(acsDeviceSettingEnum.getCode());
|
||||
attr.setRemark(AcsDeviceSettingEnum.getEnumByCode((String)acsDeviceSettingEnum.getCode()).getRemark());
|
||||
if (!YesNoTypeEnum.Y.getCode().equals(isDefault.getCode()) && deviceAttrMap.containsKey(deviceId + "_" + acsDeviceSettingEnum.getCode())) {
|
||||
AcsDeviceAttrResultDto acsDeviceAttr = deviceAttrMap.get(deviceId + "_" + acsDeviceSettingEnum.getCode());
|
||||
attr.setId(acsDeviceAttr.getId());
|
||||
attr.setValue(acsDeviceAttr.getAttrValue());
|
||||
} else {
|
||||
attr.setValue((String)this.accessControlProperties.getDeviceAtrrMap().get(acsDeviceSettingEnum.getCode()));
|
||||
}
|
||||
attrs.add(attr);
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
|
||||
protected List<AcsDeviceNewResult> convertDeviceNewResult(Collection<DeviceResult> datas, Map<String, String> areaMap) {
|
||||
ArrayList<AcsDeviceNewResult> result = new ArrayList<AcsDeviceNewResult>();
|
||||
for (DeviceResult data : datas) {
|
||||
AcsDeviceNewResult acsDeviceResult = new AcsDeviceNewResult();
|
||||
BeanCopyUtils.copyProperties((Object)data, (Object)acsDeviceResult);
|
||||
acsDeviceResult.setDeviceId(data.getId());
|
||||
acsDeviceResult.setDeviceStatus(Integer.valueOf(data.getStatus()));
|
||||
acsDeviceResult.setDeviceOnlineStatus(Integer.valueOf(data.getOnlineStatus()));
|
||||
acsDeviceResult.setAddress(this.getAddress(data));
|
||||
acsDeviceResult.setAreaName(areaMap.get(data.getAreaId()));
|
||||
result.add(acsDeviceResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected List<AcsUrgentGroupDeviceResultDTO> getGroupDevice(List<String> groupIds, String businessId) throws ServiceException {
|
||||
AcsUrgentGroupDeviceQueryDTO queryDeviceCountDTO = new AcsUrgentGroupDeviceQueryDTO();
|
||||
queryDeviceCountDTO.setGroupIds(groupIds);
|
||||
queryDeviceCountDTO.setBusinessId(businessId);
|
||||
try {
|
||||
List resultDTOS = this.acsUrgentGroupDeviceManager.query(queryDeviceCountDTO);
|
||||
return resultDTOS;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u8bbe\u5907\u5206\u7ec4\u5173\u8054\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u67e5\u8be2\u8bbe\u5907\u5206\u7ec4\u5173\u8054\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> getAllAreaMap(CloudwalkCallContext context) {
|
||||
DeviceAreaTreeParam areaTreeParam = new DeviceAreaTreeParam();
|
||||
areaTreeParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult<List<AreaTreeResult>> areaTree = this.acsAreaTreeCacheableService.tree(areaTreeParam, context);
|
||||
HashMap<String, String> areaMap = new HashMap<String, String>();
|
||||
this.getAreaMap((List)areaTree.getData(), areaMap);
|
||||
return areaMap;
|
||||
}
|
||||
}
|
||||
|
||||
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsCheckDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsCheckDeviceAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsCheckDeviceQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsCheckDeviceService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsCheckDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsCheckDeviceAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsCheckDeviceQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsCheckDeviceService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.page.CloudwalkPageAble;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsCheckDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsCheckDeviceServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsCheckDeviceService {
|
||||
@Autowired
|
||||
protected DeviceService deviceService;
|
||||
@Autowired
|
||||
private AcsCheckDeviceManager acsCheckDeviceManager;
|
||||
|
||||
public CloudwalkResult listAdded(AcsCheckDeviceQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsCheckDeviceQueryDTO dto = (AcsCheckDeviceQueryDTO)BeanCopyUtils.copyProperties((Object)param, AcsCheckDeviceQueryDTO.class);
|
||||
List results = this.acsCheckDeviceManager.listDevices(dto);
|
||||
Map<String, String> areaMap = this.getAllAreaMap(context);
|
||||
for (AcsCheckDeviceResultDTO result : results) {
|
||||
result.setAreaName(areaMap.get(result.getAreaId()));
|
||||
}
|
||||
return CloudwalkResult.success((Object)results);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u5df2\u6dfb\u52a0\u7684\u8003\u52e4\u8bbe\u5907\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult saveCheckDevices(AcsCheckDeviceAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsCheckDeviceQueryDTO dto = new AcsCheckDeviceQueryDTO();
|
||||
List results = this.acsCheckDeviceManager.listDevices(dto);
|
||||
ArrayList databaseIds = new ArrayList();
|
||||
results.forEach(check -> databaseIds.add(check.getDeviceId()));
|
||||
ArrayList<String> addIds = new ArrayList<String>();
|
||||
ArrayList<String> delIds = new ArrayList<String>();
|
||||
for (String deviceId : param.getDeviceIds()) {
|
||||
if (databaseIds.contains(deviceId)) continue;
|
||||
addIds.add(deviceId);
|
||||
}
|
||||
for (String deviceId : databaseIds) {
|
||||
if (param.getDeviceIds().contains(deviceId)) continue;
|
||||
delIds.add(deviceId);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(addIds)) {
|
||||
this.addCheckDevices(addIds, context);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(delIds)) {
|
||||
this.acsCheckDeviceManager.deleteByDeviceIds(delIds);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u4fdd\u5b58\u8003\u52e4\u8bbe\u5907\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private void addCheckDevices(List<String> addIds, CloudwalkCallContext context) throws DataAccessException, ServiceException {
|
||||
DeviceQueryParam queryParam = new DeviceQueryParam();
|
||||
queryParam.setIds(addIds);
|
||||
queryParam.setRowsOfPage(addIds.size() + 1);
|
||||
CloudwalkResult pageResult = this.deviceService.page(queryParam, context);
|
||||
ArrayList<AcsCheckDeviceAddDTO> addDTOS = new ArrayList<AcsCheckDeviceAddDTO>();
|
||||
Map<String, String> areaMap = this.getAllAreaMap(context);
|
||||
for (DeviceResult result : ((CloudwalkPageAble)pageResult.getData()).getDatas()) {
|
||||
AcsCheckDeviceAddDTO dto = (AcsCheckDeviceAddDTO)BeanCopyUtils.copyProperties((Object)result, AcsCheckDeviceAddDTO.class);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setDeviceId(result.getId());
|
||||
dto.setAreaName(areaMap.get(dto.getAreaId()));
|
||||
addDTOS.add(dto);
|
||||
}
|
||||
this.acsCheckDeviceManager.addCheckDevices(addDTOS);
|
||||
}
|
||||
}
|
||||
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreAddParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreDelParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.application.service.ApplicationImageStoreService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceImageStoreParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceImageStoreService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppBindParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppUnbindParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceImageStoreAppBindService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreAddParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreDelParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.application.service.ApplicationImageStoreService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceImageStoreParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceImageStoreService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppBindParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppUnbindParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceImageStoreAppBindService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceImageStoreAppBindServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceImageStoreAppBindService {
|
||||
@Resource
|
||||
private ApplicationImageStoreService applicationImageStoreService;
|
||||
@Resource
|
||||
private DeviceImageStoreService deviceImageStoreService;
|
||||
@Resource
|
||||
private ImageStoreService imageStoreService;
|
||||
|
||||
public CloudwalkResult<Boolean> bindAppImageStoreDevice(DeviceImageStoreAppBindParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u56fe\u5e93\u7ed1\u5b9a\u5e94\u7528\u8bbe\u5907\u5165\u53c2\uff1aDeviceImageStoreAppBindParam=[{}],CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
this.bindApplicationImageStore(param, context);
|
||||
try {
|
||||
this.bindDeviceImageStore(param, context);
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u8bbe\u5907\u56fe\u5e93\u5173\u8054\u5931\u8d25,\u56fe\u5e93id={},\u539f\u56e0:{}", (Object)param.getImageStoreId(), (Object)e.getMessage());
|
||||
this.logger.info("\u56de\u6eda\u5220\u9664\u5e94\u7528\u56fe\u5e93\u5173\u8054,imageStoreId={},applicationId={}", (Object)param.getImageStoreId(), (Object)param.getApplicationId());
|
||||
this.applicationUnBindImageStore(param.getApplicationId(), param.getImageStoreId(), context);
|
||||
throw new ServiceException("\u8bbe\u5907\u56fe\u5e93\u5173\u8054\u5931\u8d25");
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void bindApplicationImageStore(DeviceImageStoreAppBindParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
ApplicationImageStoreAddParam applicationImageStoreAddParam = new ApplicationImageStoreAddParam();
|
||||
applicationImageStoreAddParam.setApplicationId(param.getApplicationId());
|
||||
applicationImageStoreAddParam.setImageStoreId(param.getImageStoreId());
|
||||
CloudwalkResult applicationImageStoreAddResult = this.applicationImageStoreService.add(applicationImageStoreAddParam, context);
|
||||
if (!applicationImageStoreAddResult.isSuccess()) {
|
||||
this.logger.error("\u6dfb\u52a0\u5e94\u7528\u56fe\u5e93\u5173\u8054\u5931\u8d25\uff0c\u539f\u56e0\uff1a{}", (Object)applicationImageStoreAddResult.getMessage());
|
||||
throw new ServiceException(applicationImageStoreAddResult.getCode(), "\u6dfb\u52a0\u5e94\u7528\u56fe\u5e93\u5173\u8054\u5931\u8d25\uff0c\u539f\u56e0\uff1a" + applicationImageStoreAddResult.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void bindDeviceImageStore(DeviceImageStoreAppBindParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceImageStoreParam imageStoreSaveParam = new DeviceImageStoreParam();
|
||||
imageStoreSaveParam.setDeviceId(param.getDeviceId());
|
||||
imageStoreSaveParam.setImageStoreId(param.getImageStoreId());
|
||||
CloudwalkResult saveDeviceResult = this.deviceImageStoreService.add(imageStoreSaveParam, context);
|
||||
if (!saveDeviceResult.isSuccess()) {
|
||||
this.logger.error("\u7ed1\u5b9a\u8bbe\u5907\u4e0e\u56fe\u5e93\u5931\u8d25,\u8bbe\u5907id={},\u56fe\u5e93id={},\u539f\u56e0:{}", new Object[]{param.getDeviceId(), param.getImageStoreId(), saveDeviceResult.getMessage()});
|
||||
throw new ServiceException("\u7ed1\u5b9a\u8bbe\u5907\u4e0e\u56fe\u5e93\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> unbindAppImageStoreDevice(DeviceImageStoreAppUnbindParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.deviceUnBindImageStore(context, param.getDeviceId(), param.getImageStoreId(), param.getDeviceCode());
|
||||
this.applicationUnBindImageStore(param.getApplicationId(), param.getImageStoreId(), context);
|
||||
List<ImageStoreListResult> imageStoreList = this.getImageStoreResult(param.getImageStoreId(), param.getDeviceCode(), context);
|
||||
if (!CollectionUtils.isEmpty(imageStoreList)) {
|
||||
this.deleteImageStore(param.getImageStoreId(), context);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private List<ImageStoreListResult> getImageStoreResult(String imageStoreId, String deviceCode, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStoreQueryParam imageStoreQueryParam = new ImageStoreQueryParam();
|
||||
imageStoreQueryParam.setIds(Collections.singletonList(imageStoreId));
|
||||
imageStoreQueryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult imageStoreList = this.imageStoreService.list(imageStoreQueryParam, context);
|
||||
if (!imageStoreList.isSuccess()) {
|
||||
this.logger.error("\u67e5\u8be2\u8bbe\u5907\u56fe\u5e93\u5931\u8d25,\u8bbe\u5907\u7f16\u53f7:{},\u56fe\u5e93id:{},\u539f\u56e0:{}", new Object[]{deviceCode, imageStoreId, imageStoreList.getMessage()});
|
||||
throw new ServiceException("\u67e5\u8be2\u8bbe\u5907\u56fe\u5e93\u5931\u8d25,\u8bbe\u5907\u7f16\u53f7:{}" + deviceCode);
|
||||
}
|
||||
return (List)imageStoreList.getData();
|
||||
}
|
||||
|
||||
private void deviceUnBindImageStore(CloudwalkCallContext context, String deviceId, String imageStoreId, String deviceCode) throws ServiceException {
|
||||
DeviceImageStoreParam deviceImageStoreParam = new DeviceImageStoreParam();
|
||||
deviceImageStoreParam.setDeviceId(deviceId);
|
||||
deviceImageStoreParam.setImageStoreId(imageStoreId);
|
||||
CloudwalkResult deleteDeviceImageStoreResult = this.deviceImageStoreService.delete(deviceImageStoreParam, context);
|
||||
this.logger.info("\u5220\u9664\u8bbe\u5907\u56fe\u5e93\u5173\u8054\uff1a\u56fe\u5e93id={},\u7ed3\u679c:{}", (Object)imageStoreId, (Object)deleteDeviceImageStoreResult.getMessage());
|
||||
if (!deleteDeviceImageStoreResult.isSuccess()) {
|
||||
this.logger.error("\u5220\u9664\u8bbe\u5907\u56fe\u5e93\u5173\u8054\u5931\u8d25,\u8bbe\u5907\u7f16\u53f7:{},\u56fe\u5e93id:{},\u539f\u56e0:{}", new Object[]{deviceCode, imageStoreId, deleteDeviceImageStoreResult.getMessage()});
|
||||
throw new ServiceException("\u5220\u9664\u8bbe\u5907\u56fe\u5e93\u5173\u8054\u5931\u8d25,\u8bbe\u5907\u7f16\u53f7:" + deviceCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteImageStore(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStoreDelParam imageStoreDelParam = new ImageStoreDelParam();
|
||||
imageStoreDelParam.setId(imageStoreId);
|
||||
imageStoreDelParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult deleteImageStoreResult = this.imageStoreService.delete(imageStoreDelParam, context);
|
||||
if (!deleteImageStoreResult.isSuccess()) {
|
||||
this.logger.error("\u5220\u9664\u56fe\u5e93\u5931\u8d25,\u56fe\u5e93id:{},\u539f\u56e0:{}", (Object)imageStoreId, (Object)deleteImageStoreResult.getMessage());
|
||||
throw new ServiceException("\u5220\u9664\u56fe\u5e93\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void applicationUnBindImageStore(String applicationId, String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
ApplicationImageStoreDelParam applicationImageStoreDelParam = new ApplicationImageStoreDelParam();
|
||||
applicationImageStoreDelParam.setApplicationId(applicationId);
|
||||
applicationImageStoreDelParam.setImageStoreId(imageStoreId);
|
||||
CloudwalkResult deleteApplicationImageStoreResult = this.applicationImageStoreService.delete(applicationImageStoreDelParam, context);
|
||||
this.logger.info("\u5220\u9664\u5e94\u7528\u56fe\u5e93\u5173\u8054\uff1a\u56fe\u5e93id={},\u5e94\u7528id={},\u7ed3\u679c:{}", new Object[]{imageStoreId, applicationId, deleteApplicationImageStoreResult.getMessage()});
|
||||
if (!deleteApplicationImageStoreResult.isSuccess()) {
|
||||
this.logger.error("\u5e94\u7528\u4e0e\u56fe\u5e93\u89e3\u7ed1\u5931\u8d25,\u5e94\u7528id:{},\u56fe\u5e93id:{},\u539f\u56e0\uff1a{}", new Object[]{applicationId, imageStoreId, deleteApplicationImageStoreResult.getMessage()});
|
||||
throw new ServiceException("\u5e94\u7528\u4e0e\u56fe\u5e93\u89e3\u7ed1\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1277
File diff suppressed because it is too large
Load Diff
+298
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceTaskManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceRestructureBindingParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceTaskService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleNewParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTaskAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTaskDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.scheduling.annotation.Async
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceTaskManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceRestructureBindingParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceTaskService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleNewParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTaskAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTaskDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceTaskServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceTaskService {
|
||||
@Autowired
|
||||
private AcsPassRuleService acsPassRuleService;
|
||||
@Autowired
|
||||
private AcsPersonService acsPersonService;
|
||||
@Resource
|
||||
private AcsDeviceManager acsDeviceManager;
|
||||
@Resource
|
||||
private AcsPassRuleManager acsPassRuleManager;
|
||||
@Resource
|
||||
private AcsDeviceTaskManager acsDeviceTaskManager;
|
||||
|
||||
@Async(value="updateDevicesExecutor")
|
||||
public void updateDevices(AcsDeviceRestructureBindingParam param, List<String> addDeviceIds, List<String> delDeviceIds, CloudwalkCallContext context) throws ServiceException {
|
||||
block19: {
|
||||
try {
|
||||
AcsDeviceTaskAddDto addDto;
|
||||
AcsDeviceTaskDTO task;
|
||||
HashMap deviceCodeMap;
|
||||
List list;
|
||||
AcsDeviceQueryDTO queryDTO;
|
||||
if (!CollectionUtils.isEmpty(addDeviceIds)) {
|
||||
queryDTO = new AcsDeviceQueryDTO();
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
queryDTO.setDeviceIds(addDeviceIds);
|
||||
list = this.acsDeviceManager.list(queryDTO);
|
||||
deviceCodeMap = new HashMap();
|
||||
list.forEach(device -> deviceCodeMap.put(device.getDeviceId(), device.getDeviceCode()));
|
||||
for (String addDeviceId : addDeviceIds) {
|
||||
task = this.acsDeviceTaskManager.getById(param.getTaskId());
|
||||
if (task.getIsStop() != 0) break;
|
||||
if (!ObjectUtils.isEmpty((Object)param.getPersonId())) {
|
||||
AcsPersonAddParam addParam = new AcsPersonAddParam();
|
||||
addParam.setPersonIds(Collections.singletonList(param.getPersonId()));
|
||||
addParam.setDeviceId(addDeviceId);
|
||||
this.acsPersonService.add(addParam, context);
|
||||
} else {
|
||||
AcsPassRuleNewParam ruleParam = new AcsPassRuleNewParam();
|
||||
ruleParam.setDeviceId(addDeviceId);
|
||||
ruleParam.setDeviceCode((String)deviceCodeMap.get(addDeviceId));
|
||||
ArrayList<String> labelIds = new ArrayList<String>();
|
||||
if (!ObjectUtils.isEmpty((Object)param.getLabelId())) {
|
||||
labelIds.add(param.getLabelId());
|
||||
ruleParam.setRuleName(param.getLabelName());
|
||||
}
|
||||
ruleParam.setIncludeLabels(labelIds);
|
||||
ArrayList<String> orgIds = new ArrayList<String>();
|
||||
if (!ObjectUtils.isEmpty((Object)param.getOrgId())) {
|
||||
orgIds.add(param.getOrgId());
|
||||
ruleParam.setRuleName(param.getOrgName());
|
||||
}
|
||||
ruleParam.setIncludeOrganizations(orgIds);
|
||||
this.logger.info("\u5f02\u6b65\u7ed1\u5b9a\u7684\u4fe1\u606f\u4e3a\uff1a{}", JSONObject.toJSON((Object)ruleParam));
|
||||
this.acsPassRuleService.add(ruleParam, context);
|
||||
}
|
||||
addDto = new AcsDeviceTaskAddDto();
|
||||
addDto.setId(task.getId());
|
||||
addDto.setBindDevices(Integer.valueOf(task.getBindDevices() + 1));
|
||||
this.acsDeviceTaskManager.updateBingDevices(addDto);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(delDeviceIds)) break block19;
|
||||
queryDTO = new AcsDeviceQueryDTO();
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
queryDTO.setDeviceIds(delDeviceIds);
|
||||
list = this.acsDeviceManager.list(queryDTO);
|
||||
deviceCodeMap = new HashMap();
|
||||
list.forEach(device -> deviceCodeMap.put(device.getDeviceId(), device.getDeviceCode()));
|
||||
for (String delDevice : delDeviceIds) {
|
||||
task = this.acsDeviceTaskManager.getById(param.getTaskId());
|
||||
if (task.getIsStop() != 0) break;
|
||||
if (!ObjectUtils.isEmpty((Object)param.getPersonId())) {
|
||||
CloudwalkPageInfo pageInfo = new CloudwalkPageInfo(1, 10);
|
||||
AcsPersonQueryParam queryParam = new AcsPersonQueryParam();
|
||||
queryParam.setDeviceId(delDevice);
|
||||
queryParam.setPersonIds(Collections.singletonList(param.getPersonId()));
|
||||
CloudwalkResult page = this.acsPersonService.page(queryParam, pageInfo, context);
|
||||
List datas = (List)((CloudwalkPageAble)page.getData()).getDatas();
|
||||
this.logger.info("\u83b7\u53d6\u4eba\u5458\u6240\u5728\u56fe\u5e93\u4fe1\u606f\u4e3a\uff1a{}", JSONObject.toJSON((Object)datas));
|
||||
for (AcsPersonResult data : datas) {
|
||||
AcsPersonDeleteParam delParam = new AcsPersonDeleteParam();
|
||||
delParam.setDeviceId(delDevice);
|
||||
delParam.setPersonIds(Collections.singletonList(param.getPersonId()));
|
||||
delParam.setImageStoreId(data.getImageStoreId());
|
||||
this.acsPersonService.delete(delParam, context);
|
||||
}
|
||||
} else {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
if (!ObjectUtils.isEmpty((Object)param.getLabelName())) {
|
||||
dto.setName(param.getLabelName());
|
||||
}
|
||||
if (!ObjectUtils.isEmpty((Object)param.getOrgName())) {
|
||||
dto.setName(param.getOrgName());
|
||||
}
|
||||
dto.setDeviceId(delDevice);
|
||||
String ruleId = this.acsPassRuleManager.getByName(dto);
|
||||
if (!ObjectUtils.isEmpty((Object)ruleId)) {
|
||||
AcsPassRuleQueryParam detailParam = new AcsPassRuleQueryParam();
|
||||
detailParam.setId(ruleId);
|
||||
CloudwalkResult detail = this.acsPassRuleService.detail(detailParam, context);
|
||||
if (((AcsPassRuleDetailResult)detail.getData()).getIncludeLabels().size() > 2 || ((AcsPassRuleDetailResult)detail.getData()).getIncludeOrganizations().size() > 2) {
|
||||
AcsPassRuleResult result = (AcsPassRuleResult)BeanCopyUtils.copyProperties((Object)detail.getData(), AcsPassRuleResult.class);
|
||||
this.updateRule(delDevice, param, result, context, (String)deviceCodeMap.get(delDevice));
|
||||
} else {
|
||||
AcsPassRuleDeleteParam deleteParam = new AcsPassRuleDeleteParam();
|
||||
deleteParam.setIds(Collections.singletonList(ruleId));
|
||||
deleteParam.setDeviceId(delDevice);
|
||||
this.acsPassRuleService.delete(deleteParam, context);
|
||||
}
|
||||
} else {
|
||||
AcsPassRuleQueryParam queryParam = new AcsPassRuleQueryParam();
|
||||
queryParam.setDeviceId(delDevice);
|
||||
CloudwalkPageInfo page = new CloudwalkPageInfo(1, 9999);
|
||||
CloudwalkResult rulePage = this.acsPassRuleService.page(queryParam, page, context);
|
||||
for (AcsPassRuleResult result : ((CloudwalkPageAble)rulePage.getData()).getDatas()) {
|
||||
this.updateRule(delDevice, param, result, context, (String)deviceCodeMap.get(delDevice));
|
||||
}
|
||||
}
|
||||
}
|
||||
addDto = new AcsDeviceTaskAddDto();
|
||||
addDto.setId(task.getId());
|
||||
addDto.setBindDevices(Integer.valueOf(task.getBindDevices() + 1));
|
||||
this.acsDeviceTaskManager.updateBingDevices(addDto);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u5904\u7406\u8bbe\u5907\u4efb\u52a1\u5931\u8d25\uff0c\u5931\u8d25\u539f\u56e0\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateRule(String delDevice, AcsDeviceRestructureBindingParam param, AcsPassRuleResult result, CloudwalkCallContext context, String deviceCode) {
|
||||
ArrayList exLabelIds;
|
||||
AcsPassRuleEditParam editParam;
|
||||
if (!ObjectUtils.isEmpty((Object)param.getLabelId()) && !CollectionUtils.isEmpty((Collection)result.getIncludeLabels())) {
|
||||
ArrayList labelIds = new ArrayList();
|
||||
result.getIncludeLabels().forEach(label -> labelIds.add(label.getId()));
|
||||
if (labelIds.contains(param.getLabelId())) {
|
||||
editParam = new AcsPassRuleEditParam();
|
||||
editParam.setDeviceId(delDevice);
|
||||
editParam.setDeviceCode(deviceCode);
|
||||
editParam.setId(result.getId());
|
||||
editParam.setRuleName(result.getRuleName());
|
||||
if (!CollectionUtils.isEmpty((Collection)result.getIncludeOrganizations())) {
|
||||
ArrayList orgIds = new ArrayList();
|
||||
result.getIncludeOrganizations().forEach(org -> orgIds.add(org.getId()));
|
||||
editParam.setIncludeOrganizations(orgIds);
|
||||
}
|
||||
ArrayList<String> labels = new ArrayList<String>();
|
||||
for (LabelResult labelResult : result.getIncludeLabels()) {
|
||||
if (labelResult.getId().equals(param.getLabelId())) continue;
|
||||
labels.add(labelResult.getId());
|
||||
}
|
||||
editParam.setIncludeLabels(labels);
|
||||
editParam.setStartTime(result.getBeginDate());
|
||||
editParam.setEndTime(result.getEndDate());
|
||||
if (!CollectionUtils.isEmpty((Collection)result.getExcludeLabels())) {
|
||||
exLabelIds = new ArrayList();
|
||||
result.getExcludeLabels().forEach(label -> exLabelIds.add(label.getId()));
|
||||
editParam.setIncludeLabels(exLabelIds);
|
||||
}
|
||||
try {
|
||||
this.acsPassRuleService.update(editParam, context);
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u4fee\u6539\u901a\u884c\u89c4\u5219\u5931\u8d25\uff0c\u5931\u8d25\u539f\u56e0\uff1a{}", (Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ObjectUtils.isEmpty((Object)param.getOrgId()) && !CollectionUtils.isEmpty((Collection)result.getIncludeOrganizations())) {
|
||||
ArrayList orgIds = new ArrayList();
|
||||
result.getIncludeOrganizations().forEach(org -> orgIds.add(org.getId()));
|
||||
if (orgIds.contains(param.getOrgId())) {
|
||||
editParam = new AcsPassRuleEditParam();
|
||||
editParam.setDeviceId(delDevice);
|
||||
editParam.setDeviceCode(deviceCode);
|
||||
editParam.setId(result.getId());
|
||||
editParam.setRuleName(result.getRuleName());
|
||||
if (!CollectionUtils.isEmpty((Collection)result.getIncludeLabels())) {
|
||||
ArrayList labelIds = new ArrayList();
|
||||
result.getIncludeLabels().forEach(label -> labelIds.add(label.getId()));
|
||||
editParam.setIncludeLabels(labelIds);
|
||||
}
|
||||
ArrayList<String> orgs = new ArrayList<String>();
|
||||
for (OrganizationResult organizationResult : result.getIncludeOrganizations()) {
|
||||
if (organizationResult.getId().equals(param.getOrgId())) continue;
|
||||
orgs.add(organizationResult.getId());
|
||||
}
|
||||
editParam.setIncludeOrganizations(orgs);
|
||||
editParam.setStartTime(result.getBeginDate());
|
||||
editParam.setEndTime(result.getEndDate());
|
||||
if (!CollectionUtils.isEmpty((Collection)result.getExcludeLabels())) {
|
||||
exLabelIds = new ArrayList();
|
||||
result.getExcludeLabels().forEach(label -> exLabelIds.add(label.getId()));
|
||||
editParam.setIncludeLabels(exLabelIds);
|
||||
}
|
||||
try {
|
||||
this.acsPassRuleService.update(editParam, context);
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u4fee\u6539\u901a\u884c\u89c4\u5219\u5931\u8d25\uff0c\u5931\u8d25\u539f\u56e0\uff1a{}", (Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceTypeManager
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceFeaturesQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceFeaturesResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceFeaturesSubResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceTypeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceTypeService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTypeFeaturesDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsFeaturesEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.CollectionUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceTypeManager;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceFeaturesQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceFeaturesResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceFeaturesSubResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceTypeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceTypeService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceTypeFeaturesDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsFeaturesEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceTypeServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceTypeService {
|
||||
@Autowired
|
||||
private AcsDeviceTypeManager acsDeviceTypeManager;
|
||||
|
||||
public CloudwalkResult<List<AcsDeviceTypeResult>> list() throws ServiceException {
|
||||
List results;
|
||||
this.logger.info("\u67e5\u8be2\u8bbe\u5907\u7c7b\u578b\u5217\u8868\u5f00\u59cb");
|
||||
try {
|
||||
List acsDeviceTypeDTOS = this.acsDeviceTypeManager.typeListAll();
|
||||
results = BeanCopyUtils.copy((Collection)acsDeviceTypeDTOS, AcsDeviceTypeResult.class);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u8bbe\u5907\u7c7b\u578b\u5217\u8868\u5f02\u5e38\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
return CloudwalkResult.success((Object)results);
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<AcsDeviceFeaturesResult> features(AcsDeviceFeaturesQueryParam param) throws ServiceException {
|
||||
this.logger.info("\u83b7\u53d6\u8bbe\u5907\u80fd\u529b\u5165\u53c2\uff1a{}", (Object)JSONObject.toJSONString((Object)param));
|
||||
try {
|
||||
AcsDeviceFeaturesResult result = new AcsDeviceFeaturesResult();
|
||||
AcsDeviceTypeFeaturesDto dto = new AcsDeviceTypeFeaturesDto();
|
||||
dto.setDeviceTypeCode(param.getDeviceTypeCode());
|
||||
dto.setFeatureStatus(YesNoTypeEnum.Y.getCode());
|
||||
List list = this.acsDeviceTypeManager.query(dto);
|
||||
result.setDeviceTypeCode(param.getDeviceTypeCode());
|
||||
if (!CollectionUtils.isEmpty((Collection)list)) {
|
||||
if (list.stream().anyMatch(t -> AcsFeaturesEnum.ONE_TO_N_FRONT.getFeatureCode().equals(t.getFeatureCode()) || AcsFeaturesEnum.ONE_TO_N_BACKEND.getFeatureCode().equals(t.getFeatureCode()) || AcsFeaturesEnum.ONE_TO_ONE_PERSON_CARD.getFeatureCode().equals(t.getFeatureCode()) || AcsFeaturesEnum.ONE_TO_ONE_PERSON_CARD_MASKS.getFeatureCode().equals(t.getFeatureCode()))) {
|
||||
result.setIsFeatureFace(YesNoTypeEnum.Y.getCode());
|
||||
}
|
||||
if (list.stream().anyMatch(t -> AcsFeaturesEnum.TEMPERATURE_MEASUREMENT.getFeatureCode().equals(t.getFeatureCode()))) {
|
||||
result.setIsFeatureTemperatureMeasurement(YesNoTypeEnum.Y.getCode());
|
||||
}
|
||||
List subResults = BeanCopyUtils.copy((Collection)list, AcsDeviceFeaturesSubResult.class);
|
||||
result.setFeatureslist(subResults);
|
||||
}
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u83b7\u53d6\u8bbe\u5907\u80fd\u529b\u5f02\u5e38\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceUploadService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceUpdateStatusDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.device.sdk.protocol.entity.v2proto.http.param.ReportOrderTypeParam
|
||||
* cn.cloudwalk.device.sdk.protocol.entity.v2proto.http.result.ReportOrderTypeResult
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceUploadService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceUpdateStatusDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.device.sdk.protocol.entity.v2proto.http.param.ReportOrderTypeParam;
|
||||
import cn.cloudwalk.device.sdk.protocol.entity.v2proto.http.result.ReportOrderTypeResult;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.io.Serializable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceUploadServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceUploadService {
|
||||
private static final int ORDER_TYPE = 20;
|
||||
@Autowired
|
||||
private AcsDeviceManager acsDeviceManager;
|
||||
|
||||
public CloudwalkResult<ReportOrderTypeResult> updateOpenStatus(ReportOrderTypeParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u66f4\u65b0\u8bbe\u5907\u5f00\u95ed\u72b6\u6001\u5f00\u59cb\uff0cReportOrderTypeParam=[{}],CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
if (param.getOrderType() != 20) {
|
||||
throw new ServiceException("order_type is not for update device open status");
|
||||
}
|
||||
DeviceResult device = this.getDeviceByCode(param.getDeviceId(), context);
|
||||
this.updateDeviceStatus(param, device.getId(), context);
|
||||
ReportOrderTypeResult result = new ReportOrderTypeResult();
|
||||
result.setLogId(param.getLogId());
|
||||
result.setReserveInfo(param.getReserveInfo());
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
|
||||
private void updateDeviceStatus(ReportOrderTypeParam param, String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
Content content = (Content)JSONObject.parseObject((String)param.getContent(), Content.class);
|
||||
AcsDeviceUpdateStatusDTO dto = new AcsDeviceUpdateStatusDTO();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setOpenStatus(content.status);
|
||||
dto.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
dto.setDeviceId(deviceId);
|
||||
this.acsDeviceManager.updateOpenStatus(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u66f4\u65b0\u95e8\u7981\u8bbe\u5907\u5f00\u95ed\u72b6\u6001\u6570\u636e\u5e93\u5f02\u5e38,\u539f\u56e0\uff1a" + e.getMessage());
|
||||
throw new ServiceException("\u66f4\u65b0\u95e8\u7981\u8bbe\u5907\u5f00\u95ed\u72b6\u6001\u6570\u636e\u5e93\u5f02\u5e38");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Content
|
||||
implements Serializable {
|
||||
private static final long serialVersionUID = 5423715322717804192L;
|
||||
private Integer status;
|
||||
|
||||
public Integer getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+288
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsUrgentDeviceGroupResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentDeviceGroupService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentGroupDeviceService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupDelDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceDelDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsUrgentDeviceGroupStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsUrgentDeviceGroupResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentDeviceGroupService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentGroupDeviceService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupDelDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceDelDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsUrgentDeviceGroupStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsUrgentDeviceGroupServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsUrgentDeviceGroupService {
|
||||
@Autowired
|
||||
private AcsUrgentDeviceGroupManager acsUrgentDeviceGroupManager;
|
||||
@Autowired
|
||||
private AcsUrgentGroupDeviceManager acsUrgentGroupDeviceManager;
|
||||
@Autowired
|
||||
private AcsUrgentGroupDeviceService acsUrgentGroupDeviceService;
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> add(AcsUrgentDeviceGroupAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u65b0\u589e\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5165\u53c2\uff1aAcsUrgentDeviceGroupAddParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsUrgentDeviceGroupAddDTO dto = new AcsUrgentDeviceGroupAddDTO();
|
||||
dto = (AcsUrgentDeviceGroupAddDTO)BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setGroupStatus(AcsUrgentDeviceGroupStatusEnum.NORMAL.getCode());
|
||||
dto.setId(this.genUUID());
|
||||
dto.setCreateUserName(context.getUser().getCallerName());
|
||||
if (dto.getIsDefaultGroup() == null) {
|
||||
dto.setIsDefaultGroup(YesNoTypeEnum.N.getCode());
|
||||
}
|
||||
this.acsUrgentDeviceGroupManager.add(dto);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u65b0\u589e\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u65b0\u589e\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> edit(AcsUrgentDeviceGroupEditParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7f16\u8f91\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5165\u53c2\uff1aAcsUrgentDeviceGroupEditParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsUrgentDeviceGroupEditDTO dto = new AcsUrgentDeviceGroupEditDTO();
|
||||
dto = (AcsUrgentDeviceGroupEditDTO)BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.acsUrgentDeviceGroupManager.edit(dto);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7f16\u8f91\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7f16\u8f91\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> delete(AcsUrgentDeviceGroupDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5220\u9664\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5165\u53c2\uff1aAcsUrgentDeviceGroupDeleteParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
this.deleteDevice(param.getIds(), context);
|
||||
AcsUrgentDeviceGroupDelDTO dto = new AcsUrgentDeviceGroupDelDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.acsUrgentDeviceGroupManager.delete(dto);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5220\u9664\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u5220\u9664\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteDevice(List<String> groupIds, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsUrgentGroupDeviceDelDTO deviceDelDTO = new AcsUrgentGroupDeviceDelDTO();
|
||||
for (String id : groupIds) {
|
||||
deviceDelDTO.setGroupId(id);
|
||||
deviceDelDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
this.acsUrgentGroupDeviceManager.delete(deviceDelDTO);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5220\u9664\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5220\u9664\u8bbe\u5907\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsUrgentDeviceGroupResult>> page(AcsUrgentDeviceGroupQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5165\u53c2\uff1aAcsUrgentDeviceGroupQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
List<Object> result = new ArrayList();
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
List<String> groupIds = this.getGroupIds(param, context);
|
||||
if (CollectionUtils.isEmpty(groupIds)) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
List<AcsUrgentGroupDeviceResultDTO> resultDTOS = this.getGroupDevice(groupIds, businessId);
|
||||
Map<String, List<AcsUrgentGroupDeviceResultDTO>> map = resultDTOS.stream().collect(Collectors.groupingBy(AcsUrgentGroupDeviceResultDTO::getGroupId));
|
||||
try {
|
||||
AcsUrgentDeviceGroupQueryDTO groupQueryDTO = new AcsUrgentDeviceGroupQueryDTO();
|
||||
groupQueryDTO.setIds(groupIds);
|
||||
groupQueryDTO.setBusinessId(businessId);
|
||||
CloudwalkPageAble pageResult = this.acsUrgentDeviceGroupManager.page(groupQueryDTO, pageInfo);
|
||||
result = this.convertPageResult(pageResult.getDatas(), map);
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5206\u9875\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u5206\u9875\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getGroupIds(AcsUrgentDeviceGroupQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
List<Object> groupIds = new ArrayList();
|
||||
ArrayList<String> deviceIds = new ArrayList();
|
||||
if (!CollectionUtils.isEmpty((Collection)param.getDeviceIds())) {
|
||||
deviceIds = param.getDeviceIds();
|
||||
groupIds = this.getGroupIdsByDevice(deviceIds, context);
|
||||
} else if (!CollectionUtils.isEmpty((Collection)param.getDistrictIds()) || !CollectionUtils.isEmpty((Collection)param.getAreaIds())) {
|
||||
CloudwalkResult deviceResult = this.acsUrgentGroupDeviceService.listByArea(param, context);
|
||||
if (CollectionUtils.isEmpty((Collection)((Collection)deviceResult.getData()))) {
|
||||
return groupIds;
|
||||
}
|
||||
deviceIds = ((List)deviceResult.getData()).stream().distinct().map(DeviceResult::getId).collect(Collectors.toList());
|
||||
groupIds = this.getGroupIdsByDevice(deviceIds, context);
|
||||
} else {
|
||||
List<AcsUrgentDeviceGroupResultDTO> groupList = this.getGroupList(param, context);
|
||||
groupIds = groupList.stream().map(CloudwalkBaseIdentify::getId).collect(Collectors.toList());
|
||||
}
|
||||
return groupIds;
|
||||
}
|
||||
|
||||
private List<AcsUrgentDeviceGroupResultDTO> getGroupList(AcsUrgentDeviceGroupQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsUrgentDeviceGroupQueryDTO dto = new AcsUrgentDeviceGroupQueryDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(param.getGroupId());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
return this.acsUrgentDeviceGroupManager.query(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u4fe1\u606f\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getGroupIdsByDevice(List<String> deviceIds, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsUrgentGroupDeviceQueryDTO refQueryDTO = new AcsUrgentGroupDeviceQueryDTO();
|
||||
refQueryDTO.setDeviceIds(deviceIds);
|
||||
refQueryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
List groupList = this.acsUrgentGroupDeviceManager.query(refQueryDTO);
|
||||
if (CollectionUtils.isEmpty((Collection)groupList)) {
|
||||
return null;
|
||||
}
|
||||
return groupList.stream().map(AcsUrgentGroupDeviceResultDTO::getGroupId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u8bbe\u5907\u5206\u7ec4\u5173\u8054\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u67e5\u8be2\u8bbe\u5907\u5206\u7ec4\u5173\u8054\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsDeviceNewResult>> detail(AcsUrgentDeviceGroupQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u8be6\u60c5\u5165\u53c2\uff1aAcsUrgentDeviceGroupQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
List<Object> result = new ArrayList();
|
||||
List<AcsUrgentGroupDeviceResultDTO> groupDeviceList = this.getGroupDevice(Collections.singletonList(param.getGroupId()), businessId);
|
||||
if (CollectionUtils.isEmpty(groupDeviceList)) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble());
|
||||
}
|
||||
List deviceIds = groupDeviceList.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setIds(deviceIds);
|
||||
deviceQueryParam.setBusinessId(businessId);
|
||||
CloudwalkResult pageResult = this.deviceService.page(deviceQueryParam, context);
|
||||
Map<String, String> areaMap = this.getAllAreaMap(context);
|
||||
result = this.convertDeviceNewResult(((CloudwalkPageAble)pageResult.getData()).getDatas(), areaMap);
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, ((CloudwalkPageAble)pageResult.getData()).getTotalRows()));
|
||||
}
|
||||
|
||||
public CloudwalkResult<AcsUrgentDeviceGroupResult> query(AcsUrgentDeviceGroupQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
List<AcsUrgentDeviceGroupResultDTO> groupList = this.getGroupList(param, context);
|
||||
if (groupList.isEmpty()) {
|
||||
return CloudwalkResult.success((Object)new AcsUrgentDeviceGroupResult());
|
||||
}
|
||||
AcsUrgentDeviceGroupResult result = (AcsUrgentDeviceGroupResult)BeanCopyUtils.copyProperties((Object)groupList.get(0), AcsUrgentDeviceGroupResult.class);
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
|
||||
private List<AcsUrgentDeviceGroupResult> convertPageResult(Collection<AcsUrgentDeviceGroupResultDTO> datas, Map<String, List<AcsUrgentGroupDeviceResultDTO>> map) {
|
||||
ArrayList<AcsUrgentDeviceGroupResult> result = new ArrayList<AcsUrgentDeviceGroupResult>();
|
||||
for (AcsUrgentDeviceGroupResultDTO data : datas) {
|
||||
AcsUrgentDeviceGroupResult acsUrgentDeviceGroupResultDeviceResult = new AcsUrgentDeviceGroupResult();
|
||||
BeanCopyUtils.copyProperties((Object)data, (Object)acsUrgentDeviceGroupResultDeviceResult);
|
||||
if (map != null && !map.isEmpty() && map.get(data.getId()) != null) {
|
||||
acsUrgentDeviceGroupResultDeviceResult.setDeviceCount(Integer.valueOf(map.get(data.getId()).size()));
|
||||
} else {
|
||||
acsUrgentDeviceGroupResultDeviceResult.setDeviceCount(Integer.valueOf(0));
|
||||
}
|
||||
result.add(acsUrgentDeviceGroupResultDeviceResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceNewParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDevicePageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsUrgentDeviceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentDeviceService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceDeleteDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceNewDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceNewParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDevicePageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsUrgentDeviceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentDeviceService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceDeleteDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceNewDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsUrgentDeviceServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsUrgentDeviceService {
|
||||
@Autowired
|
||||
private AcsUrgentDeviceManager acsUrgentDeviceManager;
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
public CloudwalkResult<Boolean> add(AcsUrgentDeviceNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsUrgentDeviceDeleteDTO deleteDTO = new AcsUrgentDeviceDeleteDTO();
|
||||
deleteDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
deleteDTO.setDeviceIds(param.getDeviceIds());
|
||||
this.acsUrgentDeviceManager.delete(deleteDTO);
|
||||
if (CollectionUtils.isNotEmpty((Collection)param.getDeviceIds())) {
|
||||
ArrayList<AcsUrgentDeviceNewDTO> acsUrgentDeviceList = new ArrayList<AcsUrgentDeviceNewDTO>(param.getDeviceIds().size());
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setIds(param.getDeviceIds());
|
||||
CloudwalkResult deviceResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (deviceResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)((Collection)deviceResult.getData()))) {
|
||||
List devices = (List)deviceResult.getData();
|
||||
Map<String, DeviceResult> deviceMap = devices.stream().collect(Collectors.toMap(DeviceResult::getId, device -> device));
|
||||
for (String deviceId : param.getDeviceIds()) {
|
||||
DeviceResult device2 = deviceMap.get(deviceId);
|
||||
if (device2 == null) continue;
|
||||
AcsUrgentDeviceNewDTO newDTO = new AcsUrgentDeviceNewDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)newDTO);
|
||||
newDTO.setId(this.genUUID());
|
||||
newDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
newDTO.setDeviceId(deviceId);
|
||||
newDTO.setDeviceCode(device2.getDeviceCode());
|
||||
acsUrgentDeviceList.add(newDTO);
|
||||
}
|
||||
this.acsUrgentDeviceManager.batchInsert(acsUrgentDeviceList);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u65b0\u589e\u7d27\u6025\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
public CloudwalkResult<Boolean> delete(AcsUrgentDeviceDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsUrgentDeviceDeleteDTO deleteDTO = new AcsUrgentDeviceDeleteDTO();
|
||||
deleteDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
deleteDTO.setDeviceIds(param.getDeviceIds());
|
||||
try {
|
||||
this.acsUrgentDeviceManager.delete(deleteDTO);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5220\u9664\u7d27\u6025\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsUrgentDeviceResult>> page(AcsUrgentDevicePageParam param, CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u7d27\u6025\u8bbe\u5907\u5165\u53c2\uff1a{}", (Object)JSONObject.toJSONString((Object)param));
|
||||
ArrayList<AcsUrgentDeviceResult> result = new ArrayList<AcsUrgentDeviceResult>();
|
||||
AcsUrgentDeviceQueryDTO queryDTO = new AcsUrgentDeviceQueryDTO();
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkPageAble pageAble = null;
|
||||
try {
|
||||
pageAble = this.acsUrgentDeviceManager.page(queryDTO, page);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5206\u9875\u67e5\u8be2\u7d27\u6025\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty((Collection)pageAble.getDatas())) {
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
List deviceIds = pageAble.getDatas().stream().map(AcsUrgentDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
deviceQueryParam.setIds(deviceIds);
|
||||
CloudwalkResult deviceResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (deviceResult.isSuccess()) {
|
||||
if (CollectionUtils.isNotEmpty((Collection)((Collection)deviceResult.getData()))) {
|
||||
for (DeviceResult device : (List)deviceResult.getData()) {
|
||||
AcsUrgentDeviceResult acsUrgentDeviceResult = new AcsUrgentDeviceResult();
|
||||
BeanCopyUtils.copyProperties((Object)device, (Object)acsUrgentDeviceResult);
|
||||
acsUrgentDeviceResult.setDeviceId(device.getId());
|
||||
acsUrgentDeviceResult.setDeviceStatus(Integer.valueOf(device.getStatus()));
|
||||
acsUrgentDeviceResult.setDeviceOnlineStatus(Integer.valueOf(device.getOnlineStatus()));
|
||||
acsUrgentDeviceResult.setAddress(this.getAddress(device));
|
||||
acsUrgentDeviceResult.setDeviceTypeCode(device.getDeviceTypeCode());
|
||||
result.add(acsUrgentDeviceResult);
|
||||
}
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, pageAble.getTotalRows()));
|
||||
}
|
||||
return CloudwalkResult.fail((String)deviceResult.getCode(), (String)deviceResult.getMessage());
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, pageAble.getTotalRows()));
|
||||
}
|
||||
}
|
||||
|
||||
+265
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentGroupDeviceAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentGroupDeviceDelParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentGroupDeviceService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceDelDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceQueryTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.intelligent.lock.annotation.RequiredLock
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.device;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentDeviceGroupManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsUrgentGroupDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentDeviceGroupQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentGroupDeviceAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsUrgentGroupDeviceDelParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsUrgentGroupDeviceService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentDeviceGroupEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceDelDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsUrgentGroupDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceQueryTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.intelligent.lock.annotation.RequiredLock;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsUrgentGroupDeviceServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsUrgentGroupDeviceService {
|
||||
@Autowired
|
||||
private AcsUrgentGroupDeviceManager acsUrgentGroupDeviceManager;
|
||||
@Autowired
|
||||
private AcsUrgentDeviceGroupManager acsUrgentDeviceGroupManager;
|
||||
@Autowired
|
||||
private AcsDeviceManager acsDeviceManager;
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@RequiredLock(name="T(cn.cloudwalk.common.ninca.accesscontrol.config.AcsLockConstants).LOCK_URGENT_GROUP_DEVICE_ID_PREFIX.concat(#context.company.companyId)", lockWaitTime=5000L)
|
||||
public CloudwalkResult<Boolean> batchAdd(AcsUrgentGroupDeviceAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u6279\u91cf\u65b0\u589e\u8bbe\u5907\u5165\u53c2\uff1aAcsUrgentGroupDeviceAddParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
this.checkDevice(param, businessId);
|
||||
this.checkGroup(param, businessId);
|
||||
this.addList(param, context);
|
||||
this.updateGroup(param.getGroupId(), context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void updateGroup(String groupId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsUrgentDeviceGroupEditDTO editDTO = new AcsUrgentDeviceGroupEditDTO();
|
||||
BeanCopyUtils.copyProperties((Object)editDTO, (CloudwalkCallContext)context, (Object)editDTO);
|
||||
editDTO.setId(groupId);
|
||||
try {
|
||||
this.acsUrgentDeviceGroupManager.edit(editDTO);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u66f4\u65b0\u7d27\u6025\u758f\u6563\u5206\u7ec4\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u66f4\u65b0\u7d27\u6025\u758f\u6563\u5206\u7ec4\u4fe1\u606f\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void addList(AcsUrgentGroupDeviceAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
ArrayList<AcsUrgentGroupDeviceAddDTO> list = new ArrayList<AcsUrgentGroupDeviceAddDTO>();
|
||||
for (String deviceId : param.getDeviceIds()) {
|
||||
AcsUrgentGroupDeviceAddDTO dto = new AcsUrgentGroupDeviceAddDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setDeviceId(deviceId);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
list.add(dto);
|
||||
}
|
||||
try {
|
||||
this.acsUrgentGroupDeviceManager.batchAdd(list);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u65b0\u589e\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u65b0\u589e\u8bbe\u5907\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkGroup(AcsUrgentGroupDeviceAddParam param, String businessId) throws ServiceException {
|
||||
AcsUrgentGroupDeviceQueryDTO queryDTO = new AcsUrgentGroupDeviceQueryDTO();
|
||||
queryDTO.setBusinessId(businessId);
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)queryDTO);
|
||||
try {
|
||||
List result = this.acsUrgentGroupDeviceManager.query(queryDTO);
|
||||
if (CollectionUtils.isNotEmpty((Collection)result)) {
|
||||
List deviceIds = result.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
throw new ServiceException("76260133", this.getMessage("76260133") + deviceIds);
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u5206\u7ec4\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u67e5\u8be2\u5206\u7ec4\u4fe1\u606f\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDevice(AcsUrgentGroupDeviceAddParam param, String businessId) throws ServiceException {
|
||||
AcsDeviceQueryDTO deviceQueryDTO = new AcsDeviceQueryDTO();
|
||||
deviceQueryDTO.setDeviceIds(param.getDeviceIds());
|
||||
deviceQueryDTO.setBusinessId(businessId);
|
||||
try {
|
||||
List deviceResultDTOS = this.acsDeviceManager.list(deviceQueryDTO);
|
||||
if (deviceResultDTOS.isEmpty() || deviceResultDTOS.size() != param.getDeviceIds().size()) {
|
||||
this.logger.error("\u8be5\u8bbe\u5907\u4e0d\u5b58\u5728");
|
||||
throw new ServiceException("\u8be5\u8bbe\u5907\u4e0d\u5b58\u5728");
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u8bbe\u5907\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u8be5\u8bbe\u5907\u4e0d\u5b58\u5728");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> delete(AcsUrgentGroupDeviceDelParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5220\u9664\u8bbe\u5907\u5165\u53c2\uff1aAcsUrgentGroupDeviceDelParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsUrgentGroupDeviceDelDTO dto = new AcsUrgentGroupDeviceDelDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.acsUrgentGroupDeviceManager.delete(dto);
|
||||
this.updateGroup(param.getGroupId(), context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5220\u9664\u8bbe\u5907\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u7d27\u6025\u758f\u6563\u5206\u7ec4\u5220\u9664\u8bbe\u5907\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<List<DeviceResult>> listByArea(AcsUrgentDeviceGroupQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u6839\u636e\u533a\u57df\u4f4d\u7f6e\u67e5\u8be2\u758f\u6563\u8bbe\u5907\u5165\u53c2\uff1aAcsUrgentGroupDeviceListParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
List<AcsUrgentGroupDeviceResultDTO> resultDTOS = this.getGroupDevice(new ArrayList<String>(), businessId);
|
||||
if (CollectionUtils.isEmpty(resultDTOS)) {
|
||||
return CloudwalkResult.success(new ArrayList());
|
||||
}
|
||||
List<String> UrgentDeviceIds = resultDTOS.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
CloudwalkResult<List<DeviceResult>> deviceResult = this.getDeviceByArea(UrgentDeviceIds, context, param.getDistrictIds(), param.getAreaIds());
|
||||
return deviceResult;
|
||||
}
|
||||
|
||||
private CloudwalkResult<List<DeviceResult>> getDeviceByArea(List<String> deviceIds, CloudwalkCallContext context, List<String> districtIds, List<String> areaIds) throws ServiceException {
|
||||
DeviceQueryParam queryParam = new DeviceQueryParam();
|
||||
queryParam.setIds(deviceIds);
|
||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
queryParam.setDistrictIds(districtIds);
|
||||
queryParam.setAreaIds(areaIds);
|
||||
return this.deviceService.list(queryParam, context);
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsDeviceNewResult>> devicePage(AcsUrgentDeviceGroupQueryParam param, CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u7d27\u6025\u758f\u6563\u5206\u7ec4\u672a\u6dfb\u52a0\u7684\u95e8\u7981\u8bbe\u5907\uff1aAcsUrgentDeviceGroupQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
List<AcsDeviceResultDTO> list = this.getAcsDeviceListByBusinessId(businessId);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble());
|
||||
}
|
||||
List<String> acsDeviceIds = list.stream().map(AcsDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
List<String> deviceIds = this.getAcsDevice(acsDeviceIds, param, businessId);
|
||||
CloudwalkPageAble<DeviceResult> pageResult = this.getDeviceResult(deviceIds, param, page, context);
|
||||
if (CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble());
|
||||
}
|
||||
Map<String, String> areaMap = this.getAllAreaMap(context);
|
||||
List<AcsDeviceNewResult> result = this.convertDeviceNewResult(pageResult.getDatas(), areaMap);
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, pageResult.getTotalRows()));
|
||||
}
|
||||
|
||||
private List<String> getAcsDevice(List<String> deviceIds, AcsUrgentDeviceGroupQueryParam param, String businessId) throws ServiceException {
|
||||
List<AcsUrgentGroupDeviceResultDTO> UrgentGroupDeviceResult = this.getGroupDevice(Collections.singletonList(param.getGroupId()), businessId);
|
||||
if (CollectionUtils.isEmpty(UrgentGroupDeviceResult)) {
|
||||
return deviceIds;
|
||||
}
|
||||
List urgentDeviceIds = UrgentGroupDeviceResult.stream().map(AcsUrgentGroupDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
return CollectionUtils.removeList(deviceIds, urgentDeviceIds);
|
||||
}
|
||||
|
||||
private List<AcsDeviceResultDTO> getAcsDeviceListByBusinessId(String businessId) throws ServiceException {
|
||||
AcsDeviceQueryDTO dto = new AcsDeviceQueryDTO();
|
||||
dto.setQueryParent(AcsDeviceQueryTypeEnum.QUERY_MAIN.getCode());
|
||||
dto.setBusinessId(businessId);
|
||||
try {
|
||||
return this.acsDeviceManager.list(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u4fe1\u606f\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private CloudwalkPageAble<DeviceResult> getDeviceResult(List<String> deviceIds, AcsUrgentDeviceGroupQueryParam param, CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceQueryParam queryParam = new DeviceQueryParam();
|
||||
queryParam.setIds(deviceIds);
|
||||
queryParam.setDistrictIds(param.getDistrictIds());
|
||||
queryParam.setAreaIds(param.getAreaIds());
|
||||
queryParam.setCurrentPage(page.getCurrentPage());
|
||||
queryParam.setRowsOfPage(page.getPageSize());
|
||||
queryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult pageResult = this.deviceService.page(queryParam, context);
|
||||
if (!pageResult.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u8bbe\u5907\u4fe1\u606f\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)pageResult.getMessage());
|
||||
throw new ServiceException("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u8bbe\u5907\u4fe1\u606f\u5931\u8d25");
|
||||
}
|
||||
return (CloudwalkPageAble)pageResult.getData();
|
||||
}
|
||||
}
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileFinishParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileGetParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileInitParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.file.result.FileDetail
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.file.service.FileService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.param.AcsFileFinishParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.service.AcsDownloadCenterService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsFileStatusEnum
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.downloadcenter;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileFinishParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileGetParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.file.param.FileInitParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.file.result.FileDetail;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.file.service.FileService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.param.AcsFileFinishParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.service.AcsDownloadCenterService;
|
||||
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.common.ninca.accesscontrol.config.FeignThreadLocalUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsFileStatusEnum;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDownloadCenterServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsDownloadCenterService {
|
||||
@Autowired
|
||||
private FileService fileService;
|
||||
@Autowired
|
||||
private AcsApplicationService acsApplicationService;
|
||||
|
||||
public String createDownload(String fileName, CloudwalkCallContext context) {
|
||||
try {
|
||||
FileInitParam fileInitParam = new FileInitParam();
|
||||
fileInitParam.setFileName(fileName);
|
||||
context.setApplicationId(this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId()));
|
||||
fileInitParam.setApplicationId(context.getApplicationId());
|
||||
FeignThreadLocalUtil.setRequestHeader((CloudwalkCallContext)context);
|
||||
CloudwalkResult result = this.fileService.init(fileInitParam, context);
|
||||
if ("00000000".equals(result.getCode())) {
|
||||
String string = (String)result.getData();
|
||||
return string;
|
||||
}
|
||||
try {
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u521d\u59cb\u5316\u5931\u8d25\uff1acode={},message={}", (Object)result.getCode(), (Object)result.getMessage());
|
||||
throw new RuntimeException("\u4e0b\u8f7d\u4efb\u52a1\u521b\u5efa\u5931\u8d25\uff01");
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u521d\u59cb\u5316\u63a5\u53e3\u9519\u8bef", (Throwable)e);
|
||||
throw new RuntimeException("\u4e0b\u8f7d\u4efb\u52a1\u521b\u5efa\u5931\u8d25\uff01");
|
||||
}
|
||||
}
|
||||
finally {
|
||||
FeignThreadLocalUtil.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING - Removed try catching itself - possible behaviour change.
|
||||
*/
|
||||
public boolean finishDownload(AcsFileFinishParam param, CloudwalkCallContext context) {
|
||||
try {
|
||||
FeignThreadLocalUtil.setRequestHeader((CloudwalkCallContext)context);
|
||||
FileFinishParam fileFinishParam = (FileFinishParam)BeanCopyUtils.copyProperties((Object)param, FileFinishParam.class);
|
||||
CloudwalkResult result = this.fileService.finish(fileFinishParam, context);
|
||||
if ("00000000".equals(result.getCode())) {
|
||||
boolean bl = true;
|
||||
return bl;
|
||||
}
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u5b8c\u6210\u5931\u8d25\uff1acode={},message={}", (Object)result.getCode(), (Object)result.getMessage());
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u5b8c\u6210\u63a5\u53e3\u9519\u8bef", (Throwable)e);
|
||||
}
|
||||
finally {
|
||||
FeignThreadLocalUtil.remove();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int queryDownloadStatus(String fileId, CloudwalkCallContext context) {
|
||||
try {
|
||||
FileGetParam fileGetParam = new FileGetParam();
|
||||
fileGetParam.setFileId(fileId);
|
||||
CloudwalkResult result = this.fileService.get(fileGetParam, context);
|
||||
if ("00000000".equals(result.getCode())) {
|
||||
return ((FileDetail)result.getData()).getStatus();
|
||||
}
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u521d\u59cb\u5316\u5931\u8d25\uff1acode={},message={}", (Object)result.getCode(), (Object)result.getMessage());
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u4e0b\u8f7d\u4efb\u52a1\u5b8c\u6210\u63a5\u53e3\u9519\u8bef", (Throwable)e);
|
||||
}
|
||||
return AcsFileStatusEnum.PRODUCING.getCode();
|
||||
}
|
||||
}
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.cwos.client.event.event.CustomEvent
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.event;
|
||||
|
||||
import cn.cloudwalk.cwos.client.event.event.CustomEvent;
|
||||
|
||||
public class CustomOpenDoorRecordEvent
|
||||
extends CustomEvent {
|
||||
private String businessId;
|
||||
private String panoramaImage;
|
||||
private String faceImage;
|
||||
private Long recognitionTime;
|
||||
private String areaId;
|
||||
private String districtId;
|
||||
private String deviceId;
|
||||
private String deviceAddress;
|
||||
private String deviceCode;
|
||||
private String deviceName;
|
||||
private String openDoorTypeMsg;
|
||||
private String openDoorTypeCode;
|
||||
private Integer recordResult;
|
||||
private String recognitionNo;
|
||||
private String recognitionFaceId;
|
||||
|
||||
public String getTopic() {
|
||||
return "ACS_OPEN_DOOR_RECORD_EVENT_TOPIC";
|
||||
}
|
||||
|
||||
public String getBusinessId() {
|
||||
return this.businessId;
|
||||
}
|
||||
|
||||
public void setBusinessId(String businessId) {
|
||||
this.businessId = businessId;
|
||||
}
|
||||
|
||||
public String getPanoramaImage() {
|
||||
return this.panoramaImage;
|
||||
}
|
||||
|
||||
public void setPanoramaImage(String panoramaImage) {
|
||||
this.panoramaImage = panoramaImage;
|
||||
}
|
||||
|
||||
public String getFaceImage() {
|
||||
return this.faceImage;
|
||||
}
|
||||
|
||||
public void setFaceImage(String faceImage) {
|
||||
this.faceImage = faceImage;
|
||||
}
|
||||
|
||||
public Long getRecognitionTime() {
|
||||
return this.recognitionTime;
|
||||
}
|
||||
|
||||
public void setRecognitionTime(Long recognitionTime) {
|
||||
this.recognitionTime = recognitionTime;
|
||||
}
|
||||
|
||||
public String getAreaId() {
|
||||
return this.areaId;
|
||||
}
|
||||
|
||||
public void setAreaId(String areaId) {
|
||||
this.areaId = areaId;
|
||||
}
|
||||
|
||||
public String getDistrictId() {
|
||||
return this.districtId;
|
||||
}
|
||||
|
||||
public void setDistrictId(String districtId) {
|
||||
this.districtId = districtId;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return this.deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceAddress() {
|
||||
return this.deviceAddress;
|
||||
}
|
||||
|
||||
public void setDeviceAddress(String deviceAddress) {
|
||||
this.deviceAddress = deviceAddress;
|
||||
}
|
||||
|
||||
public String getDeviceCode() {
|
||||
return this.deviceCode;
|
||||
}
|
||||
|
||||
public void setDeviceCode(String deviceCode) {
|
||||
this.deviceCode = deviceCode;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return this.deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getOpenDoorTypeMsg() {
|
||||
return this.openDoorTypeMsg;
|
||||
}
|
||||
|
||||
public void setOpenDoorTypeMsg(String openDoorTypeMsg) {
|
||||
this.openDoorTypeMsg = openDoorTypeMsg;
|
||||
}
|
||||
|
||||
public String getOpenDoorTypeCode() {
|
||||
return this.openDoorTypeCode;
|
||||
}
|
||||
|
||||
public void setOpenDoorTypeCode(String openDoorTypeCode) {
|
||||
this.openDoorTypeCode = openDoorTypeCode;
|
||||
}
|
||||
|
||||
public Integer getRecordResult() {
|
||||
return this.recordResult;
|
||||
}
|
||||
|
||||
public void setRecordResult(Integer recordResult) {
|
||||
this.recordResult = recordResult;
|
||||
}
|
||||
|
||||
public String getRecognitionNo() {
|
||||
return this.recognitionNo;
|
||||
}
|
||||
|
||||
public void setRecognitionNo(String recognitionNo) {
|
||||
this.recognitionNo = recognitionNo;
|
||||
}
|
||||
|
||||
public String getRecognitionFaceId() {
|
||||
return this.recognitionFaceId;
|
||||
}
|
||||
|
||||
public void setRecognitionFaceId(String recognitionFaceId) {
|
||||
this.recognitionFaceId = recognitionFaceId;
|
||||
}
|
||||
}
|
||||
|
||||
+592
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.export.AcsParallelismDownloadManager
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartAppendParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartFinishParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartInitParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.result.FilePartResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.param.AcsFileFinishParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.service.AcsDownloadCenterService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.annotation.ExcelAttribute
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.common.ExcelCallback
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsExportTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsFileStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.ExcelUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.FolderUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* cn.cloudwalk.intelligent.davinci.common.exception.DavinciServiceException
|
||||
* cn.cloudwalk.intelligent.davinci.storage.bean.file.dto.FileRemoveDTO
|
||||
* cn.cloudwalk.intelligent.davinci.storage.manager.FileStorageManager
|
||||
* cn.cloudwalk.intelligent.lock.annotation.RequiredLock
|
||||
* com.github.pagehelper.PageInfo
|
||||
* com.google.common.collect.Lists
|
||||
* javax.annotation.Resource
|
||||
* org.apache.commons.lang3.StringUtils
|
||||
* org.apache.poi.hssf.usermodel.HSSFCell
|
||||
* org.apache.poi.hssf.usermodel.HSSFCellStyle
|
||||
* org.apache.poi.hssf.usermodel.HSSFClientAnchor
|
||||
* org.apache.poi.hssf.usermodel.HSSFFont
|
||||
* org.apache.poi.hssf.usermodel.HSSFPatriarch
|
||||
* org.apache.poi.hssf.usermodel.HSSFRichTextString
|
||||
* org.apache.poi.hssf.usermodel.HSSFRow
|
||||
* org.apache.poi.hssf.usermodel.HSSFSheet
|
||||
* org.apache.poi.hssf.usermodel.HSSFWorkbook
|
||||
* org.apache.poi.ss.usermodel.Font
|
||||
* org.apache.poi.ss.usermodel.HorizontalAlignment
|
||||
* org.apache.poi.ss.usermodel.RichTextString
|
||||
* org.apache.poi.ss.usermodel.VerticalAlignment
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.beans.factory.annotation.Value
|
||||
* org.springframework.data.redis.core.RedisTemplate
|
||||
* org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.export.AcsParallelismDownloadManager;
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartAppendParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartFinishParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartInitParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.result.FilePartResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.param.AcsFileFinishParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.downloadcenter.service.AcsDownloadCenterService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService;
|
||||
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.common.ninca.accesscontrol.annotation.ExcelAttribute;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.common.ExcelCallback;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsExportTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsFileStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.ExcelUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.FolderUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.intelligent.davinci.common.exception.DavinciServiceException;
|
||||
import cn.cloudwalk.intelligent.davinci.storage.bean.file.dto.FileRemoveDTO;
|
||||
import cn.cloudwalk.intelligent.davinci.storage.manager.FileStorageManager;
|
||||
import cn.cloudwalk.intelligent.lock.annotation.RequiredLock;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Resource;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Font;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
import org.apache.poi.ss.usermodel.RichTextString;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
public abstract class AcsAbstractExportAsyncService<T, R>
|
||||
extends AbstractCloudwalkService {
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(AcsAbstractExportAsyncService.class);
|
||||
private static final Integer FILE_PART_BATCH_SIZE = 0x500001;
|
||||
@Value(value="${cloudwalk.access-control.export-max-record:1000}")
|
||||
private long EXPORT_MAX_RECORD;
|
||||
@Autowired
|
||||
private AcsParallelismDownloadManager acsParallelismDownloadManager;
|
||||
@Autowired
|
||||
private AcsFileStorageService acsFileStorageService;
|
||||
@Autowired
|
||||
private AcsDownloadCenterService acsDownloadCenterService;
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Autowired
|
||||
private FileStorageManager fileStorageManager;
|
||||
|
||||
@RequiredLock(name="T(cn.cloudwalk.common.ninca.accesscontrol.config.AcsLockConstants).LOCK_EXPORT_BUSINESSID_PREFIX.concat(#context.company.companyId)", lockWaitTime=5000L)
|
||||
public CloudwalkResult<Boolean> startExportTask(T param, Class<R> clazz, String fileName, AcsExportTypeEnum exportType, CloudwalkCallContext context) throws ServiceException {
|
||||
String cacheKey = "acs_export_prefix:#" + context.getCompany().getCompanyId();
|
||||
try {
|
||||
String taskId = (String)this.redisTemplate.opsForValue().get((Object)cacheKey);
|
||||
if (StringUtils.isNotBlank((String)taskId)) {
|
||||
return CloudwalkResult.fail((String)"76260308", (String)this.getMessage("76260308"));
|
||||
}
|
||||
String exportFileName = StringUtils.isNotBlank((String)fileName) ? fileName : this.getDefaultFileName();
|
||||
ExportRecordContext.Builder builder = new ExportRecordContext.Builder();
|
||||
ExportRecordContext exportRecordContext = builder.withFileName(exportFileName).withTaskStatus(AcsFileStatusEnum.PRODUCING.getCode()).build();
|
||||
((CompletableFuture)CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
String fileId = this.acsDownloadCenterService.createDownload(exportFileName, context);
|
||||
this.redisTemplate.opsForValue().set((Object)cacheKey, (Object)fileId, 5L, TimeUnit.MINUTES);
|
||||
exportRecordContext.setFileId(fileId);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.info("\u5bfc\u51fa\u65f6\uff0c\u521d\u59cb\u5316\u5bfc\u51fa\u4efb\u52a1\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
this.redisTemplate.delete((Object)cacheKey);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
}).thenAccept(n -> {
|
||||
try {
|
||||
if (exportType != null && AcsExportTypeEnum.QRCODE.getCode().equals(exportType.getCode())) {
|
||||
this.exportQrCode(param, exportRecordContext, context);
|
||||
} else {
|
||||
this.export(param, clazz, exportRecordContext, null, context);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.info("\u5bfc\u51fa\u65f6\u5f02\u5e38\uff0c\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new CompletionException(e);
|
||||
}
|
||||
finally {
|
||||
FeignThreadLocalUtil.remove();
|
||||
this.redisTemplate.delete((Object)cacheKey);
|
||||
}
|
||||
})).whenComplete((n, e) -> {
|
||||
if (null != e) {
|
||||
LOGGER.error("\u5f02\u6b65\u5bfc\u51fa\u4efb\u52a1\u8fd0\u884c\u5931\u8d25\uff0c\u539f\u56e0\uff1a", e);
|
||||
AcsFileFinishParam fileFinishParam = new AcsFileFinishParam();
|
||||
if (e.getCause() instanceof ServiceException) {
|
||||
ServiceException serviceException = (ServiceException)e.getCause();
|
||||
fileFinishParam.setErrorCode(serviceException.getCode());
|
||||
fileFinishParam.setErrorMessage(serviceException.getMessage());
|
||||
} else {
|
||||
fileFinishParam.setErrorCode("76260000");
|
||||
fileFinishParam.setErrorMessage(this.getMessage("76260000"));
|
||||
}
|
||||
fileFinishParam.setFileId(exportRecordContext.getFileId());
|
||||
fileFinishParam.setFileStatus(AcsFileStatusEnum.FAIL.getCode());
|
||||
this.acsDownloadCenterService.finishDownload(fileFinishParam, context);
|
||||
} else if (AcsFileStatusEnum.CANCELED.getCode().intValue() != exportRecordContext.getTaskStatus()) {
|
||||
LOGGER.info("\u5f02\u6b65\u5bfc\u51fa\u6210\u529f\u3002[{}]", (Object)exportRecordContext.toString());
|
||||
AcsFileFinishParam fileFinishParam = new AcsFileFinishParam();
|
||||
fileFinishParam.setFileId(exportRecordContext.getFileId());
|
||||
fileFinishParam.setFilePath(exportRecordContext.getFilePath());
|
||||
fileFinishParam.setFileSize(exportRecordContext.getFileSize());
|
||||
fileFinishParam.setFileStatus(AcsFileStatusEnum.FINISH.getCode());
|
||||
this.acsDownloadCenterService.finishDownload(fileFinishParam, context);
|
||||
} else if (StringUtils.isNotBlank((String)exportRecordContext.getFilePath())) {
|
||||
FileRemoveDTO fileRemoveDTO = new FileRemoveDTO();
|
||||
fileRemoveDTO.setFileList((List)Lists.newArrayList((Object[])new String[]{exportRecordContext.getFilePath()}));
|
||||
try {
|
||||
this.fileStorageManager.remove(fileRemoveDTO);
|
||||
}
|
||||
catch (DavinciServiceException e1) {
|
||||
this.logger.error("\u5220\u9664\u6587\u4ef6\u5931\u8d25\uff0cfileId=[{}]\uff0c\u539f\u56e0\uff1a", (Object)exportRecordContext.getFileId(), (Object)e1);
|
||||
}
|
||||
}
|
||||
});
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (Exception e2) {
|
||||
this.logger.error("\u5f02\u6b65\u5bfc\u51fa\u4efb\u52a1\u5f02\u5e38\uff0c\u539f\u56e0\uff1a", (Throwable)e2);
|
||||
throw new ServiceException((Throwable)e2);
|
||||
}
|
||||
}
|
||||
|
||||
private void exportQrCode(T param, ExportRecordContext exportRecordContext, CloudwalkCallContext context) throws Exception {
|
||||
byte[] fileByte;
|
||||
CloudwalkResult<String> localFile = this.createLocalFile(param, exportRecordContext.getFileName(), context);
|
||||
String localFilePath = (String)localFile.getData();
|
||||
File file = new File(localFilePath);
|
||||
if (!file.exists()) {
|
||||
throw new FileNotFoundException(localFilePath);
|
||||
}
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream((int)file.length());
|
||||
BufferedInputStream in = null;
|
||||
try {
|
||||
in = new BufferedInputStream(new FileInputStream(file));
|
||||
int buf_size = 1024;
|
||||
byte[] buffer = new byte[buf_size];
|
||||
int len = 0;
|
||||
while (-1 != (len = in.read(buffer, 0, buf_size))) {
|
||||
bos.write(buffer, 0, len);
|
||||
}
|
||||
fileByte = bos.toByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.logger.error("\u8bfb\u53d6\u672c\u5730\u6587\u4ef6\u5931\u8d25,\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u8bfb\u53d6\u672c\u5730\u6587\u4ef6\u5931\u8d25");
|
||||
}
|
||||
finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.logger.error("\u8bfb\u53d6\u672c\u5730\u6587\u4ef6\u5931\u8d25,\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
}
|
||||
}
|
||||
bos.close();
|
||||
}
|
||||
exportRecordContext.setFileSize(Long.valueOf(fileByte.length));
|
||||
String filePath = this.fileStore(exportRecordContext.getFileName() + ".zip", fileByte, exportRecordContext, context);
|
||||
exportRecordContext.setFilePath(filePath);
|
||||
try {
|
||||
FolderUtils.deleteFile((String)localFilePath);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.error("\u5220\u9664\u672c\u5730\u6587\u4ef6\u5931\u8d25,\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u5220\u9664\u672c\u5730\u6587\u4ef6\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void export(T param, Class<R> clazz, ExportRecordContext exportRecordContext, ExcelCallback callback, CloudwalkCallContext context) throws Exception {
|
||||
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||
String sheetName = exportRecordContext.getFileName();
|
||||
FeignThreadLocalUtil.setRequestHeader((CloudwalkCallContext)context);
|
||||
int startPage = 1;
|
||||
int pageSize = 100;
|
||||
long maxPageSize = this.EXPORT_MAX_RECORD / 100L;
|
||||
PageInfo pageInfo = new PageInfo();
|
||||
ArrayList<Object> list = this.getList(param, context, startPage, 100, pageInfo);
|
||||
Long totalRows = pageInfo.getTotal();
|
||||
Long totalPages = pageInfo.getPages();
|
||||
try (HSSFWorkbook workbook = new HSSFWorkbook();){
|
||||
int sheetSize = 65536;
|
||||
Field[] allFields = clazz.getDeclaredFields();
|
||||
ArrayList<Field> fields = new ArrayList<Field>();
|
||||
for (Field field : allFields) {
|
||||
ExcelAttribute attr = field.getAnnotation(ExcelAttribute.class);
|
||||
if (attr == null || !attr.isExport()) continue;
|
||||
fields.add(field);
|
||||
}
|
||||
long listSize = this.EXPORT_MAX_RECORD < totalRows ? this.EXPORT_MAX_RECORD : totalRows;
|
||||
int startRow = 0;
|
||||
int sheetNo = (int)listSize / sheetSize;
|
||||
block15: for (int index = 0; index <= sheetNo; ++index) {
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
workbook.setSheetName(index, sheetName + index);
|
||||
ExcelUtil.createRowHeard((HSSFSheet)sheet, fields, (HSSFWorkbook)workbook, (int)startRow);
|
||||
while (true) {
|
||||
if (this.isCancelDownload(exportRecordContext, context)) {
|
||||
output.close();
|
||||
return;
|
||||
}
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
list = this.getList(param, context, startPage, 100, pageInfo);
|
||||
}
|
||||
this.acsParallelismDownloadManager.parallelResolve(list, clazz);
|
||||
this.createRowContent(sheet, fields, workbook, list, (startPage - 1) * 100, (startPage - 1) * 100 + list.size(), startRow + 1);
|
||||
if (null != callback) {
|
||||
callback.call(workbook, sheet);
|
||||
}
|
||||
if ((long)(++startPage) > totalPages || (long)startPage > maxPageSize) continue block15;
|
||||
list = new ArrayList();
|
||||
}
|
||||
}
|
||||
output.flush();
|
||||
workbook.write((OutputStream)output);
|
||||
output.close();
|
||||
byte[] fileByte = output.toByteArray();
|
||||
exportRecordContext.setFileSize(Long.valueOf(fileByte.length));
|
||||
String filePath = this.fileStore(exportRecordContext.getFileName() + ".xls", fileByte, exportRecordContext, context);
|
||||
exportRecordContext.setFilePath(filePath);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new Exception("\u5c06list\u6570\u636e\u6e90\u7684\u6570\u636e\u5bfc\u5165\u5230excel\u8868\u5355\u5f02\u5e38!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isCancelDownload(ExportRecordContext exportRecordContext, CloudwalkCallContext context) {
|
||||
int taskStatus = this.acsDownloadCenterService.queryDownloadStatus(exportRecordContext.getFileId(), context);
|
||||
if (AcsFileStatusEnum.CANCELED.getCode() == taskStatus) {
|
||||
this.logger.info("\u5bfc\u51fa\u4efb\u52a1\u5df2\u53d6\u6d88\uff0cfileID=[{}]", (Object)exportRecordContext.getFileId());
|
||||
exportRecordContext.setTaskStatus(taskStatus);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ArrayList<R> getList(T param, CloudwalkCallContext context, int startPage, int pageSize, PageInfo pageInfo) throws ServiceException {
|
||||
CloudwalkPageInfo cloudwalkPageInfo = new CloudwalkPageInfo(startPage, pageSize);
|
||||
CloudwalkPageAble<R> dataPage = this.queryPage(param, cloudwalkPageInfo, context);
|
||||
pageInfo.setTotal(dataPage.getTotalRows());
|
||||
pageInfo.setPages((int)dataPage.getTotalPages());
|
||||
return Lists.newArrayList((Iterable)dataPage.getDatas());
|
||||
}
|
||||
|
||||
private int getColumnSize(Class clazz) {
|
||||
Field[] allFields = clazz.getDeclaredFields();
|
||||
int size = 0;
|
||||
for (Field field : allFields) {
|
||||
ExcelAttribute attr = field.getAnnotation(ExcelAttribute.class);
|
||||
if (attr == null || !attr.isExport()) continue;
|
||||
++size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
private void setRow1(HSSFWorkbook workBook, HSSFSheet sheet, String row1Str) {
|
||||
HSSFCellStyle cellStyle1 = workBook.createCellStyle();
|
||||
HSSFFont font1 = workBook.createFont();
|
||||
font1.setFontHeightInPoints((short)15);
|
||||
font1.setBold(Boolean.TRUE.booleanValue());
|
||||
cellStyle1.setAlignment(HorizontalAlignment.LEFT);
|
||||
cellStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
HSSFRichTextString row1String = new HSSFRichTextString(row1Str);
|
||||
row1String.applyFont(0, row1Str.length(), (Font)font1);
|
||||
sheet.getRow(0).getCell(0).setCellValue((RichTextString)row1String);
|
||||
sheet.getRow(0).getCell(0).setCellStyle(cellStyle1);
|
||||
}
|
||||
|
||||
private String fileStore(String fileName, byte[] bytes, ExportRecordContext exportRecordContext, CloudwalkCallContext context) throws ServiceException {
|
||||
int size = bytes.length;
|
||||
LOGGER.info("\u6587\u4ef6\u5927\u5c0f\u4e3a: {}", (Object)size);
|
||||
FilePartInitParam param = new FilePartInitParam();
|
||||
param.setFileName(fileName);
|
||||
LOGGER.info("\u6587\u4ef6\u5206\u7247\u521d\u59cb\u5316\u5f00\u59cb");
|
||||
CloudwalkResult result = this.acsFileStorageService.filePartInit(param);
|
||||
if (result.isSuccess()) {
|
||||
CloudwalkResult finishResult;
|
||||
LOGGER.info("\u6587\u4ef6\u5206\u7247\u521d\u59cb\u5316\u7ed3\u675f\uff0cuploadId = {}, filePath = {}", (Object)((FilePartResult)result.getData()).getUploadId(), (Object)((FilePartResult)result.getData()).getFilePath());
|
||||
FilePartResult filePartResult = (FilePartResult)result.getData();
|
||||
int times = 0;
|
||||
while (true) {
|
||||
int start;
|
||||
if (this.isCancelDownload(exportRecordContext, context)) {
|
||||
return ((FilePartResult)result.getData()).getFilePath();
|
||||
}
|
||||
int end = (start = times++ * FILE_PART_BATCH_SIZE) + FILE_PART_BATCH_SIZE > size ? size : start + FILE_PART_BATCH_SIZE;
|
||||
byte[] trunk = Arrays.copyOfRange(bytes, start, end);
|
||||
LOGGER.info("\u7b2c{}\u4e2a\u5206\u7247\u5f00\u59cb\u8ffd\u52a0\uff0cuploadId = {}, filePath = {}, size ; {}", new Object[]{times, filePartResult.getUploadId(), filePartResult.getFilePath(), trunk.length});
|
||||
FilePartAppendParam appendParam = new FilePartAppendParam();
|
||||
appendParam.setFilePath(filePartResult.getFilePath());
|
||||
appendParam.setPartNumber(Integer.valueOf(times));
|
||||
appendParam.setUploadId(filePartResult.getUploadId());
|
||||
appendParam.setContent((Object)trunk);
|
||||
this.acsFileStorageService.filePartAppend(appendParam);
|
||||
LOGGER.info("\u7b2c{}\u4e2a\u5206\u7247\u5b8c\u6210\u8ffd\u52a0\uff0cuploadId = {}, filePath = {}", new Object[]{times, filePartResult.getUploadId(), filePartResult.getFilePath()});
|
||||
if (end < size) continue;
|
||||
LOGGER.info("\u8ffd\u52a0\u5b8c\u6210\uff0c\u51c6\u5907\u7ed3\u675f\uff0cuploadId = {}, filePath = {}", (Object)filePartResult.getUploadId(), (Object)filePartResult.getFilePath());
|
||||
FilePartFinishParam finishParam = new FilePartFinishParam();
|
||||
finishParam.setFilePath(filePartResult.getFilePath());
|
||||
finishParam.setUploadId(filePartResult.getUploadId());
|
||||
finishParam.setFileSize(Long.valueOf(size));
|
||||
finishParam.setReturnType(Integer.valueOf(1));
|
||||
finishResult = this.acsFileStorageService.filePartFinish(finishParam);
|
||||
LOGGER.info("\u7ed3\u675f\u5b8c\u6210\uff0cuploadId = {}, filePath = {}, finishFilePath = {}", new Object[]{filePartResult.getUploadId(), filePartResult.getFilePath(), finishResult.getData()});
|
||||
if (finishResult.isSuccess()) break;
|
||||
}
|
||||
return ((String)finishResult.getData()).split("=")[1];
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
protected abstract CloudwalkPageAble<R> queryPage(T var1, CloudwalkPageInfo var2, CloudwalkCallContext var3) throws ServiceException;
|
||||
|
||||
protected abstract CloudwalkResult<String> createLocalFile(T var1, String var2, CloudwalkCallContext var3) throws ServiceException;
|
||||
|
||||
protected abstract String getDefaultFileName();
|
||||
|
||||
protected abstract String getDefaultFileTitleName();
|
||||
|
||||
protected ThreadPoolTaskExecutor getExportExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(5);
|
||||
executor.setMaxPoolSize(30);
|
||||
executor.setThreadNamePrefix("Export-Pool-Executor");
|
||||
executor.setQueueCapacity(25);
|
||||
executor.initialize();
|
||||
executor.setRejectedExecutionHandler((RejectedExecutionHandler)new ThreadPoolExecutor.AbortPolicy());
|
||||
return executor;
|
||||
}
|
||||
|
||||
private <T> void createRowContent(HSSFSheet sheet, List<Field> fields, HSSFWorkbook workbook, List<T> list, int startNo, int endNo, int rowIndex) throws Exception {
|
||||
String value = null;
|
||||
int hwPicType = 0;
|
||||
byte[] picByte = null;
|
||||
int listIndex = 0;
|
||||
for (int i = startNo; i < endNo; ++i) {
|
||||
HSSFRow row = sheet.createRow(i + 1);
|
||||
T vo = list.get(listIndex);
|
||||
++listIndex;
|
||||
for (int j = 0; j < fields.size(); ++j) {
|
||||
Field field = fields.get(j);
|
||||
field.setAccessible(true);
|
||||
ExcelAttribute attr = field.getAnnotation(ExcelAttribute.class);
|
||||
int col = j;
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank((CharSequence)attr.column())) {
|
||||
col = ExcelUtil.getExcelCol((String)attr.column());
|
||||
}
|
||||
if (!attr.isExport()) continue;
|
||||
HSSFCell cell = row.createCell(col);
|
||||
Class<?> classType = field.getType();
|
||||
if (field.get(vo) == null) continue;
|
||||
value = null;
|
||||
if (classType.isAssignableFrom(Date.class)) {
|
||||
value = DateUtils.formatDate((Date)((Date)field.get(vo)), (String)"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
if (classType.isAssignableFrom(Long.class) && attr.isDate()) {
|
||||
value = DateUtils.formatDate((Date)new Date((Long)field.get(vo)), (String)"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
if (attr.isPic()) {
|
||||
try {
|
||||
if (field.getType().equals(String.class)) {
|
||||
picByte = ExcelUtil.getBytesByUrl((String)((String)field.get(vo)));
|
||||
}
|
||||
picByte = (byte[])field.get(vo);
|
||||
}
|
||||
catch (Exception exception) {
|
||||
// empty catch block
|
||||
}
|
||||
hwPicType = 5;
|
||||
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
|
||||
HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 1020, 250, (short)col, row.getRowNum(), (short)col, row.getRowNum());
|
||||
patriarch.createPicture(anchor, workbook.addPicture(picByte, hwPicType));
|
||||
row.setHeight((short)1000);
|
||||
continue;
|
||||
}
|
||||
cell.setCellValue(field.get(vo) == null ? "" : (value == null ? String.valueOf(field.get(vo)) : value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<Long> exportCount() throws ServiceException {
|
||||
try {
|
||||
return CloudwalkResult.success((Object)this.EXPORT_MAX_RECORD);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u83b7\u53d6\u6700\u5927\u5bfc\u51fa\u8bb0\u5f55\u5931\u8d25", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ExportRecordContext {
|
||||
private String fileId;
|
||||
private String filePath;
|
||||
private String fileName;
|
||||
private Long fileSize;
|
||||
private int taskStatus;
|
||||
|
||||
private ExportRecordContext() {
|
||||
}
|
||||
|
||||
public int getTaskStatus() {
|
||||
return this.taskStatus;
|
||||
}
|
||||
|
||||
public void setTaskStatus(int taskStatus) {
|
||||
this.taskStatus = taskStatus;
|
||||
}
|
||||
|
||||
public String getFileId() {
|
||||
return this.fileId;
|
||||
}
|
||||
|
||||
public void setFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
}
|
||||
|
||||
public String getFilePath() {
|
||||
return this.filePath;
|
||||
}
|
||||
|
||||
public void setFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return this.fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public Long getFileSize() {
|
||||
return this.fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(Long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ExportRecordContext{fileId='" + this.fileId + '\'' + ", filePath='" + this.filePath + '\'' + ", fileName='" + this.fileName + '\'' + ", fileSize=" + this.fileSize + ", taskStatus=" + this.taskStatus + '}';
|
||||
}
|
||||
|
||||
private static class Builder {
|
||||
private String fileId;
|
||||
private String filePath;
|
||||
private String fileName;
|
||||
private Long fileSize;
|
||||
private int taskStatus;
|
||||
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
public Builder withTaskStatus(int taskStatus) {
|
||||
this.taskStatus = taskStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withFileId(String fileId) {
|
||||
this.fileId = fileId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withFilePath(String filePath) {
|
||||
this.filePath = filePath;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder withFileSize(Long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExportRecordContext build() {
|
||||
ExportRecordContext context = new ExportRecordContext();
|
||||
context.setFileId(this.fileId);
|
||||
context.setFileSize(this.fileSize);
|
||||
context.setFilePath(this.filePath);
|
||||
context.setFileName(this.fileName);
|
||||
context.setTaskStatus(this.taskStatus);
|
||||
return context;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceNewQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsDeviceRecordExcelResult
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceNewQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceNewResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsDeviceRecordExcelResult;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsDeviceNewQueryParam, AcsDeviceRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u95e8\u7981\u8bbe\u5907\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u95e8\u7981\u8bbe\u5907\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private AcsDeviceService acsDeviceService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsDeviceRecordExcelResult> queryPage(AcsDeviceNewQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult result = this.acsDeviceService.devicePage(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsDeviceRecordExcelResult> excelResults = new ArrayList<AcsDeviceRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsDeviceNewResult detailResult : results) {
|
||||
AcsDeviceRecordExcelResult excelResult = (AcsDeviceRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsDeviceRecordExcelResult.class);
|
||||
if (!ObjectUtils.isEmpty((Object)detailResult.getDeviceOnlineStatus())) {
|
||||
if (detailResult.getDeviceOnlineStatus() == 2) {
|
||||
excelResult.setDeviceOnlineStatus("\u5728\u7ebf");
|
||||
} else {
|
||||
excelResult.setDeviceOnlineStatus("\u79bb\u7ebf");
|
||||
}
|
||||
}
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsDeviceNewQueryParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsEvacuateRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsEvacuateRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsEvacuateRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsEvacuateRecordService;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsEvacuateRecordExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsEvacuateRecordPageParam, AcsEvacuateRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u7d27\u6025\u758f\u6563\u8bb0\u5f55\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u7d27\u6025\u758f\u6563\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private AcsEvacuateRecordService acsEvacuateRecordService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsEvacuateRecordExcelResult> queryPage(AcsEvacuateRecordPageParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult result = this.acsEvacuateRecordService.page(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsEvacuateRecordExcelResult> excelResults = new ArrayList<AcsEvacuateRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsEvacuateRecordResult detailResult : results) {
|
||||
AcsEvacuateRecordExcelResult excelResult = (AcsEvacuateRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsEvacuateRecordExcelResult.class);
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsEvacuateRecordPageParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsOpenRecordExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsRecordDetailParam, AcsRecordDetailExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u5f00\u95e8\u8bb0\u5f55\u660e\u7ec6\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u95e8\u7981\u660e\u7ec6";
|
||||
@Autowired
|
||||
private DoorOpenRecordService doorOpenRecordService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsRecordDetailExcelResult> queryPage(AcsRecordDetailParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
CloudwalkResult result = this.doorOpenRecordService.openRecord(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsRecordDetailExcelResult> excelResults = new ArrayList<AcsRecordDetailExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsRecordDetailResult detailResult : results) {
|
||||
AcsRecordDetailExcelResult excelResult = (AcsRecordDetailExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsRecordDetailExcelResult.class);
|
||||
excelResult.setDeviceLocaltion(detailResult.getDistrictName() + " " + detailResult.getAreaName());
|
||||
Date d = new Date(detailResult.getRecognitionTime());
|
||||
excelResult.setOpenTime(sf.format(d));
|
||||
if (detailResult.getScore() != null) {
|
||||
excelResult.setScore(detailResult.getScore().multiply(new BigDecimal(100)));
|
||||
}
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsRecordDetailParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsOperateRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.result.AcsOperateRecordExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.acsswitch.service.AcsSwitchService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.param.AcsOperateRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.result.AcsOperateRecordExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.acsswitch.service.AcsSwitchService;
|
||||
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.common.ninca.accesscontrol.bean.record.AcsOperateRecordResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsOperateRecordExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsOperateRecordPageParam, AcsOperateRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u7acb\u5373\u5f00\u95e8\u8bb0\u5f55\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u7acb\u5373\u5f00\u95e8\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private AcsSwitchService acsSwitchService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsOperateRecordExcelResult> queryPage(AcsOperateRecordPageParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult result = this.acsSwitchService.pageRecord(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsOperateRecordExcelResult> excelResults = new ArrayList<AcsOperateRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsOperateRecordResultDTO detailResult : results) {
|
||||
AcsOperateRecordExcelResult excelResult = (AcsOperateRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsOperateRecordExcelResult.class);
|
||||
if (!ObjectUtils.isEmpty((Object)detailResult.getStatus())) {
|
||||
if (detailResult.getStatus() == 0) {
|
||||
excelResult.setStatus("\u521d\u59cb\u5316");
|
||||
} else {
|
||||
excelResult.setStatus("\u5df2\u5339\u914d");
|
||||
}
|
||||
}
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsOperateRecordPageParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsPersoncCardCompareExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsRecogRecordPageParam, AcsRecogRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u4eba\u8bc1\u6bd4\u5bf9\u8bb0\u5f55\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u4eba\u8bc1\u6bd4\u5bf9\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private DoorOpenRecordService doorOpenRecordService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsRecogRecordExcelResult> queryPage(AcsRecogRecordPageParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
CloudwalkResult result = this.doorOpenRecordService.recogRecordPage(param, pageInfo, context, true);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsRecogRecordExcelResult> excelResults = new ArrayList<AcsRecogRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsRecogRecordResult detailResult : results) {
|
||||
AcsRecogRecordExcelResult excelResult = (AcsRecogRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsRecogRecordExcelResult.class);
|
||||
excelResult.setDeviceLocaltion(detailResult.getDistrictName() + " " + detailResult.getAreaName());
|
||||
excelResult.setRecognitionResult(detailResult.getRecognitionResult() == 1 ? "\u6210\u529f" : "\u5931\u8d25");
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsRecogRecordPageParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceQrcodeParam
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceQueryTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.FolderUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.QrcodeUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.ZipUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* net.lingala.zip4j.exception.ZipException
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsDeviceQrcodeParam;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.device.dto.AcsDeviceQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceQueryTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.FolderUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.QrcodeUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.ZipUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.attribute.FileAttribute;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import net.lingala.zip4j.exception.ZipException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsQrcodeExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsDeviceQrcodeParam, Boolean> {
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
@Autowired
|
||||
private AcsDeviceManager acsDeviceManager;
|
||||
@Autowired
|
||||
private AccessControlProperties accessControlProperties;
|
||||
private static final DateTimeFormatter DIR_DATE_FORMAT = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u95e8\u7981\u4e8c\u7ef4\u7801\u5bfc\u51fa";
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<Boolean> queryPage(AcsDeviceQrcodeParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsDeviceQrcodeParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u6279\u91cf\u751f\u6210\u95e8\u7981\u4e8c\u7ef4\u7801\u5f00\u59cb:AcsDeviceQrcodeParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
List<DeviceResult> deviceInfos = this.getDeviceInfos(param.getDeviceIds(), context);
|
||||
String filePath = this.createDir(fileName);
|
||||
this.createQrcode(deviceInfos, context, filePath);
|
||||
this.zip(filePath);
|
||||
this.deleteFolder(filePath);
|
||||
this.logger.info("\u6279\u91cf\u751f\u6210\u95e8\u7981\u4e8c\u7ef4\u7801\u7ed3\u675f");
|
||||
return CloudwalkResult.success((Object)(filePath + ".zip"));
|
||||
}
|
||||
|
||||
private void deleteFolder(String filePath) throws ServiceException {
|
||||
try {
|
||||
FolderUtils.deleteFolder((String)filePath);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u5220\u9664\u6587\u4ef6\u5939\u5931\u8d25,\u539f\u56e0=[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u5220\u9664\u6587\u4ef6\u5939\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void zip(String filePath) throws ServiceException {
|
||||
try {
|
||||
ZipUtils.zip((String)filePath);
|
||||
}
|
||||
catch (ZipException e) {
|
||||
this.logger.error("\u538b\u7f29\u6587\u4ef6\u5939\u5931\u8d25,filePath=[{}],\u539f\u56e0=[{}]", new Object[]{filePath, e.getMessage(), e});
|
||||
throw new ServiceException("\u538b\u7f29\u6587\u4ef6\u5939\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private String createDir(String fileName) throws ServiceException {
|
||||
String filePath;
|
||||
Path zipDir = Paths.get(System.getProperty("user.dir") + File.separator + this.accessControlProperties.getDownDir() + File.separator + fileName, new String[0]);
|
||||
try {
|
||||
Path directories = Files.createDirectories(zipDir, new FileAttribute[0]);
|
||||
filePath = directories.toString();
|
||||
this.logger.info("\u6279\u91cf\u751f\u6210\u95e8\u7981\u4e8c\u7ef4\u7801\u672c\u5730\u6587\u4ef6\u8def\u5f84=[{}]", (Object)filePath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
this.logger.error("\u521b\u5efa\u95e8\u7981\u4e8c\u7ef4\u7801\u5bfc\u51fa\u6587\u4ef6\u5939\u5931\u8d25,\u539f\u56e0={}", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u521b\u5efa\u95e8\u7981\u4e8c\u7ef4\u7801\u5bfc\u51fa\u6587\u4ef6\u5939\u5931\u8d25");
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + LocalDateTime.now().format(DIR_DATE_FORMAT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<DeviceResult> getDeviceInfos(List<String> deviceIds, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsDeviceQueryDTO dto = new AcsDeviceQueryDTO();
|
||||
dto.setQueryParent(AcsDeviceQueryTypeEnum.QUERY_MAIN.getCode());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setDeviceIds(deviceIds);
|
||||
try {
|
||||
Map defaultReqesutHeader = FeignThreadLocalUtil.getDefaultReqesutHeader((String)context.getCompany().getCompanyId());
|
||||
FeignThreadLocalUtil.set((Map)defaultReqesutHeader);
|
||||
List list = this.acsDeviceManager.list(dto);
|
||||
if (CollectionUtils.isEmpty((Collection)list)) {
|
||||
throw new ServiceException("\u95e8\u7981\u8bbe\u5907\u4e0d\u5b58\u5728");
|
||||
}
|
||||
List acsDeviceIds = list.stream().map(AcsDeviceResultDTO::getDeviceId).collect(Collectors.toList());
|
||||
DeviceQueryParam deviceQueryParam = new DeviceQueryParam();
|
||||
deviceQueryParam.setIds(acsDeviceIds);
|
||||
CloudwalkResult deviceResult = this.deviceService.list(deviceQueryParam, context);
|
||||
if (!deviceResult.isSuccess() || CollectionUtils.isEmpty((Collection)((Collection)deviceResult.getData()))) {
|
||||
throw new ServiceException("\u67e5\u8be2\u8bbe\u5907\u5931\u8d25\u6216\u8bbe\u5907\u4e0d\u5b58\u5728");
|
||||
}
|
||||
List list2 = (List)deviceResult.getData();
|
||||
return list2;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
throw new ServiceException("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u5217\u8868\u6570\u636e\u5e93\u5f02\u5e38");
|
||||
}
|
||||
finally {
|
||||
FeignThreadLocalUtil.remove();
|
||||
}
|
||||
}
|
||||
|
||||
private void createQrcode(List<DeviceResult> deviceInfos, CloudwalkCallContext context, String path) {
|
||||
for (DeviceResult device : deviceInfos) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(this.accessControlProperties.getQrcodeOpenDoorUrl());
|
||||
sb.append("?businessId=");
|
||||
sb.append(context.getCompany().getCompanyId());
|
||||
sb.append("&deviceId=");
|
||||
sb.append(device.getId());
|
||||
sb.append("&businessCode=");
|
||||
sb.append(context.getCompany().getCorpCode());
|
||||
String name = device.getDeviceName() + "_" + device.getDeviceCode();
|
||||
QrcodeUtils.createQrcode((String)sb.toString(), (String)name, (String)path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsRecogRecordExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsRecogRecordPageParam, AcsRecogRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u8bc6\u522b\u8bb0\u5f55\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u8bc6\u522b\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private DoorOpenRecordService doorOpenRecordService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsRecogRecordExcelResult> queryPage(AcsRecogRecordPageParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
CloudwalkResult result = this.doorOpenRecordService.recogRecordPage(param, pageInfo, context, true);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsRecogRecordExcelResult> excelResults = new ArrayList<AcsRecogRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsRecogRecordResult detailResult : results) {
|
||||
AcsRecogRecordExcelResult excelResult = (AcsRecogRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsRecogRecordExcelResult.class);
|
||||
excelResult.setDeviceLocaltion(detailResult.getDistrictName() + " " + detailResult.getAreaName());
|
||||
excelResult.setRecognitionResult(detailResult.getRecognitionResult() == 1 ? "\u6210\u529f" : "\u5931\u8d25");
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsRecogRecordPageParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsPersonRecordExcelResult
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsPersonRecordExcelResult;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsRulePersonExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsPersonQueryParam, AcsPersonRecordExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u901a\u884c\u4eba\u5458\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u901a\u884c\u4eba\u5458\u8bb0\u5f55";
|
||||
@Autowired
|
||||
private AcsPersonService acsPersonService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsPersonRecordExcelResult> queryPage(AcsPersonQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult result = this.acsPersonService.page(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsPersonRecordExcelResult> excelResults = new ArrayList<AcsPersonRecordExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsPersonResult detailResult : results) {
|
||||
AcsPersonRecordExcelResult excelResult = (AcsPersonRecordExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsPersonRecordExcelResult.class);
|
||||
if (!CollectionUtils.isEmpty((Collection)detailResult.getOrganizationNames())) {
|
||||
String orgNames = detailResult.getOrganizationNames().stream().collect(Collectors.joining(","));
|
||||
excelResult.setOrgNames(orgNames);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)detailResult.getLabelNames())) {
|
||||
String labelNames = detailResult.getLabelNames().stream().collect(Collectors.joining(","));
|
||||
excelResult.setLabelNames(labelNames);
|
||||
}
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsPersonQueryParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsTemperatureRecordDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailExcelResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.export;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsTemperatureRecordDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailExcelResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
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.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.export.AcsAbstractExportAsyncService;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsTemperatureExportAsyncService
|
||||
extends AcsAbstractExportAsyncService<AcsTemperatureRecordDetailParam, AcsTemperatureRecordDetailExcelResult> {
|
||||
private static final String DEFAULT_EXPORT_FILE_NAME = "\u5f02\u5e38\u4f53\u6e29\u8bb0\u5f55\u660e\u7ec6\u5bfc\u51fa";
|
||||
private static final String DEFAULT_EXPORT_FILE_TITLE_NAME = "\u5f02\u5e38\u4f53\u6e29\u660e\u7ec6";
|
||||
@Autowired
|
||||
private DoorOpenRecordService doorOpenRecordService;
|
||||
|
||||
@Override
|
||||
protected CloudwalkPageAble<AcsTemperatureRecordDetailExcelResult> queryPage(AcsTemperatureRecordDetailParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
CloudwalkResult result = this.doorOpenRecordService.temperature(param, pageInfo, context);
|
||||
if (result.isSuccess()) {
|
||||
ArrayList<AcsTemperatureRecordDetailExcelResult> excelResults = new ArrayList<AcsTemperatureRecordDetailExcelResult>();
|
||||
if (CollectionUtils.isNotEmpty((Collection)((CloudwalkPageAble)result.getData()).getDatas())) {
|
||||
List results = (List)((CloudwalkPageAble)result.getData()).getDatas();
|
||||
for (AcsTemperatureRecordDetailResult detailResult : results) {
|
||||
AcsTemperatureRecordDetailExcelResult excelResult = (AcsTemperatureRecordDetailExcelResult)BeanCopyUtils.copyProperties((Object)detailResult, AcsTemperatureRecordDetailExcelResult.class);
|
||||
excelResult.setDeviceLocaltion(detailResult.getDistrictName() + " " + detailResult.getAreaName());
|
||||
Date d = new Date(detailResult.getRecognitionTime());
|
||||
excelResult.setAlarmTime(sf.format(d));
|
||||
if (detailResult.getScore() != null) {
|
||||
excelResult.setScore(detailResult.getScore().multiply(new BigDecimal(100)));
|
||||
}
|
||||
if (detailResult.getTempScore() != null) {
|
||||
excelResult.setAlarmCont("\u4f53\u6e29" + detailResult.getTempScore());
|
||||
}
|
||||
excelResults.add(excelResult);
|
||||
}
|
||||
}
|
||||
return new CloudwalkPageAble(excelResults, pageInfo, ((CloudwalkPageAble)result.getData()).getTotalRows());
|
||||
}
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CloudwalkResult<String> createLocalFile(AcsTemperatureRecordDetailParam param, String fileName, CloudwalkCallContext context) throws ServiceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return DEFAULT_EXPORT_FILE_NAME + DateUtils.formatDate((Date)new Date(), (String)"yyyyMMddHHmmss");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileTitleName() {
|
||||
return DEFAULT_EXPORT_FILE_TITLE_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonData
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStorePersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.passtime;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonData;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStorePersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.label.result.LabelResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.organization.result.OrganizationResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService;
|
||||
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.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
public class AbstractAcsPassService
|
||||
extends AbstractCloudwalkService {
|
||||
@Resource
|
||||
private ImageStoreService imageStoreService;
|
||||
@Resource
|
||||
private AcsPassTimeService acsPassTimeService;
|
||||
|
||||
protected ImageStoreDetailResult getImageStoreDetail(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStoreQueryParam param = new ImageStoreQueryParam();
|
||||
param.setId(imageStoreId);
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u8be6\u60c5\u5165\u53c2\uff1aImageStoreQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult imageStoreDetail = this.imageStoreService.detail(param, context);
|
||||
if (!imageStoreDetail.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u8be6\u60c5\u5931\u8d25\uff0c\u539f\u56e0\uff1a" + imageStoreDetail.getMessage());
|
||||
throw new ServiceException("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u8be6\u60c5\u5931\u8d25");
|
||||
}
|
||||
return (ImageStoreDetailResult)imageStoreDetail.getData();
|
||||
}
|
||||
|
||||
protected ImageStoreEditParam getEditParamByImageStore(ImageStoreDetailResult imageStoreDetail) {
|
||||
ImageStoreEditParam param = new ImageStoreEditParam();
|
||||
BeanCopyUtils.copyProperties((Object)imageStoreDetail, (Object)param);
|
||||
param.setIncludeOrganizations(imageStoreDetail.getIncludeOrganizations().stream().map(OrganizationResult::getId).collect(Collectors.toList()));
|
||||
param.setIncludeLabels(imageStoreDetail.getIncludeLabels().stream().map(LabelResult::getId).collect(Collectors.toList()));
|
||||
param.setIncludePersons(this.getImageStorePersonData(imageStoreDetail.getIncludePersons()));
|
||||
param.setExcludeLabels(imageStoreDetail.getExcludeLabels().stream().map(LabelResult::getId).collect(Collectors.toList()));
|
||||
param.setExcludePersons(imageStoreDetail.getExcludePersons().stream().map(ImgStorePersonResult::getId).collect(Collectors.toList()));
|
||||
return param;
|
||||
}
|
||||
|
||||
private List<ImageStorePersonData> getImageStorePersonData(List<ImgStorePersonResult> imgStorePersonResults) {
|
||||
ArrayList<ImageStorePersonData> personDataList = new ArrayList<ImageStorePersonData>();
|
||||
for (ImgStorePersonResult personResult : imgStorePersonResults) {
|
||||
ImageStorePersonData personData = new ImageStorePersonData();
|
||||
BeanCopyUtils.copyProperties((Object)personResult, (Object)personData);
|
||||
personData.setObjectId(personResult.getId());
|
||||
personDataList.add(personData);
|
||||
}
|
||||
return personDataList;
|
||||
}
|
||||
|
||||
protected AcsPassTimeResult getPassTimeById(String passableTimeId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassTimeQueryParam passTimeQueryParam = new AcsPassTimeQueryParam();
|
||||
passTimeQueryParam.setId(passableTimeId);
|
||||
CloudwalkResult passTimeResult = this.acsPassTimeService.get(passTimeQueryParam, context);
|
||||
if (!passTimeResult.isSuccess()) {
|
||||
this.logger.error("\u901a\u884c\u65f6\u95f4\u67e5\u8be2\u5931\u8d25,\u539f\u56e0\uff1a" + passTimeResult.getMessage());
|
||||
throw new ServiceException(passTimeResult.getCode(), passTimeResult.getMessage());
|
||||
}
|
||||
return (AcsPassTimeResult)passTimeResult.getData();
|
||||
}
|
||||
}
|
||||
|
||||
+430
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreAddParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppBindParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppUnbindParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceImageStoreAppBindService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleNewParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleDeleteDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleEditDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsPassTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.transaction.annotation.Propagation
|
||||
* org.springframework.transaction.annotation.Transactional
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.passtime;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreAddParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreDelParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.common.AcsApplicationService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppBindParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.DeviceImageStoreAppUnbindParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceImageStoreAppBindService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleNewParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleDeleteDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleEditDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsPassTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.passtime.AbstractAcsPassService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class AcsPassRuleServiceImpl
|
||||
extends AbstractAcsPassService
|
||||
implements AcsPassRuleService {
|
||||
@Resource
|
||||
private ImageStoreService imageStoreService;
|
||||
@Autowired
|
||||
private AcsApplicationService acsApplicationService;
|
||||
@Resource
|
||||
private AcsPassRuleManager acsPassRuleManager;
|
||||
@Resource
|
||||
private AcsDeviceImageStoreAppBindService acsDeviceImageStoreAppBindService;
|
||||
@Autowired
|
||||
private AcsDeviceService acsDeviceService;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<String> add(AcsPassRuleNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u6dfb\u52a0\u901a\u884c\u89c4\u5219\u5165\u53c2\uff1aAcsPassRuleNewParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
AcsPassTimeResult passTimeResult = new AcsPassTimeResult();
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId()) && (passTimeResult = this.getPassTimeById(param.getPassableTimeId(), context)) == null) {
|
||||
throw new ServiceException("76260516", this.getMessage("76260516"));
|
||||
}
|
||||
String imageStoreId = this.addImageStore(param, context, passTimeResult);
|
||||
AcsPassRuleAddDto dto = new AcsPassRuleAddDto();
|
||||
BeanCopyUtils.copyProperties((Object)passTimeResult, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setName(param.getRuleName());
|
||||
dto.setImageStoreId(imageStoreId);
|
||||
dto.setDeviceCode(param.getDeviceCode());
|
||||
dto.setDeviceId(param.getDeviceId());
|
||||
dto.setPassableTimeId(param.getPassableTimeId());
|
||||
if (StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
dto.setBeginDate(param.getStartTime());
|
||||
dto.setEndDate(param.getEndTime());
|
||||
}
|
||||
try {
|
||||
this.acsPassRuleManager.add(dto);
|
||||
return CloudwalkResult.success((Object)imageStoreId);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u6dfb\u52a0\u901a\u884c\u89c4\u5219\u5931\u8d25");
|
||||
throw new ServiceException("76260505", this.getMessage("76260505"));
|
||||
}
|
||||
}
|
||||
|
||||
private String addImageStore(AcsPassRuleNewParam param, CloudwalkCallContext context, AcsPassTimeResult passTimeResult) throws ServiceException {
|
||||
ImageStoreAddParam imageStoreAddParam = new ImageStoreAddParam();
|
||||
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)imageStoreAddParam);
|
||||
imageStoreAddParam.setExpiryBeginDate(param.getStartTime());
|
||||
imageStoreAddParam.setExpiryEndDate(param.getEndTime());
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
imageStoreAddParam.setValidDateCron(JSONObject.parseArray((String)passTimeResult.getValidDateCron(), String.class));
|
||||
imageStoreAddParam.setExpiryBeginDate(passTimeResult.getBeginDate());
|
||||
imageStoreAddParam.setExpiryEndDate(passTimeResult.getEndDate());
|
||||
}
|
||||
imageStoreAddParam.setName(param.getDeviceCode() + param.getRuleName());
|
||||
imageStoreAddParam.setType(Short.valueOf((short)1));
|
||||
imageStoreAddParam.setSourceApplicationId(applicationId);
|
||||
imageStoreAddParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u65b0\u589e\u56fe\u5e93\u5165\u53c2\uff1aimageStoreAddParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)imageStoreAddParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult imageStoreId = this.imageStoreService.add(imageStoreAddParam, context);
|
||||
if (!imageStoreId.isSuccess()) {
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u65b0\u589e\u56fe\u5e93\u5931\u8d25,\u539f\u56e0\uff1a" + imageStoreId.getMessage());
|
||||
throw new ServiceException(imageStoreId.getCode(), imageStoreId.getMessage());
|
||||
}
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u65b0\u589e\u56fe\u5e93\u51fa\u53c2\uff1aimageStoreId=[{}]", imageStoreId.getData());
|
||||
try {
|
||||
DeviceImageStoreAppBindParam bindParam = new DeviceImageStoreAppBindParam();
|
||||
bindParam.setImageStoreId((String)imageStoreId.getData());
|
||||
bindParam.setDeviceId(param.getDeviceId());
|
||||
bindParam.setApplicationId(applicationId);
|
||||
this.acsDeviceImageStoreAppBindService.bindAppImageStoreDevice(bindParam, context);
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u56fe\u5e93\u5173\u8054\u5931\u8d25,\u56fe\u5e93id={},\u539f\u56e0:{}", imageStoreId.getData(), (Object)e.getMessage());
|
||||
ImageStoreDelParam delParam = new ImageStoreDelParam();
|
||||
delParam.setId((String)imageStoreId.getData());
|
||||
this.logger.info("\u56de\u6eda\u5220\u9664\u56fe\u5e93\u5f00\u59cb,delParam={},context={}", JSONObject.toJSON((Object)delParam), JSONObject.toJSON((Object)context));
|
||||
CloudwalkResult deleteResult = this.imageStoreService.delete(delParam, context);
|
||||
this.logger.info("\u5220\u9664\u56fe\u5e93\uff1a\u56fe\u5e93id={},\u7ed3\u679c:{}", (Object)imageStoreId, (Object)deleteResult.getMessage());
|
||||
throw new ServiceException(e.getCode(), e.getMessage());
|
||||
}
|
||||
return (String)imageStoreId.getData();
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> update(AcsPassRuleEditParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7f16\u8f91\u901a\u884c\u89c4\u5219\u8be6\u60c5\u5165\u53c2\uff1aAcsPassRuleEditParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
this.checkDefaultRule(param.getDeviceId(), Collections.singletonList(param.getId()), context);
|
||||
AcsPassRuleEditDto dto = new AcsPassRuleEditDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setValidDateCron(null);
|
||||
dto.setValidDateJson(null);
|
||||
dto.setBeginDate(param.getStartTime());
|
||||
dto.setEndDate(param.getEndTime());
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
AcsPassTimeResult passTimeResult = this.getPassTimeById(param.getPassableTimeId(), context);
|
||||
BeanCopyUtils.copyProperties((Object)passTimeResult, (Object)dto);
|
||||
}
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setName(param.getRuleName());
|
||||
dto.setPassableTimeId(param.getPassableTimeId());
|
||||
try {
|
||||
this.acsPassRuleManager.edit(dto);
|
||||
List<AcsPassRuleResultDto> ruleList = this.getRuleByIds(Collections.singletonList(dto.getId()), context);
|
||||
this.updateImageStore(param, ruleList.get(0), context);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7f16\u8f91\u901a\u884c\u89c4\u5219\u7f16\u8f91\u5931\u8d25");
|
||||
throw new ServiceException("76260506", this.getMessage("76260506"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResultDto> checkDefaultRule(String deviceId, List<String> ruleIds, CloudwalkCallContext context) throws ServiceException {
|
||||
String imageStoreId;
|
||||
List<AcsPassRuleResultDto> resultDtoList = this.getRuleByIds(ruleIds, context);
|
||||
List imageStoreIds = resultDtoList.stream().map(AcsPassRuleResultDto::getImageStoreId).collect(Collectors.toList());
|
||||
if (imageStoreIds.contains(imageStoreId = this.getAcsImageStore(deviceId, context))) {
|
||||
throw new ServiceException("\u95e8\u7981\u9ed8\u8ba4\u89c4\u5219\u4e0d\u53ef\u7f16\u8f91\u548c\u5220\u9664");
|
||||
}
|
||||
return resultDtoList;
|
||||
}
|
||||
|
||||
private void updateImageStore(AcsPassRuleEditParam param, AcsPassRuleResultDto ruleResultDto, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStoreDetailResult imageStoreDetail = this.getImageStoreDetail(ruleResultDto.getImageStoreId(), context);
|
||||
ImageStoreEditParam imageStoreEditParam = this.getEditParamByImageStore(imageStoreDetail);
|
||||
BeanCopyUtils.copyProperties((Object)ruleResultDto, (Object)imageStoreEditParam);
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)imageStoreEditParam);
|
||||
imageStoreEditParam.setName(param.getDeviceCode() + param.getRuleName());
|
||||
imageStoreEditParam.setExpiryBeginDate(param.getStartTime());
|
||||
imageStoreEditParam.setExpiryEndDate(param.getEndTime());
|
||||
imageStoreEditParam.setValidDateCron(null);
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
imageStoreEditParam.setValidDateCron(JSONObject.parseArray((String)ruleResultDto.getValidDateCron(), String.class));
|
||||
imageStoreEditParam.setExpiryBeginDate(ruleResultDto.getBeginDate());
|
||||
imageStoreEditParam.setExpiryEndDate(ruleResultDto.getEndDate());
|
||||
}
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u7f16\u8f91\u56fe\u5e93\u5165\u53c2\uff1aImageStoreEditParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)imageStoreEditParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult result = this.imageStoreService.edit(imageStoreEditParam, context);
|
||||
if (!result.isSuccess()) {
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u7f16\u8f91\u56fe\u5e93\u5931\u8d25\uff1a\u539f\u56e0:" + result.getMessage());
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResultDto> getRuleByIds(List<String> ruleIds, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
dto.setIds(ruleIds);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
List ruleResultDtos = this.acsPassRuleManager.query(dto);
|
||||
return ruleResultDtos;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u901a\u884c\u89c4\u5219\u67e5\u8be2\u5931\u8d25");
|
||||
throw new ServiceException("\u901a\u884c\u89c4\u5219\u67e5\u8be2\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> delete(AcsPassRuleDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5220\u9664\u901a\u884c\u89c4\u5219\u5165\u53c2\uff1aAcsPassRuleDeleteParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
List<AcsPassRuleResultDto> resultDtos = this.checkDefaultRule(param.getDeviceId(), param.getIds(), context);
|
||||
String applicationId = this.acsApplicationService.getApplicationId(context.getCompany().getCompanyId());
|
||||
for (AcsPassRuleResultDto dto : resultDtos) {
|
||||
DeviceImageStoreAppUnbindParam unbindParam = new DeviceImageStoreAppUnbindParam();
|
||||
unbindParam.setApplicationId(applicationId);
|
||||
unbindParam.setDeviceId(dto.getDeviceId());
|
||||
unbindParam.setDeviceCode(dto.getDeviceCode());
|
||||
unbindParam.setImageStoreId(dto.getImageStoreId());
|
||||
this.acsDeviceImageStoreAppBindService.unbindAppImageStoreDevice(unbindParam, context);
|
||||
}
|
||||
AcsPassRuleDeleteDto dto = new AcsPassRuleDeleteDto();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setIds(param.getIds());
|
||||
try {
|
||||
this.acsPassRuleManager.delete(dto);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u901a\u884c\u89c4\u5219\u5220\u9664\u5931\u8d25");
|
||||
throw new ServiceException("76260507", this.getMessage("76260507"));
|
||||
}
|
||||
}
|
||||
|
||||
private String getAcsImageStore(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsdeviceDetailQueryParam acsdeviceDetailQueryParam = new AcsdeviceDetailQueryParam();
|
||||
acsdeviceDetailQueryParam.setDeviceId(deviceId);
|
||||
CloudwalkResult deviceDetailResult = this.acsDeviceService.detail(acsdeviceDetailQueryParam, context);
|
||||
if (!deviceDetailResult.isSuccess()) {
|
||||
throw new ServiceException(deviceDetailResult.getCode(), deviceDetailResult.getMessage());
|
||||
}
|
||||
if (deviceDetailResult.getData() == null) {
|
||||
throw new ServiceException("\u95e8\u7981\u56fe\u5e93\u4e0d\u5b58\u5728");
|
||||
}
|
||||
return ((AcsDeviceDetailResult)deviceDetailResult.getData()).getImageStoreId();
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<AcsPassRuleDetailResult> detail(AcsPassRuleQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u8be6\u60c5\u5165\u53c2\uff1aAcsPassRuleQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
List passRuleResult = this.acsPassRuleManager.query(dto);
|
||||
if (CollectionUtils.isEmpty((Collection)passRuleResult)) {
|
||||
return CloudwalkResult.fail((String)"76260517", (String)this.getMessage("76260517"));
|
||||
}
|
||||
AcsPassRuleDetailResult result = this.coverRuleDetailResult((AcsPassRuleResultDto)passRuleResult.get(0), context);
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u8be6\u60c5\u5931\u8d25");
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResult> coverRulePageResult(List<AcsPassRuleResultDto> passRuleResultDtos, CloudwalkCallContext context, boolean needDetail) throws ServiceException {
|
||||
ArrayList<AcsPassRuleResult> results = new ArrayList<AcsPassRuleResult>();
|
||||
Map<String, ImageStoreListResult> imageStoreResultMap = null;
|
||||
if (needDetail) {
|
||||
List<String> imageStoreIds = passRuleResultDtos.stream().map(AcsPassRuleResultDto::getImageStoreId).collect(Collectors.toList());
|
||||
List<ImageStoreListResult> imageStoreListResult = this.getImageStorePageResult(imageStoreIds, context);
|
||||
imageStoreResultMap = imageStoreListResult.stream().collect(Collectors.toMap(ImageStoreListResult::getId, ImageStoreListResult2 -> ImageStoreListResult2));
|
||||
}
|
||||
for (AcsPassRuleResultDto dto : passRuleResultDtos) {
|
||||
AcsPassRuleResult result = new AcsPassRuleResult();
|
||||
BeanCopyUtils.copyProperties((Object)dto, (Object)result);
|
||||
result.setRuleName(dto.getName());
|
||||
result.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
|
||||
if (!StringUtils.isEmpty((String)dto.getPassableTimeId())) {
|
||||
AcsPassTimeResult timeResult = this.getPassTimeById(dto.getPassableTimeId(), context);
|
||||
result.setValidDateCron(timeResult.getValidDateCron());
|
||||
result.setValidDateJson(timeResult.getValidDateJson());
|
||||
result.setPassableTimeName(timeResult.getPassableTimeName());
|
||||
result.setPassType(AcsPassTypeEnum.PASS_TIME.getCode());
|
||||
} else if (dto.getBeginDate() != null || dto.getEndDate() != null) {
|
||||
result.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
|
||||
}
|
||||
if (needDetail && imageStoreResultMap.containsKey(dto.getImageStoreId())) {
|
||||
ImageStoreListResult imageStoreListResult = imageStoreResultMap.get(dto.getImageStoreId());
|
||||
result.setPersonSum(imageStoreListResult.getPersonNum().intValue());
|
||||
result.setIncludeOrganizations(imageStoreListResult.getIncludeOrganizations());
|
||||
result.setIncludeLabels(imageStoreListResult.getIncludeLabels());
|
||||
result.setExcludeLabels(imageStoreListResult.getExcludeLabels());
|
||||
}
|
||||
results.add(result);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private List<ImageStoreListResult> getImageStorePageResult(List<String> imageStoreIds, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStoreQueryParam param = new ImageStoreQueryParam();
|
||||
param.setIds(imageStoreIds);
|
||||
param.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult imageStoreResult = this.imageStoreService.list(param, context);
|
||||
if (!imageStoreResult.isSuccess()) {
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u5206\u9875\u67e5\u8be2\u56fe\u5e93\u5931\u8d25\uff0c\u539f\u56e0\uff1a" + imageStoreResult.getMessage());
|
||||
throw new ServiceException(imageStoreResult.getCode(), imageStoreResult.getMessage());
|
||||
}
|
||||
return (List)imageStoreResult.getData();
|
||||
}
|
||||
|
||||
private AcsPassRuleDetailResult coverRuleDetailResult(AcsPassRuleResultDto dto, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleDetailResult result = new AcsPassRuleDetailResult();
|
||||
BeanCopyUtils.copyProperties((Object)dto, (Object)result);
|
||||
result.setRuleName(dto.getName());
|
||||
ImageStoreDetailResult imageStoreDetailResult = this.getImageStoreDetail(dto.getImageStoreId(), context);
|
||||
result.setIncludeOrganizations(imageStoreDetailResult.getIncludeOrganizations());
|
||||
result.setIncludeLabels(imageStoreDetailResult.getIncludeLabels());
|
||||
result.setExcludeLabels(imageStoreDetailResult.getExcludeLabels());
|
||||
List timeCycleParams = JSONObject.parseArray((String)dto.getValidDateJson(), AcsPassTimeCycleParam.class);
|
||||
result.setPassableCycle(timeCycleParams);
|
||||
result.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
|
||||
if (dto.getBeginDate() != null || dto.getEndDate() != null) {
|
||||
result.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
|
||||
}
|
||||
if (!StringUtils.isEmpty((String)dto.getPassableTimeId())) {
|
||||
result.setPassType(AcsPassTypeEnum.PASS_TIME.getCode());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsPassRuleResult>> page(AcsPassRuleQueryParam param, CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5165\u53c2\uff1aAcsPassRuleQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
dto.setDeviceId(param.getDeviceId());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkPageAble passRuleResult = this.acsPassRuleManager.page(dto, page);
|
||||
List<AcsPassRuleResult> results = this.coverRulePageResult((List)passRuleResult.getDatas(), context, true);
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(results, page, passRuleResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5206\u9875\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5931\u8d25");
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<List<AcsPassRuleResult>> list(AcsPassRuleQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5165\u53c2\uff1aAcsPassRuleQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
List passRuleResult = this.acsPassRuleManager.query(dto);
|
||||
return CloudwalkResult.success(this.coverRulePageResult(passRuleResult, context, false));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5931\u8d25");
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+379
@@ -0,0 +1,379 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassTimeManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassableRefManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonBindParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStoreBatchBindPersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleEditDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeDeleteDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeEditDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CronUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.transaction.annotation.Propagation
|
||||
* org.springframework.transaction.annotation.Transactional
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.passtime;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassTimeManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassableRefManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreEditParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonBindParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreDetailResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStoreBatchBindPersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleEditDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeDeleteDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeEditDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassTimeResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CronUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.passtime.AbstractAcsPassService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class AcsPassTimeServiceImpl
|
||||
extends AbstractAcsPassService
|
||||
implements AcsPassTimeService {
|
||||
@Resource
|
||||
private AcsPassTimeManager acsPassTimeManager;
|
||||
@Resource
|
||||
private AcsPassableRefManager acsPassableRefManager;
|
||||
@Resource
|
||||
private AcsPassRuleManager acsPassRuleManager;
|
||||
@Resource
|
||||
private ImageStoreService imageStoreService;
|
||||
@Resource
|
||||
private ImageStorePersonService imageStorePersonService;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<String> add(AcsPassTimeAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u65b0\u589e\u901a\u884c\u65f6\u95f4\u5165\u53c2\uff1aAcsPassTimeAddParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassTimeAddDto dto = new AcsPassTimeAddDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setName(param.getPassableTimeName());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setValidDateJson(JSONObject.toJSONString((Object)param.getPassableCycle()));
|
||||
ArrayList<String> crons = new ArrayList<String>();
|
||||
for (AcsPassTimeCycleParam timeCycle : param.getPassableCycle()) {
|
||||
Map<String, String> passTimeMap = timeCycle.getTime().stream().collect(Collectors.toMap(AcsPassTimeParam::getBeginTime, AcsPassTimeParam::getEndTime));
|
||||
crons.add(CronUtil.getCron((Date)new Date(param.getBeginDate()), (Date)new Date(param.getEndDate()), (int)timeCycle.getWeekday(), passTimeMap));
|
||||
}
|
||||
dto.setValidDateCron(JSONObject.toJSONString(crons));
|
||||
this.acsPassTimeManager.add(dto);
|
||||
return CloudwalkResult.success((Object)dto.getId());
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u65b0\u589e\u901a\u884c\u65f6\u95f4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260501", this.getMessage("76260501"));
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> edit(AcsPassTimeEditParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7f16\u8f91\u901a\u884c\u65f6\u95f4\u5165\u53c2\uff1aAcsPassTimeEditParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassTimeEditDto dto = new AcsPassTimeEditDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(param.getId());
|
||||
dto.setName(param.getPassableTimeName());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setValidDateJson(JSONObject.toJSONString((Object)param.getPassableCycle()));
|
||||
ArrayList<String> crons = new ArrayList<String>();
|
||||
for (AcsPassTimeCycleParam timeCycle : param.getPassableCycle()) {
|
||||
Map<String, String> passTimeMap = timeCycle.getTime().stream().collect(Collectors.toMap(AcsPassTimeParam::getBeginTime, AcsPassTimeParam::getEndTime));
|
||||
crons.add(CronUtil.getCron((Date)new Date(param.getBeginDate()), (Date)new Date(param.getEndDate()), (int)timeCycle.getWeekday(), passTimeMap));
|
||||
}
|
||||
dto.setValidDateCron(JSONObject.toJSONString(crons));
|
||||
this.acsPassTimeManager.edit(dto);
|
||||
List<String> updateFailImageStoreIds = this.updateTimeRule(param, dto, context);
|
||||
List<String> failPersonIds = this.updatePersonRef(param, dto, context);
|
||||
if (CollectionUtils.isEmpty(updateFailImageStoreIds)) {
|
||||
this.logger.error("\u66f4\u65b0\u56fe\u5e93\u65f6\u95f4\u5931\u8d25\uff0c\u56fe\u5e93id\uff1a" + updateFailImageStoreIds);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(failPersonIds)) {
|
||||
this.logger.error("\u66f4\u65b0\u5173\u8054\u4eba\u5458\u65f6\u95f4\u5931\u8d25\uff0c\u4eba\u5458id\uff1a" + failPersonIds);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7f16\u8f91\u901a\u884c\u65f6\u95f4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260502", this.getMessage("76260502"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> updateTimeRule(AcsPassTimeEditParam param, AcsPassTimeEditDto dto, CloudwalkCallContext context) throws ServiceException {
|
||||
ArrayList<String> updateFailImageStoreIds = new ArrayList<String>();
|
||||
List<AcsPassRuleResultDto> refResults = this.getRuleByTimeId(param, context);
|
||||
if (!CollectionUtils.isEmpty(refResults)) {
|
||||
for (AcsPassRuleResultDto refDto : refResults) {
|
||||
String updateFailImageStoreId = this.updateRule(refDto, dto, context);
|
||||
if (StringUtils.isEmpty((String)updateFailImageStoreId)) continue;
|
||||
updateFailImageStoreIds.add(updateFailImageStoreId);
|
||||
}
|
||||
}
|
||||
return updateFailImageStoreIds;
|
||||
}
|
||||
|
||||
private List<String> updatePersonRef(AcsPassTimeEditParam param, AcsPassTimeEditDto dto, CloudwalkCallContext context) throws ServiceException {
|
||||
ArrayList<String> failPersonIds = new ArrayList<String>();
|
||||
List<AcsPassableRefResultDto> personRef = this.getPersonTimeRef(param.getId(), context);
|
||||
if (!CollectionUtils.isEmpty(personRef)) {
|
||||
Map<String, List<AcsPassableRefResultDto>> refMap = personRef.stream().collect(Collectors.groupingBy(AcsPassableRefResultDto::getImageStoreId));
|
||||
List imageStoreIds = personRef.stream().map(AcsPassableRefResultDto::getImageStoreId).distinct().collect(Collectors.toList());
|
||||
for (String imageStoreId : imageStoreIds) {
|
||||
List<String> personIds = refMap.get(imageStoreId).stream().map(AcsPassableRefResultDto::getPersonId).collect(Collectors.toList());
|
||||
List<String> imageStoreFailPersonIds = this.batchBindPerson(dto, personIds, imageStoreId, context);
|
||||
this.logger.info("\u6279\u91cf\u7ed1\u5b9a\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u51fa\u53c2\uff1a\u56fe\u5e93=[{}], \u5931\u8d25\u4eba\u5458ids=[{}]", (Object)imageStoreId, imageStoreFailPersonIds);
|
||||
failPersonIds.addAll(imageStoreFailPersonIds);
|
||||
}
|
||||
}
|
||||
return failPersonIds;
|
||||
}
|
||||
|
||||
private List<String> batchBindPerson(AcsPassTimeEditDto dto, List<String> personIds, String imageStoreId, CloudwalkCallContext context) {
|
||||
try {
|
||||
ImageStorePersonBindParam param = (ImageStorePersonBindParam)BeanCopyUtils.copyProperties((Object)dto, ImageStorePersonBindParam.class);
|
||||
param.setImageStoreId(imageStoreId);
|
||||
param.setPersonIds(personIds);
|
||||
param.setExpiryBeginDate(dto.getBeginDate());
|
||||
param.setExpiryEndDate(dto.getEndDate());
|
||||
param.setNullDateIsLongTerm(Boolean.valueOf(true));
|
||||
if (dto.getValidDateCron() != null) {
|
||||
param.setValidDateCron(JSONObject.parseArray((String)dto.getValidDateCron(), String.class));
|
||||
}
|
||||
this.logger.info("\u6279\u91cf\u7ed1\u5b9a\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u5165\u53c2\uff1aImageStorePersonBindParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult result = this.imageStorePersonService.batchBind(param, context);
|
||||
if (!result.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u6279\u91cf\u7ed1\u5b9a\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u5931\u8d25\uff0c\u539f\u56e0\uff1a" + result.getMessage());
|
||||
throw new ServiceException(result.getCode(), result.getMessage());
|
||||
}
|
||||
this.logger.info("\u6279\u91cf\u7ed1\u5b9a\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u51fa\u53c2\uff1asuccessPersonIds=[{}], failPersonIds=[{}]", (Object)((ImgStoreBatchBindPersonResult)result.getData()).getSuccessPersonIds(), (Object)((ImgStoreBatchBindPersonResult)result.getData()).getFailPersonIds());
|
||||
return ((ImgStoreBatchBindPersonResult)result.getData()).getFailPersonIds();
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
this.logger.error("\u56fe\u5e93\u6279\u91cf\u7ed1\u5b9a\u4eba\u5458\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
return personIds;
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassableRefResultDto> getPersonTimeRef(String passTimeId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassableRefQueryDto dto = new AcsPassableRefQueryDto();
|
||||
try {
|
||||
dto.setPassableTimeId(passTimeId);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
return this.acsPassableRefManager.query(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u4eba\u5458\u65f6\u95f4\u5173\u8054\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260509", this.getMessage("76260509"));
|
||||
}
|
||||
}
|
||||
|
||||
private String updateRule(AcsPassRuleResultDto refDto, AcsPassTimeEditDto timeDto, CloudwalkCallContext context) throws ServiceException {
|
||||
String updateFallImageStoreId = this.updateImageStore(refDto, context);
|
||||
try {
|
||||
AcsPassRuleEditDto dto = new AcsPassRuleEditDto();
|
||||
dto.setBeginDate(timeDto.getBeginDate());
|
||||
dto.setEndDate(timeDto.getEndDate());
|
||||
dto.setValidDateJson(timeDto.getValidDateJson());
|
||||
dto.setValidDateCron(timeDto.getValidDateCron());
|
||||
dto.setId(refDto.getId());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setPassableTimeId(timeDto.getId());
|
||||
this.acsPassRuleManager.edit(dto);
|
||||
return updateFallImageStoreId;
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u7f16\u8f91\u901a\u884c\u89c4\u5219\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260506", this.getMessage("76260506"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResultDto> getRuleByTimeId(AcsPassTimeEditParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
dto.setPassableTimeId(param.getId());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
return this.acsPassRuleManager.query(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u89c4\u5219\u56fe\u5e93\u5173\u8054\u5931\u8d25");
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
}
|
||||
|
||||
private String updateImageStore(AcsPassRuleResultDto refDto, CloudwalkCallContext context) {
|
||||
try {
|
||||
ImageStoreDetailResult imageStoreDetail = this.getImageStoreDetail(refDto.getImageStoreId(), context);
|
||||
ImageStoreEditParam param = this.getEditParamByImageStore(imageStoreDetail);
|
||||
param.setImageStoreId(refDto.getImageStoreId());
|
||||
param.setNullDateIsLongTerm(Boolean.valueOf(true));
|
||||
CloudwalkResult result = this.imageStoreService.edit(param, context);
|
||||
if (!result.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u66f4\u65b0\u56fe\u5e93\u5931\u8d25");
|
||||
throw new ServiceException("\u8fdc\u7a0b\u8c03\u7528\u66f4\u65b0\u56fe\u5e93\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
catch (ServiceException e) {
|
||||
return refDto.getImageStoreId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> delete(AcsPassTimeDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5220\u9664\u901a\u884c\u65f6\u95f4\u5165\u53c2\uff1aAcsPassTimeDeleteParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
this.checkTime(param, context);
|
||||
AcsPassTimeDeleteDto dto = (AcsPassTimeDeleteDto)BeanCopyUtils.copyProperties((Object)param, AcsPassTimeDeleteDto.class);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.acsPassTimeManager.delete(dto);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5220\u9664\u901a\u884c\u65f6\u95f4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260503", this.getMessage("76260503"));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTime(AcsPassTimeDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleQueryDto ruleQueryDto = new AcsPassRuleQueryDto();
|
||||
ruleQueryDto.setPassableTimeId((String)param.getIds().get(0));
|
||||
ruleQueryDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
List ruleResult = this.acsPassRuleManager.query(ruleQueryDto);
|
||||
if (!ruleResult.isEmpty()) {
|
||||
List ruleName = ruleResult.stream().map(AcsPassRuleResultDto::getName).collect(Collectors.toList());
|
||||
this.logger.error("\u5df2\u7ed1\u5b9a\u901a\u884c\u89c4\u5219\uff0c\u65e0\u6cd5\u5220\u9664");
|
||||
throw new ServiceException("\u5df2\u7ed1\u5b9a\u901a\u884c\u89c4\u5219" + ruleName);
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
List<AcsPassableRefResultDto> refResult = this.getPersonTimeRef((String)param.getIds().get(0), context);
|
||||
if (!refResult.isEmpty()) {
|
||||
this.logger.error("\u5df2\u7ed1\u5b9a\u901a\u884c\u4eba\u5458, \u65e0\u6cd5\u5220\u9664");
|
||||
throw new ServiceException("\u5df2\u7ed1\u5b9a\u901a\u884c\u4eba\u5458");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<List<AcsPassTimeResult>> list(AcsPassTimeQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u65f6\u95f4\u5165\u53c2\uff1aAcsPassTimeQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassTimeQueryDto dto = new AcsPassTimeQueryDto();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
List resultDtoList = this.acsPassTimeManager.query(dto);
|
||||
return CloudwalkResult.success(this.coverResult(resultDtoList));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u65f6\u95f4\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260504", this.getMessage("76260504"));
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<AcsPassTimeResult> get(AcsPassTimeQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u65f6\u95f4\u8be6\u60c5\u5165\u53c2\uff1aAcsPassTimeQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
try {
|
||||
AcsPassTimeQueryDto dto = (AcsPassTimeQueryDto)BeanCopyUtils.copyProperties((Object)param, AcsPassTimeQueryDto.class);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
List resultDtoList = this.acsPassTimeManager.query(dto);
|
||||
if (CollectionUtils.isEmpty((Collection)resultDtoList)) {
|
||||
return CloudwalkResult.success((Object)new AcsPassTimeResult());
|
||||
}
|
||||
return CloudwalkResult.success((Object)this.coverResult(resultDtoList).get(0));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u65f6\u95f4\u8be6\u60c5\u5931\u8d25,\u9519\u8bef\u4fe1\u606f\uff1a{}", (Object)e.getMessage());
|
||||
throw new ServiceException("76260504", this.getMessage("76260504"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsPassTimeResult> coverResult(List<AcsPassTimeResultDto> resultDtoList) {
|
||||
ArrayList<AcsPassTimeResult> results = new ArrayList<AcsPassTimeResult>();
|
||||
for (AcsPassTimeResultDto dto : resultDtoList) {
|
||||
AcsPassTimeResult result = (AcsPassTimeResult)BeanCopyUtils.copyProperties((Object)dto, AcsPassTimeResult.class);
|
||||
result.setPassableTimeName(dto.getName());
|
||||
result.setPassableTimeId(dto.getId());
|
||||
List timeCycleParams = JSONObject.parseArray((String)dto.getValidDateJson(), AcsPassTimeCycleParam.class);
|
||||
result.setPassableCycle(timeCycleParams);
|
||||
results.add(result);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
+905
@@ -0,0 +1,905 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassableRefManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.person.AcsPersonManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.param.FeatureQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.result.FeatureQueryResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.service.BiologyToolService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceApplicationQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceApplicationResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceImageStoreResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceApplicationService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceImageStoreService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonBindParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonDelParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStorePersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStoreBatchBindPersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonAddParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddNewParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonCheckTimeParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDeleteParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonFaceParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryByAppParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonTimeDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsAppResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsImagestorePersonStatisticsResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonFaceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonTimeDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.result.AppImageStoreStatisticsResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseTimes
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefDeleteDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.person.dto.AcsPersonAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsPassTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.transaction.annotation.Transactional
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.person;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassRuleManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.passtime.AcsPassableRefManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.person.AcsPersonManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.application.param.ApplicationImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.param.FeatureQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.result.FeatureQueryResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.service.BiologyToolService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceApplicationQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceApplicationResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceImageStoreResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceApplicationService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceImageStoreService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonBindParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonDelParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStorePersonQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.param.ImageStoreQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStoreListResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImageStorePersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.result.ImgStoreBatchBindPersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStorePersonService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.imagestore.service.ImageStoreService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonAddParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassRuleQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeCycleParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.param.AcsPassTimeQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassRuleResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.result.AcsPassTimeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassRuleService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.passtime.service.AcsPassTimeService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddNewParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonCheckTimeParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDeleteParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonFaceParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryByAppParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.param.AcsPersonTimeDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsAppResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsImagestorePersonStatisticsResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonFaceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AcsPersonTimeDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.result.AppImageStoreStatisticsResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.person.service.AcsPersonService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseIdentify;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassRuleResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefDeleteDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.pass.dto.AcsPassableRefResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.person.dto.AcsPersonAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsPassTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.passtime.AbstractAcsPassService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class AcsPersonServiceImpl
|
||||
extends AbstractAcsPassService
|
||||
implements AcsPersonService {
|
||||
private static final int ROWS_OF_PAGE = 1000;
|
||||
@Autowired
|
||||
private BiologyToolService biologyToolService;
|
||||
@Autowired
|
||||
private DeviceImageStoreService deviceImageStoreService;
|
||||
@Autowired
|
||||
private ImageStorePersonService imageStorePersonService;
|
||||
@Autowired
|
||||
private AcsDeviceService acsDeviceService;
|
||||
@Autowired
|
||||
private DeviceApplicationService deviceApplicationService;
|
||||
@Autowired
|
||||
private PersonService personService;
|
||||
@Autowired
|
||||
private ImageStoreService imageStoreService;
|
||||
@Autowired
|
||||
private AcsPersonManager acsPersonManager;
|
||||
@Autowired
|
||||
protected AccessControlProperties accessControlProperties;
|
||||
@Resource
|
||||
private AcsPassableRefManager acsPassableRefManager;
|
||||
@Resource
|
||||
private AcsPassRuleService acsPassRuleService;
|
||||
@Resource
|
||||
private AcsPassTimeService acsPassTimeService;
|
||||
@Resource
|
||||
private AcsPassRuleManager acsPassRuleManager;
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<AcsPersonFaceResult> faceCompare(AcsPersonFaceParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u4eba\u8138\u6bd4\u5bf9\u5f00\u59cb\uff0cdeviceId=[{}], CloudwalkCallContext=[{}]", (Object)param.getDeviceId(), (Object)JSONObject.toJSONString((Object)context));
|
||||
AcsPersonFaceResult result = new AcsPersonFaceResult();
|
||||
HashSet personIds = new HashSet();
|
||||
FeatureQueryParam featureQueryParam = new FeatureQueryParam();
|
||||
featureQueryParam.setTopN(Integer.valueOf(1));
|
||||
featureQueryParam.setImageBase64(param.getFaceImage());
|
||||
List<DeviceImageStoreResult> imageStores = this.getDeviceImageStore(param.getDeviceId(), context);
|
||||
List imageStroeIds = imageStores.stream().map(DeviceImageStoreResult::getImageStoreId).collect(Collectors.toList());
|
||||
featureQueryParam.setImageStoreIds(imageStroeIds);
|
||||
CloudwalkResult compareResult = this.biologyToolService.querygroups(featureQueryParam, context);
|
||||
if (compareResult.isSuccess()) {
|
||||
if (CollectionUtils.isNotEmpty((Map)((Map)compareResult.getData()))) {
|
||||
for (Map.Entry entry : ((Map)compareResult.getData()).entrySet()) {
|
||||
List features = (List)entry.getValue();
|
||||
List featuresFilter = features.stream().filter(feature -> new BigDecimal(feature.getScore()).multiply(new BigDecimal("100")).compareTo(this.accessControlProperties.getFaceCompareThreshold()) >= 0).collect(Collectors.toList());
|
||||
List featurePersonIds = featuresFilter.stream().map(FeatureQueryResult::getPersonId).collect(Collectors.toList());
|
||||
personIds.addAll(featurePersonIds);
|
||||
}
|
||||
result.setPersonIds(new ArrayList(personIds));
|
||||
}
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
return CloudwalkResult.fail((String)compareResult.getCode(), (String)compareResult.getMessage());
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> add(AcsPersonAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u4ece\u73b0\u6709\u4eba\u5458\u6dfb\u52a0\u95e8\u7981\u901a\u884c\u4eba\u5458\u5f00\u59cb\uff0cAcsPersonAddParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String acsImageStoreId = this.getAcsImageStore(param.getDeviceId(), context);
|
||||
ImageStorePersonBindParam imageStorePersonBindParam = new ImageStorePersonBindParam();
|
||||
imageStorePersonBindParam.setImageStoreId(acsImageStoreId);
|
||||
imageStorePersonBindParam.setPersonIds(param.getPersonIds());
|
||||
imageStorePersonBindParam.setNullDateIsLongTerm(Boolean.valueOf(true));
|
||||
imageStorePersonBindParam.setExpiryBeginDate(param.getStartTime());
|
||||
imageStorePersonBindParam.setExpiryEndDate(param.getEndTime());
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
AcsPassTimeResult passTimeResult = this.getPassTimeById(param.getPassableTimeId(), context);
|
||||
imageStorePersonBindParam.setExpiryBeginDate(passTimeResult.getBeginDate());
|
||||
imageStorePersonBindParam.setExpiryEndDate(passTimeResult.getEndDate());
|
||||
imageStorePersonBindParam.setValidDateCron(JSONObject.parseArray((String)passTimeResult.getValidDateCron(), String.class));
|
||||
}
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u7ed1\u5b9a\u4eba\u5458\u56fe\u5e93\u5f00\u59cb\uff0cimageStorePersonBindParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)imageStorePersonBindParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult bindResult = this.imageStorePersonService.batchBind(imageStorePersonBindParam, context);
|
||||
if (!bindResult.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u7ed1\u5b9a\u4eba\u5458\u56fe\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}],\u5931\u8d25\u4eba\u5458id:[{}]", (Object)bindResult.getMessage(), (Object)((ImgStoreBatchBindPersonResult)bindResult.getData()).getFailPersonIds());
|
||||
return CloudwalkResult.fail((String)bindResult.getCode(), (String)bindResult.getMessage());
|
||||
}
|
||||
this.deleteRef(acsImageStoreId, param.getPersonIds(), context.getCompany().getCompanyId());
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
this.batchAddRef(param.getPersonIds(), param.getPassableTimeId(), context, acsImageStoreId);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void batchAddRef(List<String> personIds, String passableTimeId, CloudwalkCallContext context, String acsImageStoreId) throws ServiceException {
|
||||
String businessId = context.getCompany().getCompanyId();
|
||||
ArrayList<AcsPassableRefAddDto> dtos = new ArrayList<AcsPassableRefAddDto>();
|
||||
try {
|
||||
for (String personId : personIds) {
|
||||
AcsPassableRefAddDto dto = new AcsPassableRefAddDto();
|
||||
BeanCopyUtils.copyProperties((Object)dto, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setBusinessId(businessId);
|
||||
dto.setImageStoreId(acsImageStoreId);
|
||||
dto.setPassableTimeId(passableTimeId);
|
||||
dto.setPersonId(personId);
|
||||
dtos.add(dto);
|
||||
}
|
||||
this.acsPassableRefManager.batchAdd(dtos);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u6279\u91cf\u6dfb\u52a0\u4eba\u5458\u56fe\u5e93\u5173\u8054\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage());
|
||||
throw new ServiceException("\u6279\u91cf\u6dfb\u52a0\u4eba\u5458\u56fe\u5e93\u5173\u8054\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
@Transactional(rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> addNew(AcsPersonAddNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u4ece\u65b0\u589e\u4eba\u5458\u6dfb\u52a0\u95e8\u7981\u901a\u884c\u4eba\u5458\u5f00\u59cb, AcsPersonAddNewParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
String acsImageStoreId = this.getAcsImageStore(param.getDeviceId(), context);
|
||||
String personId = this.addPerson(param, context);
|
||||
this.bindImageStorePerson(acsImageStoreId, personId, param.getStartTime(), param.getEndTime(), param.getPassableTimeId(), context);
|
||||
this.addAcsPerson(acsImageStoreId, personId, param, context);
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
this.addPersonRef(acsImageStoreId, personId, param, context);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void addPersonRef(String acsImageStoreId, String personId, AcsPersonAddNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsPassableRefAddDto dto = new AcsPassableRefAddDto();
|
||||
BeanCopyUtils.copyProperties((Object)param, (CloudwalkCallContext)context, (Object)dto);
|
||||
dto.setId(this.genUUID());
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setImageStoreId(acsImageStoreId);
|
||||
dto.setPassableTimeId(param.getPassableTimeId());
|
||||
dto.setPersonId(personId);
|
||||
this.acsPassableRefManager.add(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u65b0\u589e\u56fe\u5e93\u4eba\u5458\u65f6\u95f4\u5173\u8054\u6570\u636e\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("76260511", this.getMessage("76260511"));
|
||||
}
|
||||
}
|
||||
|
||||
private void addAcsPerson(String acsImageStoreId, String personId, AcsPersonAddNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsPersonAddDto acsPersonAddDto = new AcsPersonAddDto();
|
||||
BeanCopyUtils.copyProperties((CloudwalkBaseTimes)acsPersonAddDto, (CloudwalkCallContext)context);
|
||||
acsPersonAddDto.setId(this.genUUID());
|
||||
acsPersonAddDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
acsPersonAddDto.setImagestoreId(acsImageStoreId);
|
||||
acsPersonAddDto.setPersonId(personId);
|
||||
acsPersonAddDto.setDeviceId(param.getDeviceId());
|
||||
this.acsPersonManager.add(acsPersonAddDto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u65b0\u589e\u95e8\u7981\u901a\u884c\u4eba\u5458\u6570\u636e\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("76260007", this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
|
||||
private void bindImageStorePerson(String acsImageStoreId, String personId, Long startTime, Long endTime, String passableTimeId, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStorePersonBindParam imageStorePersonBindParam = new ImageStorePersonBindParam();
|
||||
imageStorePersonBindParam.setImageStoreId(acsImageStoreId);
|
||||
imageStorePersonBindParam.setNullDateIsLongTerm(Boolean.valueOf(true));
|
||||
imageStorePersonBindParam.setPersonId(personId);
|
||||
imageStorePersonBindParam.setExpiryBeginDate(startTime);
|
||||
imageStorePersonBindParam.setExpiryEndDate(endTime);
|
||||
if (!StringUtils.isEmpty((String)passableTimeId)) {
|
||||
AcsPassTimeResult passTimeResult = this.getPassTimeById(passableTimeId, context);
|
||||
imageStorePersonBindParam.setExpiryBeginDate(passTimeResult.getBeginDate());
|
||||
imageStorePersonBindParam.setExpiryEndDate(passTimeResult.getEndDate());
|
||||
imageStorePersonBindParam.setValidDateCron(JSONObject.parseArray((String)passTimeResult.getValidDateCron(), String.class));
|
||||
}
|
||||
this.logger.info("\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u7ed1\u5b9a\u5f00\u59cb\uff0cimageStorePersonBindParam:[{}],context:[{}]", (Object)JSONObject.toJSONString((Object)imageStorePersonBindParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult bindResult = this.imageStorePersonService.bind(imageStorePersonBindParam, context);
|
||||
if (!bindResult.isSuccess()) {
|
||||
this.logger.error("\u56fe\u5e93\u4eba\u5458\u5173\u7cfb\u7ed1\u5b9a\u5931\u8d25,imageStoreId=[{}],personId=[{}],\u539f\u56e0\uff1a[{}]", new Object[]{acsImageStoreId, personId, bindResult.getMessage()});
|
||||
throw new ServiceException(bindResult.getCode(), bindResult.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String addPerson(AcsPersonAddNewParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
PersonAddParam personAddParam = new PersonAddParam();
|
||||
BeanCopyUtils.copyProperties((Object)param.getPersonProperties(), (Object)personAddParam);
|
||||
CloudwalkResult addPersonResult = this.personService.add(personAddParam, context);
|
||||
if (!addPersonResult.isSuccess()) {
|
||||
this.logger.info("\u65b0\u589e\u4eba\u5458\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)addPersonResult.getMessage());
|
||||
throw new ServiceException(addPersonResult.getCode(), addPersonResult.getMessage());
|
||||
}
|
||||
return (String)addPersonResult.getData();
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> edit(AcsPersonEditParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u7f16\u8f91\u95e8\u7981\u901a\u884c\u4eba\u5458\u5f00\u59cb\uff0cAcsPersonEditParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
this.checkPersonIdByImageStore(param.getPersonId(), param.getImageStoreId(), context);
|
||||
ImageStorePersonDelParam delParam = new ImageStorePersonDelParam();
|
||||
delParam.setImageStoreId(param.getImageStoreId());
|
||||
delParam.setPersonId(param.getPersonId());
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u89e3\u7ed1\u56fe\u5e93\u4eba\u5458\u5f00\u59cb\uff0cImageStorePersonDelParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)delParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult deleteResult = this.imageStorePersonService.delete(delParam, context);
|
||||
if (!deleteResult.isSuccess()) {
|
||||
this.logger.error("\u56fe\u5e93\u4eba\u5458\u66f4\u65b0\u4e4b\u524d\u5148\u89e3\u7ed1\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)deleteResult.getMessage());
|
||||
return CloudwalkResult.fail((String)"76260406", (String)(this.getMessage("76260406") + " " + deleteResult.getMessage()));
|
||||
}
|
||||
this.deleteRef(param.getImageStoreId(), Collections.singletonList(param.getPersonId()), context.getCompany().getCompanyId());
|
||||
this.bindImageStorePerson(param.getImageStoreId(), param.getPersonId(), param.getStartTime(), param.getEndTime(), param.getPassableTimeId(), context);
|
||||
if (!StringUtils.isEmpty((String)param.getPassableTimeId())) {
|
||||
this.batchAddRef(Collections.singletonList(param.getPersonId()), param.getPassableTimeId(), context, param.getImageStoreId());
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void deleteRef(String acsImageStoreId, List<String> personIds, String businessId) throws ServiceException {
|
||||
try {
|
||||
AcsPassableRefDeleteDto deleteDto = new AcsPassableRefDeleteDto();
|
||||
deleteDto.setImageStoreId(acsImageStoreId);
|
||||
deleteDto.setPersonIds(personIds);
|
||||
deleteDto.setBusinessId(businessId);
|
||||
this.acsPassableRefManager.delete(deleteDto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5220\u9664\u4eba\u5458\u56fe\u5e93\u5173\u8054\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage());
|
||||
throw new ServiceException("\u5220\u9664\u4eba\u5458\u56fe\u5e93\u5173\u8054\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> delete(AcsPersonDeleteParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5220\u9664\u95e8\u7981\u901a\u884c\u4eba\u5458\u5f00\u59cb\uff0cAcsPersonDeleteParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
for (String personId : param.getPersonIds()) {
|
||||
ImageStorePersonDelParam imageStorePersonDelParam = new ImageStorePersonDelParam();
|
||||
imageStorePersonDelParam.setPersonId(personId);
|
||||
imageStorePersonDelParam.setImageStoreId(param.getImageStoreId());
|
||||
CloudwalkResult imageStorePersonDeleteResult = this.imageStorePersonService.delete(imageStorePersonDelParam, context);
|
||||
if (!imageStorePersonDeleteResult.isSuccess()) {
|
||||
return CloudwalkResult.fail((String)"76260407", (String)(this.getMessage("76260407") + " " + imageStorePersonDeleteResult.getMessage()));
|
||||
}
|
||||
this.deleteRef(param.getImageStoreId(), Collections.singletonList(personId), context.getCompany().getCompanyId());
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<AcsImagestorePersonStatisticsResult> imagestorePersonStatistics(AcsPersonQueryParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5e94\u7528\u56fe\u5e93\u4eba\u5458\u7edf\u8ba1\u5f00\u59cb\uff0cAcsPersonQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
AcsImagestorePersonStatisticsResult result = new AcsImagestorePersonStatisticsResult();
|
||||
ArrayList<AppImageStoreStatisticsResult> appImageStores = new ArrayList<AppImageStoreStatisticsResult>();
|
||||
DeviceApplicationQueryParam applicationQueryParam = new DeviceApplicationQueryParam();
|
||||
applicationQueryParam.setDeviceId(param.getDeviceId());
|
||||
CloudwalkResult deviceAppResult = this.deviceApplicationService.list(applicationQueryParam, context);
|
||||
if (!deviceAppResult.isSuccess() || CollectionUtils.isEmpty((Collection)((Collection)deviceAppResult.getData()))) {
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
List<DeviceApplicationResult> sortedDeviceAppList = this.sortedDeviceAppList((CloudwalkResult<List<DeviceApplicationResult>>)deviceAppResult);
|
||||
for (DeviceApplicationResult deviceApp : sortedDeviceAppList) {
|
||||
AppImageStoreStatisticsResult appImageStore = new AppImageStoreStatisticsResult();
|
||||
List<ImageStoreListResult> imageStoreResult = this.getImageStoreIdsByAppAndDevice(deviceApp.getApplicationId(), param.getDeviceId(), context);
|
||||
int personNum = imageStoreResult.stream().mapToInt(ImageStoreListResult::getPersonNum).sum();
|
||||
appImageStore.setApplicationId(deviceApp.getApplicationId());
|
||||
appImageStore.setApplicationName(deviceApp.getApplicationName());
|
||||
appImageStore.setServiceCode(deviceApp.getServiceCode());
|
||||
appImageStore.setPersonNum(Integer.valueOf(personNum));
|
||||
appImageStores.add(appImageStore);
|
||||
}
|
||||
result.setAppImageStores(appImageStores);
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
|
||||
private List<DeviceApplicationResult> sortedDeviceAppList(CloudwalkResult<List<DeviceApplicationResult>> deviceAppResult) {
|
||||
List deviceAppList = (List)deviceAppResult.getData();
|
||||
ArrayList<DeviceApplicationResult> sortedDeviceAppList = new ArrayList<DeviceApplicationResult>();
|
||||
List acsAppList = deviceAppList.stream().filter(s -> "access-control".equals(s.getServiceCode())).collect(Collectors.toList());
|
||||
List otherAppList = deviceAppList.stream().filter(s -> !"access-control".equals(s.getServiceCode())).collect(Collectors.toList());
|
||||
sortedDeviceAppList.addAll(acsAppList);
|
||||
sortedDeviceAppList.addAll(otherAppList);
|
||||
return sortedDeviceAppList;
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsPersonResult>> page(AcsPersonQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u901a\u884c\u4eba\u5458\u5f00\u59cb\uff0cAcsPersonQueryParam=[{}], CloudwalkPageInfo=[{}], CloudwalkCallContext=[{}]", new Object[]{JSONObject.toJSONString((Object)param), JSONObject.toJSONString((Object)pageInfo), JSONObject.toJSONString((Object)context)});
|
||||
ArrayList<AcsPersonResult> result = new ArrayList<AcsPersonResult>();
|
||||
List<String> personIds = param.getPersonIds();
|
||||
List<AcsPassRuleResult> ruleResults = this.getRuleListByDeviceId(param.getDeviceId(), context);
|
||||
if (CollectionUtils.isEmpty(ruleResults)) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
List<String> imageStoreIds = ruleResults.stream().map(AcsPassRuleResult::getImageStoreId).collect(Collectors.toList());
|
||||
if (StringUtils.isNotBlank((String)param.getImageStoreId()) && !imageStoreIds.contains(param.getImageStoreId())) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
Map<String, AcsPassRuleResult> ruleMap = ruleResults.stream().collect(Collectors.toMap(AcsPassRuleResult::getImageStoreId, r -> r));
|
||||
if (!StringUtils.isEmpty((String)param.getPersonName()) && CollectionUtils.isEmpty(personIds = this.getPersonIdsByName(param.getPersonName(), context))) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
CloudwalkPageAble<ImageStorePersonResult> pageResult = this.getImageStorePerson(param, pageInfo, context, personIds, imageStoreIds);
|
||||
if (!CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
this.covertPageResult(result, pageResult.getDatas(), ruleMap, context);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
|
||||
private List<ImageStoreListResult> getImageStoreIdsByAppAndDevice(String applicationId, String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
ApplicationImageStoreQueryParam queryParam = new ApplicationImageStoreQueryParam();
|
||||
queryParam.setApplicationId(applicationId);
|
||||
List<DeviceImageStoreResult> deviceImageStore = this.getDeviceImageStore(deviceId, context);
|
||||
if (deviceImageStore.isEmpty()) {
|
||||
return new ArrayList<ImageStoreListResult>();
|
||||
}
|
||||
List imageStoreIdByDevice = deviceImageStore.stream().map(DeviceImageStoreResult::getImageStoreId).collect(Collectors.toList());
|
||||
ImageStoreQueryParam imageStoreQueryParam = new ImageStoreQueryParam();
|
||||
imageStoreQueryParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
imageStoreQueryParam.setApplicationId(applicationId);
|
||||
imageStoreQueryParam.setIds(imageStoreIdByDevice);
|
||||
CloudwalkResult imageStoreResult = this.imageStoreService.list(imageStoreQueryParam, context);
|
||||
return (List)imageStoreResult.getData();
|
||||
}
|
||||
|
||||
private CloudwalkPageAble<ImageStorePersonResult> getImageStorePerson(AcsPersonQueryParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context, List<String> personIds, List<String> imageStoreIds) throws ServiceException {
|
||||
CloudwalkPageAble results = new CloudwalkPageAble();
|
||||
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
|
||||
imageStorePersonQueryParam.setImageStoreId(param.getImageStoreId());
|
||||
if (StringUtils.isEmpty((String)param.getImageStoreId())) {
|
||||
imageStorePersonQueryParam.setImageStoreIds(imageStoreIds);
|
||||
}
|
||||
imageStorePersonQueryParam.setPersonIds(personIds);
|
||||
imageStorePersonQueryParam.setOrganizationIds(param.getOrganizationIds());
|
||||
imageStorePersonQueryParam.setLabelIds(param.getLabelIds());
|
||||
imageStorePersonQueryParam.setCurrentPage(pageInfo.getCurrentPage());
|
||||
imageStorePersonQueryParam.setRowsOfPage(pageInfo.getPageSize());
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u4eba\u5458\u5165\u53c2\uff0cimageStorePersonQueryParam\uff1a[{}],context:[{}]", (Object)JSONObject.toJSONString((Object)imageStorePersonQueryParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult pageResult = this.imageStorePersonService.page(imageStorePersonQueryParam, context);
|
||||
if (!pageResult.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u4eba\u5458\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)pageResult.getMessage());
|
||||
throw new ServiceException(pageResult.getCode(), pageResult.getMessage());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)((CloudwalkPageAble)pageResult.getData()).getDatas())) {
|
||||
results = (CloudwalkPageAble)pageResult.getData();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<AcsPersonDetailResult> personDetail(AcsPersonDetailParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u4eba\u5458\u8be6\u60c5\u5f00\u59cb\uff0cAcsPersonDetailParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
ArrayList<AcsAppResult> apps = new ArrayList<AcsAppResult>();
|
||||
AcsPersonDetailResult result = new AcsPersonDetailResult();
|
||||
ImageStoreQueryParam imageStoreQueryParam = new ImageStoreQueryParam();
|
||||
imageStoreQueryParam.setPersonIds(Collections.singletonList(param.getPersonId()));
|
||||
CloudwalkResult imageStoreList = this.imageStoreService.list(imageStoreQueryParam, context);
|
||||
if (!imageStoreList.isSuccess() || CollectionUtils.isEmpty((Collection)((Collection)imageStoreList.getData()))) {
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
Map appMap = ((List)imageStoreList.getData()).stream().collect(Collectors.toMap(ImageStoreListResult::getSourceApplicationId, Function.identity(), (existing, replacement) -> existing));
|
||||
DeviceImageStoreQueryParam deviceImageStoreQueryParam = new DeviceImageStoreQueryParam();
|
||||
deviceImageStoreQueryParam.setDeviceId(param.getDeviceId());
|
||||
CloudwalkResult deviceQueryResult = this.deviceImageStoreService.list(deviceImageStoreQueryParam, context);
|
||||
if (!deviceQueryResult.isSuccess() || CollectionUtils.isEmpty((Collection)((Collection)deviceQueryResult.getData()))) {
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
List imageStoreIdsByDevice = ((List)deviceQueryResult.getData()).stream().map(DeviceImageStoreResult::getImageStoreId).collect(Collectors.toList());
|
||||
List imageStoresByDevicePerson = ((List)imageStoreList.getData()).stream().filter(imageStore -> imageStoreIdsByDevice.contains(imageStore.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(imageStoresByDevicePerson)) {
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
Map<String, List<ImageStoreListResult>> appImageStoreMap = imageStoresByDevicePerson.stream().collect(Collectors.groupingBy(ImageStoreListResult::getSourceApplicationId));
|
||||
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
|
||||
imageStorePersonQueryParam.setPersonId(param.getPersonId());
|
||||
imageStorePersonQueryParam.setRowsOfPage(1000);
|
||||
CloudwalkResult imageStorePersonPageResult = this.imageStorePersonService.page(imageStorePersonQueryParam, context);
|
||||
if (!imageStorePersonPageResult.isSuccess() || CollectionUtils.isEmpty((Collection)((CloudwalkPageAble)imageStorePersonPageResult.getData()).getDatas())) {
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
for (String sourceApplicationId : appImageStoreMap.keySet()) {
|
||||
List<ImageStoreListResult> imageStores = appImageStoreMap.get(sourceApplicationId);
|
||||
List imageStoreIds = imageStores.stream().map(ImageStoreListResult::getId).collect(Collectors.toList());
|
||||
ImageStoreListResult appResult = (ImageStoreListResult)appMap.get(sourceApplicationId);
|
||||
AcsAppResult app = new AcsAppResult();
|
||||
List<ImageStorePersonResult> imageStorePersonList = ((CloudwalkPageAble)imageStorePersonPageResult.getData()).getDatas().stream().filter(imageStorePerson -> imageStoreIds.contains(imageStorePerson.getImageStoreId())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(imageStorePersonList)) continue;
|
||||
app.setApplicationId(appResult.getApplicationId());
|
||||
app.setApplicationName(appResult.getName());
|
||||
app.setPassIntervals(this.mergeTime(imageStorePersonList));
|
||||
apps.add(app);
|
||||
}
|
||||
result.setApps(apps);
|
||||
ImageStorePersonResult imageStorePersonResult = (ImageStorePersonResult)((CloudwalkPageAble)imageStorePersonPageResult.getData()).getDatas().iterator().next();
|
||||
result.setComparePicture(imageStorePersonResult.getComparePicture());
|
||||
result.setPersonName(imageStorePersonResult.getName());
|
||||
result.setPersonId(imageStorePersonResult.getPersonId());
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
|
||||
public CloudwalkResult<AcsPersonTimeDetailResult> timeDetail(AcsPersonTimeDetailParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
List<AcsPassableRefResultDto> ref;
|
||||
this.logger.info("\u67e5\u8be2\u901a\u884c\u4eba\u5458\u65f6\u95f4\u8be6\u60c5\u5f00\u59cb\uff0cAcsPersonTimeDetailParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
AcsPersonTimeDetailResult result = new AcsPersonTimeDetailResult();
|
||||
ImageStorePersonResult imageStorePersonResult = this.getImageStorePersonResult(param, context);
|
||||
AcsPassRuleResult rule = this.getRuleByImageStore(param.getImageStoreId(), context);
|
||||
result.setBeginDate(imageStorePersonResult.getExpiryBeginDate());
|
||||
result.setEndDate(imageStorePersonResult.getExpiryEndDate());
|
||||
result.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
|
||||
if (imageStorePersonResult.getExpiryBeginDate() != null || imageStorePersonResult.getExpiryEndDate() != null) {
|
||||
result.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)imageStorePersonResult.getValidDateCron())) {
|
||||
BeanCopyUtils.copyProperties((Object)rule, (Object)result);
|
||||
result.setPassableTimeId(rule.getPassableTimeId());
|
||||
result.setPassableTimeName(rule.getPassableTimeName());
|
||||
List timeCycleParams = JSONObject.parseArray((String)rule.getValidDateJson(), AcsPassTimeCycleParam.class);
|
||||
result.setPassableCycle(timeCycleParams);
|
||||
result.setPassType(AcsPassTypeEnum.PASS_TIME.getCode());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(ref = this.getPersonImageStoreRef(imageStorePersonResult.getPersonId(), imageStorePersonResult.getImageStoreId(), context))) {
|
||||
AcsPassTimeResult timeResult = this.getPassTimeById(ref.get(0).getPassableTimeId(), context);
|
||||
result.setPassableTimeName(timeResult.getPassableTimeName());
|
||||
result.setPassableTimeId(timeResult.getPassableTimeId());
|
||||
result.setPassableCycle(timeResult.getPassableCycle());
|
||||
result.setPassType(AcsPassTypeEnum.PASS_TIME.getCode());
|
||||
}
|
||||
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
|
||||
imageStorePersonQueryParam.setPersonId(param.getPersonId());
|
||||
imageStorePersonQueryParam.setRowsOfPage(1000);
|
||||
CloudwalkResult imageStorePersonPageResult = this.imageStorePersonService.page(imageStorePersonQueryParam, context);
|
||||
ImageStorePersonResult imageStoreResult = (ImageStorePersonResult)((CloudwalkPageAble)imageStorePersonPageResult.getData()).getDatas().iterator().next();
|
||||
result.setComparePicture(imageStoreResult.getComparePicture());
|
||||
result.setPersonName(imageStoreResult.getName());
|
||||
result.setPersonId(imageStoreResult.getPersonId());
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
|
||||
private AcsPassRuleResult getRuleByImageStore(String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleQueryParam ruleQueryParam = new AcsPassRuleQueryParam();
|
||||
ruleQueryParam.setImageStoreId(imageStoreId);
|
||||
CloudwalkResult results = this.acsPassRuleService.list(ruleQueryParam, context);
|
||||
return (AcsPassRuleResult)((List)results.getData()).get(0);
|
||||
}
|
||||
|
||||
private ImageStorePersonResult getImageStorePersonResult(AcsPersonTimeDetailParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
|
||||
imageStorePersonQueryParam.setImageStoreId(param.getImageStoreId());
|
||||
imageStorePersonQueryParam.setPersonId(param.getPersonId());
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u901a\u884c\u4eba\u5458\u5165\u53c2\uff0cImageStorePersonQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)imageStorePersonQueryParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult pageResult = this.imageStorePersonService.page(imageStorePersonQueryParam, context);
|
||||
if (!pageResult.isSuccess() || CollectionUtils.isEmpty((Collection)((CloudwalkPageAble)pageResult.getData()).getDatas())) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u901a\u884c\u4eba\u5458\u5931\u8d25\uff0c\u539f\u56e0\uff1a" + pageResult.getMessage());
|
||||
throw new ServiceException("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u901a\u884c\u4eba\u5458\u5931\u8d25");
|
||||
}
|
||||
List list = (List)((CloudwalkPageAble)pageResult.getData()).getDatas();
|
||||
return (ImageStorePersonResult)list.get(0);
|
||||
}
|
||||
|
||||
private List<String> mergeTime(List<ImageStorePersonResult> imageStorePersonList) {
|
||||
ArrayList<String> passIntervals = new ArrayList<String>();
|
||||
List personLongTerm = imageStorePersonList.stream().filter(s -> s.getExpiryBeginDate() == null && s.getExpiryEndDate() == null).collect(Collectors.toList());
|
||||
if (CollectionUtils.isNotEmpty(personLongTerm)) {
|
||||
passIntervals.add("\u957f\u671f");
|
||||
} else {
|
||||
Collections.sort(imageStorePersonList, (t1, t2) -> t1.getExpiryBeginDate().compareTo(t2.getExpiryEndDate()));
|
||||
for (int i = 0; i < imageStorePersonList.size() - 1; ++i) {
|
||||
int j = i + 1;
|
||||
if (imageStorePersonList.get(i).getExpiryEndDate() < imageStorePersonList.get(j).getExpiryBeginDate()) continue;
|
||||
if (imageStorePersonList.get(i).getExpiryEndDate() >= imageStorePersonList.get(j).getExpiryEndDate()) {
|
||||
imageStorePersonList.set(j, imageStorePersonList.get(i));
|
||||
} else {
|
||||
imageStorePersonList.get(j).setExpiryBeginDate(imageStorePersonList.get(i).getExpiryBeginDate());
|
||||
}
|
||||
imageStorePersonList.set(i, null);
|
||||
}
|
||||
List personTimeMergeList = imageStorePersonList.stream().filter(s -> s != null).collect(Collectors.toList());
|
||||
for (ImageStorePersonResult personTimeMerge : personTimeMergeList) {
|
||||
String beginDate = DateUtils.parseDate((Date)new Date(personTimeMerge.getExpiryBeginDate()), (String)"yyyy-MM-dd HH:mm:ss");
|
||||
String endDate = DateUtils.parseDate((Date)new Date(personTimeMerge.getExpiryEndDate()), (String)"yyyy-MM-dd HH:mm:ss");
|
||||
passIntervals.add(beginDate + " \u81f3 " + endDate);
|
||||
}
|
||||
}
|
||||
return passIntervals;
|
||||
}
|
||||
|
||||
private void covertPageResult(List<AcsPersonResult> result, Collection<ImageStorePersonResult> datas, Map<String, AcsPassRuleResult> ruleMap, CloudwalkCallContext context) throws ServiceException {
|
||||
List<String> personIds = datas.stream().map(ImageStorePersonResult::getPersonId).collect(Collectors.toList());
|
||||
Map<String, PersonResult> personIcCardMap = this.getPersonIcCardByIds(personIds, context);
|
||||
for (ImageStorePersonResult data : datas) {
|
||||
AcsPassRuleResult rule = null;
|
||||
AcsPersonResult acsPersonResult = new AcsPersonResult();
|
||||
if (ruleMap != null && ruleMap.get(data.getImageStoreId()) != null) {
|
||||
rule = ruleMap.get(data.getImageStoreId());
|
||||
acsPersonResult.setRuleName(rule.getRuleName());
|
||||
acsPersonResult.setRuleId(rule.getId());
|
||||
}
|
||||
BeanCopyUtils.copyProperties((Object)data, (Object)acsPersonResult);
|
||||
acsPersonResult.setPersonName(data.getName());
|
||||
acsPersonResult.setStartTime(data.getExpiryBeginDate());
|
||||
acsPersonResult.setEndTime(data.getExpiryEndDate());
|
||||
acsPersonResult.setPassType(AcsPassTypeEnum.LONG_TIME.getCode());
|
||||
if (data.getExpiryBeginDate() != null || data.getExpiryEndDate() != null) {
|
||||
acsPersonResult.setPassType(AcsPassTypeEnum.AUTO_PASS.getCode());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)data.getValidDateCron()) && rule != null) {
|
||||
acsPersonResult.setPassableTimeId(rule.getPassableTimeId());
|
||||
acsPersonResult.setPassableTimeName(rule.getPassableTimeName());
|
||||
List<AcsPassableRefResultDto> ref = this.getPersonImageStoreRef(data.getPersonId(), data.getImageStoreId(), context);
|
||||
if (!CollectionUtils.isEmpty(ref)) {
|
||||
AcsPassTimeResult timeResult = this.getPassTimeById(ref.get(0).getPassableTimeId(), context);
|
||||
acsPersonResult.setPassableTimeName(timeResult.getPassableTimeName());
|
||||
acsPersonResult.setPassableTimeId(timeResult.getPassableTimeId());
|
||||
}
|
||||
acsPersonResult.setPassType(AcsPassTypeEnum.PASS_TIME.getCode());
|
||||
}
|
||||
PersonResult personResult = personIcCardMap.get(data.getPersonId());
|
||||
if (personIcCardMap != null && personResult != null) {
|
||||
acsPersonResult.setIcCardNo(personResult.getIcCardNo());
|
||||
acsPersonResult.setOrganizationIds(personResult.getOrganizationIds());
|
||||
acsPersonResult.setOrganizationNames(personResult.getOrganizationNames());
|
||||
acsPersonResult.setLabelIds(personResult.getLabelIds());
|
||||
acsPersonResult.setLabelNames(personResult.getLabelNames());
|
||||
}
|
||||
result.add(acsPersonResult);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, PersonResult> getPersonIcCardByIds(List<String> personIds, CloudwalkCallContext context) throws ServiceException {
|
||||
Map<String, PersonResult> personIcCardMap = null;
|
||||
PersonQueryParam param = new PersonQueryParam();
|
||||
param.setIds(personIds);
|
||||
CloudwalkResult personResult = this.personService.list(param, context);
|
||||
List personList = (List)personResult.getData();
|
||||
if (personResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)personList)) {
|
||||
personIcCardMap = personList.stream().collect(Collectors.toMap(CloudwalkBaseIdentify::getId, PersonResult2 -> PersonResult2));
|
||||
}
|
||||
return personIcCardMap;
|
||||
}
|
||||
|
||||
private List<AcsPassableRefResultDto> getPersonImageStoreRef(String personId, String imageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsPassableRefQueryDto dto = new AcsPassableRefQueryDto();
|
||||
dto.setImageStoreId(imageStoreId);
|
||||
dto.setPersonId(personId);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
return this.acsPassableRefManager.query(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u4eba\u5458\u65f6\u95f4\u56fe\u5e93\u5173\u8054\u5931\u8d25,\u539f\u56e0\uff1a", (Object)e.getMessage());
|
||||
throw new ServiceException("76260509", this.getMessage("76260509"));
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getPersonIdsByName(String personName, CloudwalkCallContext context) throws ServiceException {
|
||||
List<String> personIdsByName = new ArrayList<String>();
|
||||
if (StringUtils.isNotBlank((String)personName)) {
|
||||
PersonQueryParam personQueryParam = new PersonQueryParam();
|
||||
personQueryParam.setName(personName);
|
||||
CloudwalkResult personResult = this.personService.list(personQueryParam, context);
|
||||
List personList = (List)personResult.getData();
|
||||
if (personResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)personList)) {
|
||||
personIdsByName = personList.stream().map(CloudwalkBaseIdentify::getId).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
return personIdsByName;
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResult> getRuleListByDeviceId(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassRuleQueryParam param = new AcsPassRuleQueryParam();
|
||||
param.setDeviceId(deviceId);
|
||||
CloudwalkResult ruleResult = this.acsPassRuleService.list(param, context);
|
||||
if (!ruleResult.isSuccess()) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5931\u8d25,\u539f\u56e0:[{}]", (Object)ruleResult.getMessage());
|
||||
throw new ServiceException("76260508", ruleResult.getMessage());
|
||||
}
|
||||
return (List)ruleResult.getData();
|
||||
}
|
||||
|
||||
private String getAcsImageStore(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsdeviceDetailQueryParam acsdeviceDetailQueryParam = new AcsdeviceDetailQueryParam();
|
||||
acsdeviceDetailQueryParam.setDeviceId(deviceId);
|
||||
CloudwalkResult deviceDetailResult = this.acsDeviceService.detail(acsdeviceDetailQueryParam, context);
|
||||
if (deviceDetailResult.isSuccess()) {
|
||||
if (deviceDetailResult.getData() != null) {
|
||||
return ((AcsDeviceDetailResult)deviceDetailResult.getData()).getImageStoreId();
|
||||
}
|
||||
throw new ServiceException("\u95e8\u7981\u56fe\u5e93\u4e0d\u5b58\u5728");
|
||||
}
|
||||
throw new ServiceException(deviceDetailResult.getCode(), deviceDetailResult.getMessage());
|
||||
}
|
||||
|
||||
private void checkPersonIdByImageStore(String personId, String acsImageStoreId, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStorePersonQueryParam imageStorePersonQueryParam = new ImageStorePersonQueryParam();
|
||||
imageStorePersonQueryParam.setPersonId(personId);
|
||||
imageStorePersonQueryParam.setImageStoreId(acsImageStoreId);
|
||||
this.logger.info("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u901a\u884c\u4eba\u5458\u5165\u53c2\uff0cImageStorePersonQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)imageStorePersonQueryParam), (Object)JSONObject.toJSONString((Object)context));
|
||||
CloudwalkResult imageStorePersonResult = this.imageStorePersonService.page(imageStorePersonQueryParam, context);
|
||||
if (imageStorePersonResult.isSuccess()) {
|
||||
if (imageStorePersonResult.getData() == null || CollectionUtils.isEmpty((Collection)((CloudwalkPageAble)imageStorePersonResult.getData()).getDatas())) {
|
||||
throw new ServiceException("\u8be5\u4eba\u5458\u672a\u7ed1\u5b9a\u95e8\u7981\u56fe\u5e93\uff0c\u4eba\u5458id\u4e3a:" + personId);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceException(imageStorePersonResult.getCode(), imageStorePersonResult.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private List<DeviceImageStoreResult> getDeviceImageStore(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceImageStoreQueryParam deviceImageStoreQueryParam = new DeviceImageStoreQueryParam();
|
||||
deviceImageStoreQueryParam.setDeviceId(deviceId);
|
||||
CloudwalkResult imageStoreResult = this.deviceImageStoreService.list(deviceImageStoreQueryParam, context);
|
||||
if (imageStoreResult.isSuccess()) {
|
||||
if (CollectionUtils.isNotEmpty((Collection)((Collection)imageStoreResult.getData()))) {
|
||||
return (List)imageStoreResult.getData();
|
||||
}
|
||||
throw new ServiceException("\u8be5\u8bbe\u5907\u672a\u7ed1\u5b9a\u56fe\u5e93");
|
||||
}
|
||||
throw new ServiceException(imageStoreResult.getCode(), imageStoreResult.getMessage());
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<String> checkPersonTime(AcsPersonCheckTimeParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsPassTimeQueryParam queryTimeParam;
|
||||
List passTimeList;
|
||||
this.logger.info("\u901a\u884c\u4eba\u5458\u65f6\u95f4\u6821\u9a8c\uff0cAcsPersonCheckTimeParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
List<ImageStorePersonResult> results = this.getPersonImageStore(param.getPersonId(), param.getImageStoreIds(), context);
|
||||
List<AcsPassableRefResultDto> ref = this.getPersonImageStoreRef(param.getPersonId(), null, context);
|
||||
Map<String, AcsPassableRefResultDto> refMap = null;
|
||||
Map<String, AcsPassTimeResult> passTimeMap = null;
|
||||
if (!CollectionUtils.isEmpty(ref)) {
|
||||
refMap = ref.stream().collect(Collectors.toMap(AcsPassableRefResultDto::getImageStoreId, AcsPassableRefResultDto2 -> AcsPassableRefResultDto2));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty((Collection)(passTimeList = (List)this.acsPassTimeService.list(queryTimeParam = new AcsPassTimeQueryParam(), context).getData()))) {
|
||||
passTimeMap = passTimeList.stream().collect(Collectors.toMap(AcsPassTimeResult::getPassableTimeId, AcsPassTimeResult2 -> AcsPassTimeResult2));
|
||||
}
|
||||
List<AcsPassRuleResultDto> ruleList = this.getRuleByImageStoreIds(param.getImageStoreIds(), context);
|
||||
Map<String, AcsPassRuleResultDto> ruleMap = ruleList.stream().collect(Collectors.toMap(AcsPassRuleResultDto::getImageStoreId, AcsPassRuleResultDto2 -> AcsPassRuleResultDto2));
|
||||
for (ImageStorePersonResult result : results) {
|
||||
AcsPassTimeResult timeResult;
|
||||
if (result.getExpiryBeginDate() == null && result.getExpiryEndDate() == null) {
|
||||
return CloudwalkResult.success((Object)result.getImageStoreId());
|
||||
}
|
||||
if (!DateUtils.timeIsInRound((String)DateUtils.formatDate((Date)new Date(param.getTime()), (String)"yyyy-MM-dd HH:mm:ss"), (String)DateUtils.formatDate((Date)new Date(result.getExpiryBeginDate()), (String)"yyyy-MM-dd HH:mm:ss"), (String)DateUtils.formatDate((Date)new Date(result.getExpiryEndDate()), (String)"yyyy-MM-dd HH:mm:ss"), (String)"yyyy-MM-dd HH:mm:ss")) continue;
|
||||
if (CollectionUtils.isEmpty((Collection)result.getValidDateCron())) {
|
||||
return CloudwalkResult.success((Object)result.getImageStoreId());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(refMap) && refMap.containsKey(result.getImageStoreId())) {
|
||||
timeResult = passTimeMap.get(refMap.get(result.getImageStoreId()).getPassableTimeId());
|
||||
if (!this.isInTimeCut(param.getTime(), timeResult).booleanValue()) continue;
|
||||
return CloudwalkResult.success((Object)result.getImageStoreId());
|
||||
}
|
||||
if (!ruleMap.containsKey(result.getImageStoreId())) continue;
|
||||
timeResult = passTimeMap.get(ruleMap.get(result.getImageStoreId()).getPassableTimeId());
|
||||
if (!this.isInTimeCut(param.getTime(), timeResult).booleanValue()) continue;
|
||||
return CloudwalkResult.success((Object)result.getImageStoreId());
|
||||
}
|
||||
return CloudwalkResult.fail((String)"76260510", (String)"\u4eba\u5458\u4e0d\u5728\u901a\u884c\u65f6\u95f4\u5185");
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsPersonResult>> pageByApp(AcsPersonQueryByAppParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u5e94\u7528\u901a\u884c\u4eba\u5458\u5165\u53c2\uff1aAcsPersonQueryByAppParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
List<String> personIds = null;
|
||||
ArrayList<AcsPersonResult> result = new ArrayList<AcsPersonResult>();
|
||||
List<ImageStoreListResult> imageStoreResult = this.getImageStoreIdsByAppAndDevice(param.getApplicationId(), param.getDeviceId(), context);
|
||||
List<String> imageStoreIds = imageStoreResult.stream().map(ImageStoreListResult::getId).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(imageStoreIds)) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
if (!StringUtils.isEmpty((String)param.getPersonName()) && CollectionUtils.isEmpty(personIds = this.getPersonIdsByName(param.getPersonName(), context))) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, 0L));
|
||||
}
|
||||
CloudwalkPageAble<ImageStorePersonResult> pageResult = this.getAppImageStorePerson(imageStoreIds, personIds, pageInfo, context);
|
||||
if (!CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
this.covertPageResult(result, pageResult.getDatas(), null, context);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
|
||||
private CloudwalkPageAble<ImageStorePersonResult> getAppImageStorePerson(List<String> imageStoreIds, List<String> personIds, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStorePersonQueryParam param = new ImageStorePersonQueryParam();
|
||||
param.setImageStoreIds(imageStoreIds);
|
||||
param.setPersonIds(personIds);
|
||||
param.setCurrentPage(pageInfo.getCurrentPage());
|
||||
param.setRowsOfPage(pageInfo.getPageSize());
|
||||
CloudwalkResult pageResult = this.imageStorePersonService.page(param, context);
|
||||
if (!pageResult.isSuccess()) {
|
||||
this.logger.error("\u8fdc\u7a0b\u8c03\u7528\u67e5\u8be2\u56fe\u5e93\u4eba\u5458\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)pageResult.getMessage());
|
||||
throw new ServiceException(pageResult.getCode(), pageResult.getMessage());
|
||||
}
|
||||
return (CloudwalkPageAble)pageResult.getData();
|
||||
}
|
||||
|
||||
private List<AcsPassRuleResultDto> getRuleByImageStoreIds(List<String> imageStoreIds, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsPassRuleQueryDto dto = new AcsPassRuleQueryDto();
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
dto.setImageStoreIds(imageStoreIds);
|
||||
return this.acsPassRuleManager.query(dto);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u901a\u884c\u89c4\u5219\u5931\u8d25");
|
||||
throw new ServiceException("76260508", this.getMessage("76260508"));
|
||||
}
|
||||
}
|
||||
|
||||
private Boolean isInTimeCut(Long time, AcsPassTimeResult timeResult) {
|
||||
Map<Integer, List> timeCycle = timeResult.getPassableCycle().stream().collect(Collectors.toMap(AcsPassTimeCycleParam::getWeekday, AcsPassTimeCycleParam::getTime));
|
||||
List timeCutList = timeCycle.get(DateUtils.getDayOfWeek((Date)new Date(time)));
|
||||
if (!CollectionUtils.isEmpty((Collection)timeCutList)) {
|
||||
for (AcsPassTimeParam timeCut : timeCutList) {
|
||||
if (!DateUtils.timeIsInRound((String)DateUtils.formatDate((Date)new Date(time), (String)"HH:mm:ss"), (String)timeCut.getBeginTime(), (String)timeCut.getEndTime(), (String)"HH:mm:ss")) continue;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private List<ImageStorePersonResult> getPersonImageStore(String personId, List<String> imageStoreIds, CloudwalkCallContext context) throws ServiceException {
|
||||
ImageStorePersonQueryParam param = new ImageStorePersonQueryParam();
|
||||
param.setImageStoreIds(imageStoreIds);
|
||||
param.setPersonId(personId);
|
||||
CloudwalkResult imageStorePersonResult = this.imageStorePersonService.page(param, context);
|
||||
if (!imageStorePersonResult.isSuccess()) {
|
||||
throw new ServiceException(imageStorePersonResult.getCode(), imageStorePersonResult.getMessage());
|
||||
}
|
||||
return (List)((CloudwalkPageAble)imageStorePersonResult.getData()).getDatas();
|
||||
}
|
||||
}
|
||||
|
||||
+212
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsElevatorRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsElevatorRecordAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsElevatorRecordService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* cn.cloudwalk.cwos.client.event.event.BaseEvent
|
||||
* cn.cloudwalk.event.CloudwalkEventManager
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.BeanUtils
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsElevatorRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsElevatorRecordAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsElevatorRecordService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
|
||||
import cn.cloudwalk.event.CloudwalkEventManager;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.event.CustomOpenDoorRecordEvent;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsElevatorRecordServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsElevatorRecordService {
|
||||
@Resource
|
||||
private AcsElevatorRecordManager acsElevatorRecordManager;
|
||||
@Resource
|
||||
private AcsOperateRecordManager acsOperateRecordManager;
|
||||
@Resource
|
||||
private CloudwalkEventManager cloudwalkEventManager;
|
||||
@Resource
|
||||
private AccessControlProperties accessControlProperties;
|
||||
private static final int DELAY_TIME = 10000;
|
||||
|
||||
public CloudwalkResult<Boolean> add(AcsElevatorRecordAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsElevatorRecordAddDTO addDTO = new AcsElevatorRecordAddDTO();
|
||||
String deviceId = "";
|
||||
String deviceAddress = "";
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)addDTO);
|
||||
if (param.getDeviceResult() != null) {
|
||||
DeviceResult deviceResult = param.getDeviceResult();
|
||||
BeanCopyUtils.copyProperties((Object)deviceResult, (Object)addDTO);
|
||||
addDTO.setDeviceId(deviceResult.getId());
|
||||
deviceId = deviceResult.getId();
|
||||
deviceAddress = this.getAddress(deviceResult);
|
||||
}
|
||||
addDTO.setId(this.genUUID());
|
||||
addDTO.setCreateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setCreateUserId(context.getUser().getCaller());
|
||||
addDTO.setLastUpdateUserId(context.getUser().getCaller());
|
||||
OpenDoorTypeEnum openDoorType = OpenDoorTypeEnum.getOpenDoorTypeEnumByCode((String)param.getOpenDoorType());
|
||||
if (StringUtils.isNotBlank((String)deviceId) && openDoorType != null && OpenDoorTypeEnum.APP.getCode().equals(openDoorType.getCode())) {
|
||||
String operateName = this.getOperateName(param, deviceId);
|
||||
if (StringUtils.isNotBlank((String)operateName)) {
|
||||
addDTO.setOperateName(operateName);
|
||||
} else {
|
||||
this.logger.info("\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\u7528\u6237\u540d\u4e3a\u7a7a,recognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
}
|
||||
}
|
||||
this.acsElevatorRecordManager.add(addDTO);
|
||||
try {
|
||||
this.publish(context, addDTO, deviceAddress);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u4fdd\u5b58\u5f00\u95e8\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Integer> modify(AcsOpenDoorRecordEditParam param) throws ServiceException {
|
||||
try {
|
||||
this.logger.info("\u66f4\u65b0\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u5f00\u59cb:AcsOpenDoorRecordEditParam=[{}]", (Object)JSONObject.toJSONString((Object)param));
|
||||
Integer updateCount = 0;
|
||||
AcsOpenDoorRecordQueryDTO queryDTO = new AcsOpenDoorRecordQueryDTO();
|
||||
BeanUtils.copyProperties((Object)param, (Object)queryDTO);
|
||||
List queryResult = this.acsElevatorRecordManager.query(queryDTO);
|
||||
if (CollectionUtils.isNotEmpty((Collection)queryResult)) {
|
||||
AcsElevatorRecordQueryResultDTO openDoorRecord = (AcsElevatorRecordQueryResultDTO)queryResult.get(0);
|
||||
if (AcsOpenDoorStatusEnum.INIT.getCode().equals(openDoorRecord.getRecordResult())) {
|
||||
AcsOpenDoorRecordEditDTO editDTO = new AcsOpenDoorRecordEditDTO();
|
||||
BeanUtils.copyProperties((Object)param, (Object)editDTO);
|
||||
editDTO.setId(openDoorRecord.getId());
|
||||
editDTO.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
updateCount = this.acsElevatorRecordManager.update(editDTO);
|
||||
this.logger.info("\u66f4\u65b0\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u7ed3\u675f,\u66f4\u65b0\u6761\u6570:[{}]", (Object)updateCount);
|
||||
}
|
||||
}
|
||||
return CloudwalkResult.success((Object)updateCount);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
throw new ServiceException("76260007", this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
|
||||
private void publish(CloudwalkCallContext context, AcsElevatorRecordAddDTO addDTO, String deviceAddress) {
|
||||
if (this.accessControlProperties.getPublishOpendoorSwitch().booleanValue() && StringUtils.isNotBlank((String)this.accessControlProperties.getPublishOpendoorServiceCode())) {
|
||||
CustomOpenDoorRecordEvent openDoorRecordEvent = new CustomOpenDoorRecordEvent();
|
||||
BeanCopyUtils.copyProperties((Object)addDTO, (Object)((Object)openDoorRecordEvent));
|
||||
openDoorRecordEvent.setPanoramaImage(this.genFullPath(addDTO.getPanoramaImagePath()));
|
||||
openDoorRecordEvent.setFaceImage(this.genFullPath(addDTO.getFaceImagePath()));
|
||||
if (StringUtils.isNotBlank((String)addDTO.getOpenDoorType())) {
|
||||
openDoorRecordEvent.setOpenDoorTypeCode(addDTO.getOpenDoorType());
|
||||
openDoorRecordEvent.setOpenDoorTypeMsg(OpenDoorTypeEnum.getEnumByCode((String)addDTO.getOpenDoorType()));
|
||||
}
|
||||
openDoorRecordEvent.setDeviceAddress(deviceAddress);
|
||||
openDoorRecordEvent.setMessageId(String.valueOf(System.currentTimeMillis()));
|
||||
openDoorRecordEvent.setServiceCode(this.accessControlProperties.getPublishOpendoorServiceCode());
|
||||
openDoorRecordEvent.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.logger.info("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u5f00\u59cb\uff0cCustomOpenDooerRecordEvent=[{}]", (Object)JSONObject.toJSONString((Object)((Object)openDoorRecordEvent)));
|
||||
this.cloudwalkEventManager.publish((BaseEvent)openDoorRecordEvent);
|
||||
this.logger.info("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u7ed3\u675f");
|
||||
}
|
||||
}
|
||||
|
||||
private String getOperateName(AcsElevatorRecordAddParam param, String deviceId) throws DataAccessException {
|
||||
AcsOperateRecordQueryDTO operateRecordQueryDTO = new AcsOperateRecordQueryDTO();
|
||||
operateRecordQueryDTO.setBusinessId(param.getBusinessId());
|
||||
operateRecordQueryDTO.setDeviceId(deviceId);
|
||||
ArrayList<String> operateTypeCodes = new ArrayList<String>();
|
||||
operateTypeCodes.add(AcsOperateTypeEnum.REMOTE_OPEN_DOOR.getCode());
|
||||
operateTypeCodes.add(AcsOperateTypeEnum.QRCODE_OPEN_DOOR.getCode());
|
||||
operateRecordQueryDTO.setOperateTypeCodes(operateTypeCodes);
|
||||
operateRecordQueryDTO.setStatus(AcsOperateStatusEnum.INIT.getCode());
|
||||
operateRecordQueryDTO.setDelayTime(Long.valueOf(DateUtils.getCurrentTime() - 10000L));
|
||||
List operateRecordList = this.acsOperateRecordManager.queryOrderByOperateTime(operateRecordQueryDTO);
|
||||
if (!CollectionUtils.isEmpty((Collection)operateRecordList)) {
|
||||
AcsOperateRecordQueryResultDTO acsOperateRecordQueryResultDTO = (AcsOperateRecordQueryResultDTO)operateRecordList.get(0);
|
||||
AcsOperateRecordEditDTO operateRecordEditDTO = new AcsOperateRecordEditDTO();
|
||||
operateRecordEditDTO.setId(acsOperateRecordQueryResultDTO.getId());
|
||||
operateRecordEditDTO.setStatus(AcsOperateStatusEnum.MATCHED.getCode());
|
||||
int updateCount = this.acsOperateRecordManager.update(operateRecordEditDTO);
|
||||
if (updateCount < 1) {
|
||||
this.logger.info("\u6ca1\u627e\u5230\u5339\u914d\u7684\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\uff0c\u4e0d\u4fdd\u5b58\u8be5\u6761\u5f00\u95e8\u6570\u636e\uff0crecognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
}
|
||||
return acsOperateRecordQueryResultDTO.getOperateName();
|
||||
}
|
||||
this.logger.info("\u6ca1\u627e\u5230\u5339\u914d\u7684\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\uff0c\u4e0d\u4fdd\u5b58\u8be5\u6761\u5f00\u95e8\u6570\u636e\uff0crecognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
return null;
|
||||
}
|
||||
|
||||
private String genFullPath(String path) {
|
||||
return StringUtils.isNotBlank((String)path) ? this.accessControlProperties.getCwosPicUrl() + path : null;
|
||||
}
|
||||
}
|
||||
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsEvacuateRecordManager
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsEvacuateRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsEvacuateRecordService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordResultDTO
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsEvacuateRecordManager;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsEvacuateRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsEvacuateRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsEvacuateRecordService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsEvacuateRecordResultDTO;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsEvacuateRecordServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsEvacuateRecordService {
|
||||
@Autowired
|
||||
private AcsEvacuateRecordManager acsEvacuateRecordManager;
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsEvacuateRecordResult>> page(AcsEvacuateRecordPageParam param, CloudwalkPageInfo page, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsEvacuateRecordQueryDTO dto = new AcsEvacuateRecordQueryDTO();
|
||||
List<Object> result = new ArrayList();
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)dto);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkPageAble pageResult = this.acsEvacuateRecordManager.page(dto, page);
|
||||
if (pageResult.getDatas() == null || pageResult.getDatas().isEmpty()) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, 0L));
|
||||
}
|
||||
result = this.convertPageResult(pageResult.getDatas());
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, pageResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5206\u9875\u67e5\u8be2\u758f\u6563\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private List<AcsEvacuateRecordResult> convertPageResult(Collection<AcsEvacuateRecordResultDTO> datas) {
|
||||
ArrayList<AcsEvacuateRecordResult> result = new ArrayList<AcsEvacuateRecordResult>();
|
||||
for (AcsEvacuateRecordResultDTO data : datas) {
|
||||
AcsEvacuateRecordResult recordResult = new AcsEvacuateRecordResult();
|
||||
BeanCopyUtils.copyProperties((Object)data, (Object)recordResult);
|
||||
recordResult.setDeviceNames(JSONObject.parseArray((String)data.getDeviceName(), String.class));
|
||||
result.add(recordResult);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.param.FeatureQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.result.FeatureQueryResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.biology.service.BiologyToolService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.EntranceGuardControlParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsCompareParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsFaceCaptureParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsFaceCaptureService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecogRecordService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AcsConstants
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsRecognitionStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsSwitchEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* cn.cloudwalk.intelligent.lock.annotation.RequiredLock
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.aop.framework.AopContext
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.data.redis.core.RedisTemplate
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.transaction.annotation.Propagation
|
||||
* org.springframework.transaction.annotation.Transactional
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.param.FeatureQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.result.FeatureQueryResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.biology.service.BiologyToolService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.EntranceGuardControlParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsCompareParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsFaceCaptureParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsFaceCaptureService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecogRecordService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AcsConstants;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsRecognitionStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsSwitchEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.intelligent.lock.annotation.RequiredLock;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Service
|
||||
public class AcsFaceCaptureServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsFaceCaptureService {
|
||||
@Autowired
|
||||
private AcsFileStorageService fileStorageService;
|
||||
@Autowired
|
||||
private BiologyToolService biologyToolService;
|
||||
@Autowired
|
||||
private AcsRecogRecordService acsRecogRecordService;
|
||||
@Autowired
|
||||
private AcsOpenDoorRecordService acsOpenDoorRecordService;
|
||||
@Autowired
|
||||
private DeviceNotifyService deviceNotifyService;
|
||||
@Autowired
|
||||
private AcsOpenDoorRecordManager acsOpenDoorRecordManager;
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<FeatureQueryResult> compare(AcsCompareParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult faceImageResult = this.fileStorageService.getFileBase64(param.getImagePath());
|
||||
if (faceImageResult.isSuccess()) {
|
||||
String faceImage = (String)faceImageResult.getData();
|
||||
FeatureQueryParam featureQueryParam = new FeatureQueryParam();
|
||||
featureQueryParam.setImageBase64(faceImage);
|
||||
featureQueryParam.setTopN(Integer.valueOf(1));
|
||||
featureQueryParam.setImageStoreIds(param.getImageStoreIds());
|
||||
this.logger.info("\u8c03\u75281:N\u8bc6\u522b\u63a5\u53e3\u5f00\u59cb,FeatureQueryParam=[{}]", (Object)JSONObject.toJSONString((Object)featureQueryParam));
|
||||
CloudwalkResult captureCompareResult = this.biologyToolService.query(featureQueryParam, context);
|
||||
this.logger.info("\u8c03\u75281:N\u8bc6\u522b\u63a5\u53e3\u7ed3\u675f,captureCompareResult=[{}]", (Object)JSONObject.toJSONString((Object)captureCompareResult));
|
||||
if (captureCompareResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)((Collection)captureCompareResult.getData()))) {
|
||||
return CloudwalkResult.success(((List)captureCompareResult.getData()).get(0));
|
||||
}
|
||||
return CloudwalkResult.fail((String)"76260332", (String)this.getMessage("76260332"));
|
||||
}
|
||||
throw new ServiceException(faceImageResult.getCode(), faceImageResult.getMessage());
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
@Transactional(propagation=Propagation.REQUIRED, rollbackFor={Exception.class})
|
||||
public CloudwalkResult<Boolean> saveRecordAndOpenDoor(AcsFaceCaptureParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u4fdd\u5b58\u5f00\u95e8\u548c\u8bc6\u522b\u8bb0\u5f55\u5e76\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u5f00\u59cb:AcsFaceCaptureParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
this.saveResultAndNotify(param, context);
|
||||
this.logger.info("\u4fdd\u5b58\u5f00\u95e8\u548c\u8bc6\u522b\u8bb0\u5f55\u5e76\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u7ed3\u675f");
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void saveOpenDoorRecord(AcsFaceCaptureParam param, String regLogId, String openDoorLogId, Integer openDoorResult, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsOpenDoorRecordAddParam addParam = new AcsOpenDoorRecordAddParam();
|
||||
addParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
addParam.setDeviceCode(param.getDeviceCode());
|
||||
addParam.setDeviceName(param.getDeviceResult().getDeviceName());
|
||||
addParam.setDeviceResult(param.getDeviceResult());
|
||||
addParam.setLogId(openDoorLogId);
|
||||
addParam.setOpenDoorType(OpenDoorTypeEnum.FACE.getCode());
|
||||
addParam.setRecognitionFaceId(regLogId);
|
||||
addParam.setRecognitionTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
addParam.setRecordResult(openDoorResult);
|
||||
CloudwalkResult result = this.acsOpenDoorRecordService.add(addParam, context);
|
||||
if (!result.isSuccess()) {
|
||||
this.logger.error("\u540e\u7aef\u8bc6\u522b\u4fdd\u5b58\u5f00\u95e8\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)result.getMessage());
|
||||
throw new ServiceException("\u540e\u7aef\u8bc6\u522b\u4fdd\u5b58\u5f00\u95e8\u8bb0\u5f55\u5931\u8d25");
|
||||
}
|
||||
this.redisTemplate.opsForValue().set((Object)AcsCacheKeyUtil.getBackendRegExpireKey((String)context.getCompany().getCompanyId(), (String)openDoorLogId), (Object)openDoorLogId, this.accessControlProperties.getFaceCaptureOpenDoorFailMilliseconds().longValue(), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private void saveRecogRecord(AcsFaceCaptureParam param, String regLogId, Integer regResult, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsRecogRecordAddParam acsRecogRecordAddParam = new AcsRecogRecordAddParam();
|
||||
acsRecogRecordAddParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
acsRecogRecordAddParam.setDeviceCode(param.getDeviceCode());
|
||||
acsRecogRecordAddParam.setDeviceName(param.getDeviceResult().getDeviceName());
|
||||
acsRecogRecordAddParam.setDeviceResult(param.getDeviceResult());
|
||||
acsRecogRecordAddParam.setFaceId(param.getFaceId());
|
||||
acsRecogRecordAddParam.setGroupId(param.getGroupId());
|
||||
acsRecogRecordAddParam.setLogId(regLogId);
|
||||
acsRecogRecordAddParam.setFaceImagePath(param.getFaceImagePath());
|
||||
acsRecogRecordAddParam.setRecognitionTime(param.getRecognitionTime());
|
||||
acsRecogRecordAddParam.setMaskScore(param.getMaskScore());
|
||||
if (param.getQualityScore() != null) {
|
||||
acsRecogRecordAddParam.setQualityScore(param.getQualityScore());
|
||||
} else {
|
||||
acsRecogRecordAddParam.setQualityScore(BigDecimal.ZERO);
|
||||
}
|
||||
acsRecogRecordAddParam.setTempScore(param.getTempScore());
|
||||
acsRecogRecordAddParam.setPanoramaImagePath(param.getPanoramaImagePath());
|
||||
acsRecogRecordAddParam.setRecognitionResult(regResult);
|
||||
acsRecogRecordAddParam.setScore(param.getScore());
|
||||
acsRecogRecordAddParam.setThreshold(param.getFaceRegThreshold());
|
||||
acsRecogRecordAddParam.setCompareType(param.getCompareType());
|
||||
CloudwalkResult result = this.acsRecogRecordService.add(acsRecogRecordAddParam, context);
|
||||
if (!result.isSuccess()) {
|
||||
this.logger.error("\u540e\u7aef\u8bc6\u522b\u4fdd\u5b58\u8bc6\u522b\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)result.getMessage());
|
||||
throw new ServiceException("\u4fdd\u5b58\u8bc6\u522b\u8bb0\u5f55\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void saveResultAndNotify(AcsFaceCaptureParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
CloudwalkResult<String> cacheResult;
|
||||
String cacheKey = AcsCacheKeyUtil.getBackendRegLogIdKey((String)param.getDeviceCode(), (String)context.getCompany().getCompanyId(), (String)param.getCaptureId());
|
||||
String regLogId = (String)this.redisTemplate.opsForValue().get((Object)cacheKey);
|
||||
if (StringUtils.isBlank((String)regLogId) && !(cacheResult = ((AcsFaceCaptureServiceImpl)AopContext.currentProxy()).initOpenDoorRecordAndNotify(cacheKey, param, context)).isSuccess()) {
|
||||
this.logger.error("\u521b\u5efa\u8bc6\u522b\u8bb0\u5f55logId\u7f13\u5b58\u5931\u8d25,\u539f\u56e0:[{}]", (Object)cacheResult.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredLock(name="T(cn.cloudwalk.common.ninca.accesscontrol.config.AcsLockConstants).LOCK_BACKEND_REG_LOG_ID_PREFIX.concat(#key)", lockWaitTime=10000L)
|
||||
public CloudwalkResult<String> initOpenDoorRecordAndNotify(String key, AcsFaceCaptureParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
String regLogId = this.genUUID();
|
||||
String openDoorLogId = this.genUUID();
|
||||
if (!AcsRecognitionStatusEnum.SUCESS.getCode().equals(param.getRecognitionResult())) {
|
||||
this.saveRecogRecord(param, regLogId, AcsRecognitionStatusEnum.FAIL.getCode(), context);
|
||||
this.saveOpenDoorRecord(param, regLogId, openDoorLogId, AcsOpenDoorStatusEnum.FAIL.getCode(), context);
|
||||
return CloudwalkResult.success((Object)regLogId);
|
||||
}
|
||||
String regLogIdCache = (String)this.redisTemplate.opsForValue().get((Object)key);
|
||||
if (StringUtils.isBlank((String)regLogIdCache)) {
|
||||
try {
|
||||
this.redisTemplate.opsForValue().set((Object)key, (Object)regLogId, this.accessControlProperties.getFaceCaptureIntervalMilliseconds().longValue(), TimeUnit.MILLISECONDS);
|
||||
this.saveOpenDoorRecord(param, regLogId, openDoorLogId, AcsOpenDoorStatusEnum.INIT.getCode(), context);
|
||||
this.notifyOpenDoor(param, context.getCompany().getCompanyId(), openDoorLogId);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u540e\u7aef\u8bc6\u522b\u4fdd\u5b58\u5f00\u95e8\u8bb0\u5f55\u5e76\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
this.redisTemplate.delete((Object)key);
|
||||
this.updateOpenDoorRecord(context.getCompany().getCompanyId(), AcsOpenDoorStatusEnum.FAIL.getCode(), param.getDeviceResult(), openDoorLogId);
|
||||
}
|
||||
this.saveRecogRecord(param, regLogId, AcsRecognitionStatusEnum.SUCESS.getCode(), context);
|
||||
}
|
||||
return CloudwalkResult.success((Object)regLogIdCache);
|
||||
}
|
||||
|
||||
private void notifyOpenDoor(AcsFaceCaptureParam param, String businessId, String openDoorLogId) throws ServiceException {
|
||||
EntranceGuardControlParam notifyEntranceGuardControlParam = new EntranceGuardControlParam();
|
||||
notifyEntranceGuardControlParam.setDeviceId(param.getAcsSubDeviceCode());
|
||||
notifyEntranceGuardControlParam.setLogId(openDoorLogId);
|
||||
notifyEntranceGuardControlParam.setGuardSwitch(AcsSwitchEnum.ON.getCode());
|
||||
this.logger.info("\u540e\u7aef\u6bd4\u5bf9\u5f00\u59cb\u4e0b\u53d1\u5f00\u5173\u95e8\u6307\u4ee4\u5f00\u59cb:{}", (Object)JSONObject.toJSONString((Object)notifyEntranceGuardControlParam));
|
||||
CloudwalkResult notifyResult = this.deviceNotifyService.entranceGuardControl(notifyEntranceGuardControlParam);
|
||||
this.logger.info("\u540e\u7aef\u6bd4\u5bf9\u5f00\u59cb\u4e0b\u53d1\u5f00\u5173\u95e8\u6307\u4ee4\u7ed3\u675f:{}", (Object)JSONObject.toJSONString((Object)notifyResult));
|
||||
if (!notifyResult.isSuccess()) {
|
||||
this.logger.error("\u540e\u7aef\u6bd4\u5bf9\u4e0b\u53d1\u5f00\u95e8\u6307\u4ee4\u5931\u8d25\uff0c\u8bbe\u5907\u7f16\u7801=[{}], \u539f\u56e0=[{}]", (Object)param.getAcsSubDeviceCode(), (Object)notifyResult.getMessage());
|
||||
this.updateOpenDoorRecord(businessId, AcsOpenDoorStatusEnum.FAIL.getCode(), param.getDeviceResult(), openDoorLogId);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOpenDoorRecord(String businessId, Integer recordResult, DeviceResult deviceResult, String openDoorLogId) throws ServiceException {
|
||||
AcsOpenDoorRecordEditDTO editDTO = new AcsOpenDoorRecordEditDTO();
|
||||
editDTO.setBusinessId(businessId);
|
||||
editDTO.setLogId(openDoorLogId);
|
||||
editDTO.setDeviceId(deviceResult.getId());
|
||||
editDTO.setRecordResult(recordResult);
|
||||
editDTO.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
editDTO.setStartDay(Long.valueOf(DateUtils.getCurrentTime() - this.accessControlProperties.getFaceCaptureOpenDoorFailMilliseconds() - AcsConstants.ONE_DAY_MILLISECONDS));
|
||||
editDTO.setEndDay(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
try {
|
||||
Integer updateCount = this.acsOpenDoorRecordManager.update(editDTO);
|
||||
this.logger.info("\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u66f4\u65b0\u6761\u6570:[{}]", (Object)updateCount);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
throw new ServiceException("76260007", this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
|
||||
public static class FaceParam
|
||||
implements Serializable {
|
||||
private static final long serialVersionUID = -1498245468315683958L;
|
||||
private String faceImagePath;
|
||||
private Long recognitionTime;
|
||||
private BigDecimal maskScore;
|
||||
private BigDecimal qualityScore;
|
||||
private BigDecimal tempScore;
|
||||
|
||||
public String getFaceImagePath() {
|
||||
return this.faceImagePath;
|
||||
}
|
||||
|
||||
public void setFaceImagePath(String faceImagePath) {
|
||||
this.faceImagePath = faceImagePath;
|
||||
}
|
||||
|
||||
public Long getRecognitionTime() {
|
||||
return this.recognitionTime;
|
||||
}
|
||||
|
||||
public void setRecognitionTime(Long recognitionTime) {
|
||||
this.recognitionTime = recognitionTime;
|
||||
}
|
||||
|
||||
public BigDecimal getMaskScore() {
|
||||
return this.maskScore;
|
||||
}
|
||||
|
||||
public void setMaskScore(BigDecimal maskScore) {
|
||||
this.maskScore = maskScore;
|
||||
}
|
||||
|
||||
public BigDecimal getQualityScore() {
|
||||
return this.qualityScore;
|
||||
}
|
||||
|
||||
public void setQualityScore(BigDecimal qualityScore) {
|
||||
this.qualityScore = qualityScore;
|
||||
}
|
||||
|
||||
public BigDecimal getTempScore() {
|
||||
return this.tempScore;
|
||||
}
|
||||
|
||||
public void setTempScore(BigDecimal tempScore) {
|
||||
this.tempScore = tempScore;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordEditDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* cn.cloudwalk.cwos.client.event.event.BaseEvent
|
||||
* cn.cloudwalk.event.CloudwalkEventManager
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.BeanUtils
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOperateRecordManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordEditDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOperateRecordQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOperateTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.cwos.client.event.event.BaseEvent;
|
||||
import cn.cloudwalk.event.CloudwalkEventManager;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.event.CustomOpenDoorRecordEvent;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsOpenDoorRecordServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsOpenDoorRecordService {
|
||||
@Resource
|
||||
private AcsOpenDoorRecordManager acsOpenDoorRecordManager;
|
||||
@Resource
|
||||
private AcsOperateRecordManager acsOperateRecordManager;
|
||||
@Resource
|
||||
private CloudwalkEventManager cloudwalkEventManager;
|
||||
@Resource
|
||||
private AccessControlProperties accessControlProperties;
|
||||
private static final int delayTime = 10000;
|
||||
|
||||
public CloudwalkResult<Boolean> add(AcsOpenDoorRecordAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsOpenDoorRecordAddDTO addDTO = new AcsOpenDoorRecordAddDTO();
|
||||
String deviceId = "";
|
||||
String deviceAddress = "";
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)addDTO);
|
||||
if (param.getDeviceResult() != null) {
|
||||
DeviceResult deviceResult = param.getDeviceResult();
|
||||
BeanCopyUtils.copyProperties((Object)deviceResult, (Object)addDTO);
|
||||
addDTO.setDeviceId(deviceResult.getId());
|
||||
deviceId = deviceResult.getId();
|
||||
deviceAddress = this.getAddress(deviceResult);
|
||||
}
|
||||
addDTO.setId(this.genUUID());
|
||||
addDTO.setCreateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setCreateUserId(context.getUser().getCaller());
|
||||
addDTO.setLastUpdateUserId(context.getUser().getCaller());
|
||||
OpenDoorTypeEnum openDoorType = OpenDoorTypeEnum.getOpenDoorTypeEnumByCode((String)param.getOpenDoorType());
|
||||
if (StringUtils.isNotBlank((String)deviceId) && openDoorType != null && OpenDoorTypeEnum.APP.getCode().equals(openDoorType.getCode())) {
|
||||
String operateName = this.getOperateName(param, deviceId);
|
||||
if (StringUtils.isNotBlank((String)operateName)) {
|
||||
addDTO.setOperateName(operateName);
|
||||
} else {
|
||||
this.logger.info("\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\u7528\u6237\u540d\u4e3a\u7a7a,recognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
}
|
||||
}
|
||||
this.acsOpenDoorRecordManager.add(addDTO);
|
||||
try {
|
||||
this.publish(context, addDTO, deviceAddress);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u4fdd\u5b58\u5f00\u95e8\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Integer> modify(AcsOpenDoorRecordEditParam param) throws ServiceException {
|
||||
try {
|
||||
this.logger.info("\u66f4\u65b0\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u5f00\u59cb:AcsOpenDoorRecordEditParam=[{}]", (Object)JSONObject.toJSONString((Object)param));
|
||||
Integer updateCount = 0;
|
||||
AcsOpenDoorRecordQueryDTO queryDTO = new AcsOpenDoorRecordQueryDTO();
|
||||
BeanUtils.copyProperties((Object)param, (Object)queryDTO);
|
||||
List queryResult = this.acsOpenDoorRecordManager.query(queryDTO);
|
||||
if (CollectionUtils.isNotEmpty((Collection)queryResult)) {
|
||||
AcsOpenDoorRecordQueryResultDTO openDoorRecord = (AcsOpenDoorRecordQueryResultDTO)queryResult.get(0);
|
||||
if (AcsOpenDoorStatusEnum.INIT.getCode().equals(openDoorRecord.getRecordResult())) {
|
||||
AcsOpenDoorRecordEditDTO editDTO = new AcsOpenDoorRecordEditDTO();
|
||||
BeanUtils.copyProperties((Object)param, (Object)editDTO);
|
||||
editDTO.setId(openDoorRecord.getId());
|
||||
editDTO.setLastUpdateTime(Long.valueOf(DateUtils.getCurrentTime()));
|
||||
updateCount = this.acsOpenDoorRecordManager.update(editDTO);
|
||||
this.logger.info("\u66f4\u65b0\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u7ed3\u675f,\u66f4\u65b0\u6761\u6570:[{}]", (Object)updateCount);
|
||||
}
|
||||
}
|
||||
return CloudwalkResult.success((Object)updateCount);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
throw new ServiceException("76260007", this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
|
||||
public Integer updateRecogOpenDoorType(String openDoorTable, String recogTable, Long startTime) throws ServiceException {
|
||||
try {
|
||||
return this.acsOpenDoorRecordManager.updateRecogOpenDoorType(openDoorTable, recogTable, startTime, null);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
throw new ServiceException("76260007", "\u66f4\u65b0\u8bc6\u522b\u8bb0\u5f55\u5f00\u95e8\u7c7b\u578b\u5b57\u6bb5\u5931\u8d25");
|
||||
}
|
||||
}
|
||||
|
||||
private void publish(CloudwalkCallContext context, AcsOpenDoorRecordAddDTO addDTO, String deviceAddress) {
|
||||
if (this.accessControlProperties.getPublishOpendoorSwitch().booleanValue() && StringUtils.isNotBlank((String)this.accessControlProperties.getPublishOpendoorServiceCode())) {
|
||||
CustomOpenDoorRecordEvent openDoorRecordEvent = new CustomOpenDoorRecordEvent();
|
||||
BeanCopyUtils.copyProperties((Object)addDTO, (Object)((Object)openDoorRecordEvent));
|
||||
openDoorRecordEvent.setPanoramaImage(this.genFullPath(addDTO.getPanoramaImagePath()));
|
||||
openDoorRecordEvent.setFaceImage(this.genFullPath(addDTO.getFaceImagePath()));
|
||||
if (StringUtils.isNotBlank((String)addDTO.getOpenDoorType())) {
|
||||
openDoorRecordEvent.setOpenDoorTypeCode(addDTO.getOpenDoorType());
|
||||
openDoorRecordEvent.setOpenDoorTypeMsg(OpenDoorTypeEnum.getEnumByCode((String)addDTO.getOpenDoorType()));
|
||||
}
|
||||
openDoorRecordEvent.setDeviceAddress(deviceAddress);
|
||||
openDoorRecordEvent.setMessageId(String.valueOf(System.currentTimeMillis()));
|
||||
openDoorRecordEvent.setServiceCode(this.accessControlProperties.getPublishOpendoorServiceCode());
|
||||
openDoorRecordEvent.setBusinessId(context.getCompany().getCompanyId());
|
||||
this.logger.info("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u5f00\u59cb\uff0cCustomOpenDooerRecordEvent=[{}]", (Object)JSONObject.toJSONString((Object)((Object)openDoorRecordEvent)));
|
||||
this.cloudwalkEventManager.publish((BaseEvent)openDoorRecordEvent);
|
||||
this.logger.info("\u5f00\u95e8\u8bb0\u5f55\u6d88\u606f\u53d1\u9001\u7ed3\u675f");
|
||||
}
|
||||
}
|
||||
|
||||
private String getOperateName(AcsOpenDoorRecordAddParam param, String deviceId) throws DataAccessException {
|
||||
AcsOperateRecordQueryDTO operateRecordQueryDTO = new AcsOperateRecordQueryDTO();
|
||||
operateRecordQueryDTO.setBusinessId(param.getBusinessId());
|
||||
operateRecordQueryDTO.setDeviceId(deviceId);
|
||||
ArrayList<String> operateTypeCodes = new ArrayList<String>();
|
||||
operateTypeCodes.add(AcsOperateTypeEnum.REMOTE_OPEN_DOOR.getCode());
|
||||
operateTypeCodes.add(AcsOperateTypeEnum.QRCODE_OPEN_DOOR.getCode());
|
||||
operateRecordQueryDTO.setOperateTypeCodes(operateTypeCodes);
|
||||
operateRecordQueryDTO.setStatus(AcsOperateStatusEnum.INIT.getCode());
|
||||
operateRecordQueryDTO.setDelayTime(Long.valueOf(DateUtils.getCurrentTime() - 10000L));
|
||||
List operateRecordList = this.acsOperateRecordManager.queryOrderByOperateTime(operateRecordQueryDTO);
|
||||
if (!CollectionUtils.isEmpty((Collection)operateRecordList)) {
|
||||
AcsOperateRecordQueryResultDTO acsOperateRecordQueryResultDTO = (AcsOperateRecordQueryResultDTO)operateRecordList.get(0);
|
||||
AcsOperateRecordEditDTO operateRecordEditDTO = new AcsOperateRecordEditDTO();
|
||||
operateRecordEditDTO.setId(acsOperateRecordQueryResultDTO.getId());
|
||||
operateRecordEditDTO.setStatus(AcsOperateStatusEnum.MATCHED.getCode());
|
||||
int updateCount = this.acsOperateRecordManager.update(operateRecordEditDTO);
|
||||
if (updateCount < 1) {
|
||||
this.logger.info("\u6ca1\u627e\u5230\u5339\u914d\u7684\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\uff0c\u4e0d\u4fdd\u5b58\u8be5\u6761\u5f00\u95e8\u6570\u636e\uff0crecognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
}
|
||||
return acsOperateRecordQueryResultDTO.getOperateName();
|
||||
}
|
||||
this.logger.info("\u6ca1\u627e\u5230\u5339\u914d\u7684\u8fdc\u7a0b\u5f00\u95e8\u64cd\u4f5c\u8bb0\u5f55\uff0c\u4e0d\u4fdd\u5b58\u8be5\u6761\u5f00\u95e8\u6570\u636e\uff0crecognitionFaceId=[{}]", (Object)param.getRecognitionFaceId());
|
||||
return null;
|
||||
}
|
||||
|
||||
private String genFullPath(String path) {
|
||||
return StringUtils.isNotBlank((String)path) ? this.accessControlProperties.getCwosPicUrl() + path : null;
|
||||
}
|
||||
}
|
||||
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecogRecordManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonDetailParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsPersonCardCompareAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordAddParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecogRecordService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceTemperatureSettingParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceSettingService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.entity.CloudwalkBaseTimes
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsPersonReserveInfoDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.CompareTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSON
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.transaction.annotation.Transactional
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecogRecordManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonDetailParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsPersonCardCompareAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordAddParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecogRecordService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceTemperatureSettingParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceSettingService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.entity.CloudwalkBaseTimes;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsPersonReserveInfoDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.CompareTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsRecogRecordServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsRecogRecordService {
|
||||
@Resource
|
||||
private AcsRecogRecordManager acsRecogRecordManager;
|
||||
@Resource
|
||||
private PersonService personService;
|
||||
@Resource
|
||||
private AcsDeviceSettingService acsDeviceSettingService;
|
||||
|
||||
@Transactional(rollbackFor={Exception.class})
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> add(AcsRecogRecordAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
JSONObject reserveInfo;
|
||||
AcsRecogRecordAddDTO addDTO = new AcsRecogRecordAddDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)addDTO);
|
||||
if (param.getDeviceResult() != null) {
|
||||
DeviceResult deviceResult = param.getDeviceResult();
|
||||
BeanCopyUtils.copyProperties((Object)deviceResult, (Object)addDTO);
|
||||
addDTO.setDeviceId(deviceResult.getId());
|
||||
}
|
||||
if (param.getSubDeviceResult() != null) {
|
||||
DeviceResult subDeviceResult = param.getSubDeviceResult();
|
||||
addDTO.setSubDeviceId(subDeviceResult.getId());
|
||||
addDTO.setSubDeviceCode(subDeviceResult.getDeviceCode());
|
||||
addDTO.setSubDeviceName(subDeviceResult.getDeviceName());
|
||||
addDTO.setSubDeviceTypeId(subDeviceResult.getDeviceTypeId());
|
||||
addDTO.setSubDeviceTypeName(subDeviceResult.getDeviceTypeName());
|
||||
}
|
||||
PersonQueryParam personQueryParam = new PersonQueryParam();
|
||||
personQueryParam.setImageIds(Collections.singletonList(param.getFaceId()));
|
||||
CloudwalkResult personListResult = this.personService.list(personQueryParam, context);
|
||||
if (personListResult.isSuccess() && CollectionUtils.isNotEmpty((Collection)((Collection)personListResult.getData()))) {
|
||||
PersonResult personResult = (PersonResult)((List)personListResult.getData()).get(0);
|
||||
addDTO.setPersonId(personResult.getId());
|
||||
addDTO.setPersonName(personResult.getName());
|
||||
addDTO.setRegisterImagePath(personResult.getComparePicture());
|
||||
} else if (StringUtils.isNotBlank((String)param.getReserveInfo()) && !(reserveInfo = JSON.parseObject((String)param.getReserveInfo())).isEmpty() && reserveInfo.containsKey((Object)"personId")) {
|
||||
AcsPersonReserveInfoDTO personInfo = (AcsPersonReserveInfoDTO)reserveInfo.toJavaObject(AcsPersonReserveInfoDTO.class);
|
||||
PersonDetailParam personDetailParam = new PersonDetailParam();
|
||||
personDetailParam.setId(personInfo.getPersonId());
|
||||
personDetailParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult detail = this.personService.detail(personDetailParam, context);
|
||||
if (detail.isSuccess() && !ObjectUtils.isEmpty((Object)detail.getData())) {
|
||||
PersonResult data = (PersonResult)detail.getData();
|
||||
addDTO.setPersonId(data.getId());
|
||||
addDTO.setPersonName(data.getName());
|
||||
addDTO.setRegisterImagePath(data.getComparePicture());
|
||||
}
|
||||
}
|
||||
BigDecimal tempTempThreshold = this.getTempThreshold(addDTO.getDeviceId(), context);
|
||||
addDTO.setTempThreshold(tempTempThreshold);
|
||||
addDTO.setId(this.genUUID());
|
||||
addDTO.setCreateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setLastUpdateTime(Long.valueOf(System.currentTimeMillis()));
|
||||
addDTO.setCreateUserId(context.getUser().getCaller());
|
||||
addDTO.setLastUpdateUserId(context.getUser().getCaller());
|
||||
addDTO.setSource(param.getCompareType() == null ? CompareTypeEnum.RECOG.getCode() : param.getCompareType());
|
||||
this.acsRecogRecordManager.add(addDTO);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u4fdd\u5b58\u8bc6\u522b\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor={Exception.class})
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<Boolean> addCompareRecord(AcsPersonCardCompareAddParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
AcsRecogRecordAddDTO addDTO = new AcsRecogRecordAddDTO();
|
||||
BeanCopyUtils.copyProperties((Object)param, (Object)addDTO);
|
||||
if (param.getDeviceResult() != null) {
|
||||
DeviceResult deviceResult = param.getDeviceResult();
|
||||
BeanCopyUtils.copyProperties((Object)deviceResult, (Object)addDTO);
|
||||
addDTO.setDeviceId(deviceResult.getId());
|
||||
}
|
||||
addDTO.setPersonId("");
|
||||
addDTO.setGroupId("");
|
||||
addDTO.setFaceId("");
|
||||
addDTO.setQualityScore(BigDecimal.valueOf(0L));
|
||||
addDTO.setSource(param.getCompareType());
|
||||
BigDecimal tempTempThreshold = this.getTempThreshold(addDTO.getDeviceId(), context);
|
||||
addDTO.setTempThreshold(tempTempThreshold);
|
||||
addDTO.setId(this.genUUID());
|
||||
BeanCopyUtils.copyProperties((CloudwalkBaseTimes)addDTO, (CloudwalkCallContext)context);
|
||||
this.acsRecogRecordManager.add(addDTO);
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u4fdd\u5b58\u8bc6\u522b\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private BigDecimal getTempThreshold(String deviceId, CloudwalkCallContext context) throws ServiceException {
|
||||
List temperatureSetting;
|
||||
AcsDeviceTemperatureSettingParam settingParam = new AcsDeviceTemperatureSettingParam();
|
||||
settingParam.setDeviceId(deviceId);
|
||||
CloudwalkResult settingCloudwalkResult = this.acsDeviceSettingService.getTemperatureSetting(settingParam, context);
|
||||
if (settingCloudwalkResult.isSuccess() && settingCloudwalkResult.getData() != null && CollectionUtils.isNotEmpty((Collection)(temperatureSetting = ((AcsDeviceSettingResult)settingCloudwalkResult.getData()).getAttrs()))) {
|
||||
List settingsList = temperatureSetting.stream().filter(s -> AcsDeviceSettingEnum.TEMP_THRESHOLD.getCode().equals(s.getCode())).collect(Collectors.toList());
|
||||
String temp = null;
|
||||
if (CollectionUtils.isNotEmpty(settingsList) && (temp = ((AcsSettingAttr)settingsList.get(0)).getValue()) != null) {
|
||||
return new BigDecimal(temp);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+631
@@ -0,0 +1,631 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.ClockDeviceManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsElevatorRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecogRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordManager
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordStatisticsManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceAreaQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceDistrictQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceAreaResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceDistrictResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceAreaService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceDistrictService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsElevatorRecordDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordThreeSendParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsTemperatureRecordDetailParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsElevatorRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordThreeSendResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageAble
|
||||
* cn.cloudwalk.cloud.page.CloudwalkPageInfo
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.session.company.CompanyContext
|
||||
* cn.cloudwalk.cloud.session.user.UserContext
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.cloud.utils.CloudwalkDateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.ClockDeviceResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordDetailQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordDetailQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordStatisticsResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordPageDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordStatisticsResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordDetailQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordDetailQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsAddDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordThreeSendQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsTemperatureRecordDetailQueryDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsTemperatureRecordDetailQueryResultDTO
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* cn.cloudwalk.intelligent.lock.annotation.RequiredLock
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.beans.factory.annotation.Value
|
||||
* org.springframework.data.redis.core.RedisTemplate
|
||||
* org.springframework.stereotype.Service
|
||||
* org.springframework.util.ObjectUtils
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.ClockDeviceManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsElevatorRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsOpenDoorRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecogRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordManager;
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.record.AcsRecordStatisticsManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceAreaQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceDistrictQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceAreaResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceDistrictResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceAreaService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceDistrictService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.param.PersonQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.result.PersonResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.person.service.PersonService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.param.DeviceAreaTreeParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.sysetting.result.AreaTreeResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsElevatorRecordDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecogRecordPageParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordThreeSendParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsTemperatureRecordDetailParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsElevatorRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecogRecordResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordThreeSendResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsTemperatureRecordDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.DoorOpenRecordService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
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.session.company.CompanyContext;
|
||||
import cn.cloudwalk.cloud.session.user.UserContext;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.cloud.utils.CloudwalkDateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.ClockDeviceResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordDetailQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsElevatorRecordDetailQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsOpenDoorRecordStatisticsResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordPageDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecogRecordStatisticsResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordDetailQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordDetailQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordStatisticsAddDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsRecordThreeSendQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsTemperatureRecordDetailQueryDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.record.AcsTemperatureRecordDetailQueryResultDTO;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.FeignThreadLocalUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.OpenDoorTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.intelligent.lock.annotation.RequiredLock;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.cacheable.AcsAreaTreeCacheableService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
@Service
|
||||
public class AcsRecordServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements DoorOpenRecordService {
|
||||
@Value(value="${push.method}")
|
||||
private Integer pushMethod;
|
||||
@Resource
|
||||
private AcsRecordManager acsRecordManager;
|
||||
@Resource
|
||||
private ClockDeviceManager clockDeviceManager;
|
||||
@Resource
|
||||
private PersonService personService;
|
||||
@Resource
|
||||
private AcsElevatorRecordManager acsElevatorRecordManager;
|
||||
@Resource
|
||||
private DeviceDistrictService deviceDistrictService;
|
||||
@Resource
|
||||
private DeviceAreaService deviceAreaService;
|
||||
@Resource
|
||||
private AcsRecogRecordManager acsRecogRecordManager;
|
||||
@Resource
|
||||
private AcsRecordStatisticsManager acsRecordStatisticsManager;
|
||||
@Resource
|
||||
private AcsOpenDoorRecordManager acsOpenDoorRecordManager;
|
||||
@Resource
|
||||
protected RedisTemplate<String, Object> redisTemplate;
|
||||
@Resource
|
||||
private AcsAreaTreeCacheableService acsAreaTreeCacheableService;
|
||||
private static final Long ONE_YEAR_MILLISECONDS = 31536000000L;
|
||||
private static final String AREA_FLAG = "area";
|
||||
private static final String DISTRICT_FLAG = "district";
|
||||
protected static final int CACHE_EXPIRE_TIME = 8;
|
||||
@Value(value="${xinhewan.businessid}")
|
||||
private String businessId;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsRecordDetailResult>> openRecord(AcsRecordDetailParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext cloudwalkContext) throws ServiceException {
|
||||
if (param.getEndTime() - param.getStartTime() > ONE_YEAR_MILLISECONDS) {
|
||||
return CloudwalkResult.fail((String)"76260304", (String)this.getMessage("76260304"));
|
||||
}
|
||||
AcsRecordDetailQueryDTO queryDTO = (AcsRecordDetailQueryDTO)BeanCopyUtils.copyProperties((Object)param, AcsRecordDetailQueryDTO.class);
|
||||
queryDTO.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
||||
try {
|
||||
CloudwalkPageAble pageResult = this.acsRecordManager.detail(queryDTO, pageInfo);
|
||||
if (CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(new ArrayList(), pageInfo, 0L));
|
||||
}
|
||||
List list = (List)pageResult.getDatas();
|
||||
ArrayList<AcsRecordDetailResult> acsList = new ArrayList<AcsRecordDetailResult>(list.size());
|
||||
DeviceDistrictQueryParam deviceDistrictQueryParam = new DeviceDistrictQueryParam();
|
||||
HashMap<String, String> districtMap = new HashMap<String, String>();
|
||||
deviceDistrictQueryParam.setIds(this.acsRecordListDupRemove(list, DISTRICT_FLAG));
|
||||
CloudwalkResult deviceDistrictResult = this.deviceDistrictService.list(deviceDistrictQueryParam);
|
||||
for (DeviceDistrictResult result : (List)deviceDistrictResult.getData()) {
|
||||
districtMap.put(result.getDistrictCode(), result.getMergeName());
|
||||
}
|
||||
DeviceAreaTreeParam areaTreeParam = new DeviceAreaTreeParam();
|
||||
areaTreeParam.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
||||
CloudwalkResult<List<AreaTreeResult>> areaTree = this.acsAreaTreeCacheableService.tree(areaTreeParam, cloudwalkContext);
|
||||
HashMap<String, String> areaMap = new HashMap<String, String>();
|
||||
this.getAreaMap((List)areaTree.getData(), areaMap);
|
||||
DeviceAreaQueryParam deviceAreaParentQueryParam = new DeviceAreaQueryParam();
|
||||
HashMap<String, String> areaParentMap = new HashMap<String, String>();
|
||||
deviceAreaParentQueryParam.setParentIds(this.acsRecordListDupRemove(list, AREA_FLAG));
|
||||
CloudwalkResult deviceAreaParentResult = this.deviceAreaService.list(deviceAreaParentQueryParam);
|
||||
for (DeviceAreaResult result : (List)deviceAreaParentResult.getData()) {
|
||||
areaParentMap.put(result.getParentId(), result.getName());
|
||||
}
|
||||
for (AcsRecordDetailQueryResultDTO resultDTO : list) {
|
||||
AcsRecordDetailResult recordResult = (AcsRecordDetailResult)BeanCopyUtils.copyProperties((Object)resultDTO, AcsRecordDetailResult.class);
|
||||
if (!StringUtils.isEmpty((String)resultDTO.getPanoramaImageOpen())) {
|
||||
recordResult.setPanoramaImage(resultDTO.getPanoramaImageOpen());
|
||||
} else if (!StringUtils.isEmpty((String)resultDTO.getPanoramaImageRecog())) {
|
||||
recordResult.setPanoramaImage(resultDTO.getPanoramaImageRecog());
|
||||
}
|
||||
if (StringUtils.isNotBlank((String)resultDTO.getOpenDoorType())) {
|
||||
recordResult.setOpenDoorType(OpenDoorTypeEnum.getEnumByCode((String)resultDTO.getOpenDoorType()));
|
||||
recordResult.setOpenDoorTypeCode(resultDTO.getOpenDoorType().toUpperCase());
|
||||
}
|
||||
recordResult.setDistrictName((String)districtMap.get(resultDTO.getDistrictId()));
|
||||
if (areaParentMap.containsKey(resultDTO.getAreaId())) {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()) + "-" + (String)areaParentMap.get(resultDTO.getAreaId()));
|
||||
} else {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()));
|
||||
}
|
||||
acsList.add(recordResult);
|
||||
}
|
||||
ArrayList personIds = new ArrayList();
|
||||
acsList.forEach(acs -> personIds.add(acs.getPersonId()));
|
||||
PersonQueryParam queryParam = new PersonQueryParam();
|
||||
queryParam.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
||||
queryParam.setIds(personIds);
|
||||
CloudwalkResult personList = this.personService.list(queryParam, cloudwalkContext);
|
||||
HashMap<String, PersonResult> map = new HashMap<String, PersonResult>();
|
||||
for (PersonResult personResult : (List)personList.getData()) {
|
||||
map.put(personResult.getId(), personResult);
|
||||
}
|
||||
for (AcsRecordDetailResult acsRecordDetailResult : acsList) {
|
||||
PersonResult person = (PersonResult)map.get(acsRecordDetailResult.getPersonId());
|
||||
if (ObjectUtils.isEmpty((Object)person)) continue;
|
||||
if (!CollectionUtils.isEmpty((Collection)person.getOrganizationIds())) {
|
||||
acsRecordDetailResult.setOrganizationIds(person.getOrganizationIds());
|
||||
String orgId = person.getOrganizationIds().stream().collect(Collectors.joining(","));
|
||||
acsRecordDetailResult.setOrgId(orgId);
|
||||
}
|
||||
if (CollectionUtils.isEmpty((Collection)person.getOrganizationNames())) continue;
|
||||
acsRecordDetailResult.setOrganizationNames(person.getOrganizationNames());
|
||||
String orgName = person.getOrganizationNames().stream().collect(Collectors.joining(","));
|
||||
acsRecordDetailResult.setOrgName(orgName);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(acsList, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5f00\u95e8\u8bb0\u5f55\u8be6\u60c5\u67e5\u8be2\u5931\u8d25,\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<List<AcsRecordThreeSendResult>> listByTime(AcsRecordThreeSendParam param) throws ServiceException {
|
||||
AcsRecordThreeSendQueryDTO queryDTO = (AcsRecordThreeSendQueryDTO)BeanCopyUtils.copyProperties((Object)param, AcsRecordThreeSendQueryDTO.class);
|
||||
try {
|
||||
ArrayList<String> deviceIds = new ArrayList<String>();
|
||||
List clockList = this.clockDeviceManager.listAll();
|
||||
HashMap<String, String> clockMap = new HashMap<String, String>();
|
||||
for (ClockDeviceResultDTO resultDTO : clockList) {
|
||||
deviceIds.add(resultDTO.getDeviceId());
|
||||
clockMap.put(resultDTO.getDeviceId(), resultDTO.getAreaId());
|
||||
}
|
||||
queryDTO.setDeviceIds(deviceIds);
|
||||
if (ObjectUtils.isEmpty((Object)queryDTO.getEndTime())) {
|
||||
queryDTO.setEndTime(Long.valueOf(AcsRecordServiceImpl.add24HoursWithinYear(queryDTO.getStartTime())));
|
||||
}
|
||||
this.logger.info("listByTime businessId {} queryDTO {}", (Object)this.businessId, (Object)JSONObject.toJSONString((Object)queryDTO));
|
||||
queryDTO.setBusinessId(this.businessId);
|
||||
List pageResult = this.acsRecordManager.listByTime(queryDTO);
|
||||
if (CollectionUtils.isEmpty((Collection)pageResult)) {
|
||||
return CloudwalkResult.success(new ArrayList());
|
||||
}
|
||||
ArrayList<AcsRecordThreeSendResult> results = new ArrayList<AcsRecordThreeSendResult>();
|
||||
PersonQueryParam personQueryParam = new PersonQueryParam();
|
||||
ArrayList<String> personIds = new ArrayList<String>();
|
||||
for (AcsRecordDetailQueryResultDTO dto : pageResult) {
|
||||
if (!ObjectUtils.isEmpty((Object)dto.getPersonId())) {
|
||||
personIds.add(dto.getPersonId());
|
||||
}
|
||||
if (ObjectUtils.isEmpty((Object)dto.getBusinessId())) continue;
|
||||
personQueryParam.setBusinessId(dto.getBusinessId());
|
||||
}
|
||||
personQueryParam.setIds(personIds);
|
||||
CloudwalkCallContext context = new CloudwalkCallContext();
|
||||
CompanyContext companyContext = new CompanyContext();
|
||||
companyContext.setCompanyId(personQueryParam.getBusinessId());
|
||||
context.setCompany(companyContext);
|
||||
CloudwalkResult personList = this.personService.list(personQueryParam, context);
|
||||
HashMap personMap = new HashMap();
|
||||
((List)personList.getData()).forEach(result -> personMap.put(result.getId(), result));
|
||||
for (AcsRecordDetailQueryResultDTO dto : pageResult) {
|
||||
AcsRecordThreeSendResult result2 = (AcsRecordThreeSendResult)BeanCopyUtils.copyProperties((Object)dto, AcsRecordThreeSendResult.class);
|
||||
PersonResult personResult = (PersonResult)personMap.get(result2.getPersonId());
|
||||
if (!ObjectUtils.isEmpty((Object)personResult) && !ObjectUtils.isEmpty((Object)personResult.getPersonCode()) && !ObjectUtils.isEmpty((Object)personResult.getDefaultFloor()) && personResult.getDefaultFloor().equals(clockMap.get(dto.getDeviceId()))) {
|
||||
result2.setPersonCode(personResult.getPersonCode());
|
||||
}
|
||||
results.add(result2);
|
||||
}
|
||||
return CloudwalkResult.success(results);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u6839\u636e\u65f6\u95f4\u67e5\u8be2\u6210\u529f\u7684\u5f00\u95e8\u8bb0\u5f55\u5931\u8d25,\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkCallContext getCloudwalkContext(String businessId) throws ServiceException {
|
||||
CloudwalkCallContext context = new CloudwalkCallContext();
|
||||
CompanyContext companyContext = new CompanyContext();
|
||||
companyContext.setCompanyId(businessId);
|
||||
context.setCompany(companyContext);
|
||||
UserContext userContext = new UserContext();
|
||||
userContext.setCaller("defaultUserId");
|
||||
userContext.setCallerName("defaultUserName");
|
||||
context.setUser(userContext);
|
||||
context.setCallTime(CloudwalkDateUtils.getCurrentDate());
|
||||
HashMap<String, String> feignThreadLoaclMap = new HashMap<String, String>(3);
|
||||
feignThreadLoaclMap.put("businessid", businessId);
|
||||
feignThreadLoaclMap.put("platformuserid", "defaultUserId");
|
||||
feignThreadLoaclMap.put("username", "defaultUserName");
|
||||
FeignThreadLocalUtil.set(feignThreadLoaclMap);
|
||||
return context;
|
||||
}
|
||||
|
||||
protected void getAreaMap(List<AreaTreeResult> areaTreeResultList, Map<String, String> areaMap) {
|
||||
for (AreaTreeResult areaTree : areaTreeResultList) {
|
||||
areaMap.put(areaTree.getId(), areaTree.getName());
|
||||
if (areaTree.getChildren() == null) continue;
|
||||
this.getAreaMap(areaTree.getChildren(), areaMap);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsElevatorRecordResult>> elevatorRecord(AcsElevatorRecordDetailParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext context) throws ServiceException {
|
||||
if (param.getEndTime() - param.getStartTime() > ONE_YEAR_MILLISECONDS) {
|
||||
return CloudwalkResult.fail((String)"76260304", (String)this.getMessage("76260304"));
|
||||
}
|
||||
AcsElevatorRecordDetailQueryDTO queryDTO = (AcsElevatorRecordDetailQueryDTO)BeanCopyUtils.copyProperties((Object)param, AcsElevatorRecordDetailQueryDTO.class);
|
||||
queryDTO.setBusinessId(context.getCompany().getCompanyId());
|
||||
try {
|
||||
CloudwalkPageAble pageResult = this.acsElevatorRecordManager.detail(queryDTO, pageInfo);
|
||||
if (CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(new ArrayList(), pageInfo, 0L));
|
||||
}
|
||||
List list = (List)pageResult.getDatas();
|
||||
ArrayList<AcsElevatorRecordResult> acsList = new ArrayList<AcsElevatorRecordResult>(list.size());
|
||||
DeviceDistrictQueryParam deviceDistrictQueryParam = new DeviceDistrictQueryParam();
|
||||
deviceDistrictQueryParam.setIds(this.acsElevatorRecordListDupRemove(list, DISTRICT_FLAG));
|
||||
CloudwalkResult deviceDistrictResult = this.deviceDistrictService.list(deviceDistrictQueryParam);
|
||||
HashMap<String, String> districtMap = new HashMap<String, String>(((List)deviceDistrictResult.getData()).size());
|
||||
for (DeviceDistrictResult result : (List)deviceDistrictResult.getData()) {
|
||||
districtMap.put(result.getDistrictCode(), result.getMergeName());
|
||||
}
|
||||
DeviceAreaTreeParam areaTreeParam = new DeviceAreaTreeParam();
|
||||
areaTreeParam.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkResult<List<AreaTreeResult>> areaTree = this.acsAreaTreeCacheableService.tree(areaTreeParam, context);
|
||||
HashMap<String, String> areaMap = new HashMap<String, String>(((List)areaTree.getData()).size());
|
||||
this.getAreaMap((List)areaTree.getData(), areaMap);
|
||||
DeviceAreaQueryParam deviceAreaParentQueryParam = new DeviceAreaQueryParam();
|
||||
HashMap<String, String> areaParentMap = new HashMap<String, String>();
|
||||
deviceAreaParentQueryParam.setParentIds(this.acsElevatorRecordListDupRemove(list, AREA_FLAG));
|
||||
CloudwalkResult deviceAreaParentResult = this.deviceAreaService.list(deviceAreaParentQueryParam);
|
||||
for (DeviceAreaResult result : (List)deviceAreaParentResult.getData()) {
|
||||
areaParentMap.put(result.getParentId(), result.getName());
|
||||
}
|
||||
for (AcsElevatorRecordDetailQueryResultDTO resultDTO : list) {
|
||||
AcsElevatorRecordResult recordResult = (AcsElevatorRecordResult)BeanCopyUtils.copyProperties((Object)resultDTO, AcsElevatorRecordResult.class);
|
||||
if (!StringUtils.isEmpty((String)resultDTO.getPanoramaImageOpen())) {
|
||||
recordResult.setPanoramaImage(resultDTO.getPanoramaImageOpen());
|
||||
} else if (!StringUtils.isEmpty((String)resultDTO.getPanoramaImageRecog())) {
|
||||
recordResult.setPanoramaImage(resultDTO.getPanoramaImageRecog());
|
||||
}
|
||||
if (StringUtils.isNotBlank((String)resultDTO.getOpenDoorType())) {
|
||||
recordResult.setOpenDoorType(OpenDoorTypeEnum.getEnumByCode((String)resultDTO.getOpenDoorType()));
|
||||
recordResult.setOpenDoorTypeCode(resultDTO.getOpenDoorType().toUpperCase());
|
||||
}
|
||||
recordResult.setDistrictName((String)districtMap.get(resultDTO.getDistrictId()));
|
||||
if (areaParentMap.containsKey(resultDTO.getAreaId())) {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()) + "-" + (String)areaParentMap.get(resultDTO.getAreaId()));
|
||||
} else {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()));
|
||||
}
|
||||
acsList.add(recordResult);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(acsList, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5f00\u95e8\u8bb0\u5f55\u8be6\u60c5\u67e5\u8be2\u5931\u8d25,\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsTemperatureRecordDetailResult>> temperature(AcsTemperatureRecordDetailParam param, CloudwalkPageInfo pageInfo, CloudwalkCallContext cloudwalkContext) throws ServiceException {
|
||||
if (param.getEndTime() - param.getStartTime() > ONE_YEAR_MILLISECONDS) {
|
||||
return CloudwalkResult.fail((String)"76260304", (String)this.getMessage("76260304"));
|
||||
}
|
||||
AcsTemperatureRecordDetailQueryDTO queryDTO = (AcsTemperatureRecordDetailQueryDTO)BeanCopyUtils.copyProperties((Object)param, AcsTemperatureRecordDetailQueryDTO.class);
|
||||
queryDTO.setBusinessId(cloudwalkContext.getCompany().getCompanyId());
|
||||
try {
|
||||
CloudwalkPageAble pageResult = this.acsRecordManager.temperature(queryDTO, pageInfo);
|
||||
if (CollectionUtils.isEmpty((Collection)pageResult.getDatas())) {
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(new ArrayList(), pageInfo, 0L));
|
||||
}
|
||||
List list = (List)pageResult.getDatas();
|
||||
ArrayList<AcsTemperatureRecordDetailResult> acsList = new ArrayList<AcsTemperatureRecordDetailResult>(list.size());
|
||||
DeviceDistrictQueryParam deviceDistrictQueryParam = new DeviceDistrictQueryParam();
|
||||
HashMap<String, String> districtMap = new HashMap<String, String>();
|
||||
deviceDistrictQueryParam.setIds(this.acsTempRecordListDupRemove(list, DISTRICT_FLAG));
|
||||
CloudwalkResult deviceDistrictResult = this.deviceDistrictService.list(deviceDistrictQueryParam);
|
||||
for (DeviceDistrictResult result : (List)deviceDistrictResult.getData()) {
|
||||
districtMap.put(result.getDistrictCode(), result.getMergeName());
|
||||
}
|
||||
DeviceAreaQueryParam deviceAreaQueryParam = new DeviceAreaQueryParam();
|
||||
HashMap<String, String> areaMap = new HashMap<String, String>();
|
||||
deviceAreaQueryParam.setIds(this.acsTempRecordListDupRemove(list, AREA_FLAG));
|
||||
CloudwalkResult deviceAreaResult = this.deviceAreaService.list(deviceAreaQueryParam);
|
||||
for (DeviceAreaResult result : (List)deviceAreaResult.getData()) {
|
||||
areaMap.put(result.getId(), result.getName());
|
||||
}
|
||||
DeviceAreaQueryParam deviceAreaParentQueryParam = new DeviceAreaQueryParam();
|
||||
HashMap<String, String> areaParentMap = new HashMap<String, String>();
|
||||
deviceAreaParentQueryParam.setParentIds(this.acsTempRecordListDupRemove(list, AREA_FLAG));
|
||||
CloudwalkResult deviceAreaParentResult = this.deviceAreaService.list(deviceAreaParentQueryParam);
|
||||
for (DeviceAreaResult result : (List)deviceAreaParentResult.getData()) {
|
||||
areaParentMap.put(result.getParentId(), result.getName());
|
||||
}
|
||||
for (AcsTemperatureRecordDetailQueryResultDTO resultDTO : list) {
|
||||
AcsTemperatureRecordDetailResult recordResult = (AcsTemperatureRecordDetailResult)BeanCopyUtils.copyProperties((Object)resultDTO, AcsTemperatureRecordDetailResult.class);
|
||||
recordResult.setDistrictName((String)districtMap.get(resultDTO.getDistrictId()));
|
||||
if (areaParentMap.containsKey(resultDTO.getAreaId())) {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()) + "-" + (String)areaParentMap.get(resultDTO.getAreaId()));
|
||||
} else {
|
||||
recordResult.setAreaName((String)areaMap.get(resultDTO.getAreaId()));
|
||||
}
|
||||
acsList.add(recordResult);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(acsList, pageInfo, pageResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5f02\u5e38\u4f53\u6e29\u8bb0\u5f55\u8be6\u60c5\u67e5\u8be2\u5931\u8d25,\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<CloudwalkPageAble<AcsRecogRecordResult>> recogRecordPage(AcsRecogRecordPageParam param, CloudwalkPageInfo page, CloudwalkCallContext context, boolean isExport) throws ServiceException {
|
||||
this.logger.info("\u5206\u9875\u67e5\u8be2\u8bc6\u522b\u8bb0\u5f55\u5165\u53c2\uff1a{}", (Object)JSONObject.toJSONString((Object)param));
|
||||
if (param.getEndTime() - param.getStartTime() > ONE_YEAR_MILLISECONDS) {
|
||||
return CloudwalkResult.fail((String)"76260304", (String)this.getMessage("76260304"));
|
||||
}
|
||||
AcsRecogRecordPageDTO dto = (AcsRecogRecordPageDTO)BeanCopyUtils.copyProperties((Object)param, AcsRecogRecordPageDTO.class);
|
||||
dto.setBusinessId(context.getCompany().getCompanyId());
|
||||
CloudwalkPageAble cloudwalkResult = null;
|
||||
try {
|
||||
cloudwalkResult = this.acsRecogRecordManager.page(dto, page);
|
||||
List recordList = (List)cloudwalkResult.getDatas();
|
||||
ArrayList<AcsRecogRecordResult> result = new ArrayList<AcsRecogRecordResult>(recordList.size());
|
||||
DeviceDistrictQueryParam deviceDistrictQueryParam = new DeviceDistrictQueryParam();
|
||||
List districtIds = recordList.stream().map(AcsRecogRecordResultDTO::getDistrictId).collect(Collectors.toList());
|
||||
deviceDistrictQueryParam.setIds(districtIds);
|
||||
CloudwalkResult deviceDistrictResult = this.deviceDistrictService.list(deviceDistrictQueryParam);
|
||||
Map<String, String> districtMap = ((List)deviceDistrictResult.getData()).stream().collect(Collectors.toMap(DeviceDistrictResult::getDistrictCode, DeviceDistrictResult::getMergeName));
|
||||
DeviceAreaQueryParam deviceAreaQueryParam = new DeviceAreaQueryParam();
|
||||
List areaIds = recordList.stream().map(AcsRecogRecordResultDTO::getAreaId).collect(Collectors.toList());
|
||||
deviceAreaQueryParam.setIds(areaIds);
|
||||
CloudwalkResult deviceAreaResult = this.deviceAreaService.list(deviceAreaQueryParam);
|
||||
Map<String, String> areaMap = ((List)deviceAreaResult.getData()).stream().collect(Collectors.toMap(DeviceAreaResult::getId, DeviceAreaResult::getName));
|
||||
DeviceAreaQueryParam deviceAreaParentQueryParam = new DeviceAreaQueryParam();
|
||||
deviceAreaParentQueryParam.setParentIds(areaIds);
|
||||
CloudwalkResult deviceAreaParentResult = this.deviceAreaService.list(deviceAreaParentQueryParam);
|
||||
Map<String, String> areaParentMap = ((List)deviceAreaParentResult.getData()).stream().collect(Collectors.toMap(DeviceAreaResult::getParentId, DeviceAreaResult::getName, (k, v) -> v));
|
||||
for (AcsRecogRecordResultDTO resultDTO : recordList) {
|
||||
AcsRecogRecordResult recordResult = (AcsRecogRecordResult)BeanCopyUtils.copyProperties((Object)resultDTO, AcsRecogRecordResult.class);
|
||||
recordResult.setDistrictName(districtMap.get(resultDTO.getDistrictId()));
|
||||
if (areaParentMap.containsKey(resultDTO.getAreaId())) {
|
||||
recordResult.setAreaName(areaMap.get(resultDTO.getAreaId()) + "-" + areaParentMap.get(resultDTO.getAreaId()));
|
||||
} else {
|
||||
recordResult.setAreaName(areaMap.get(resultDTO.getAreaId()));
|
||||
}
|
||||
result.add(recordResult);
|
||||
}
|
||||
return CloudwalkResult.success((Object)new CloudwalkPageAble(result, page, cloudwalkResult.getTotalRows()));
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u5206\u9875\u67e5\u8be2\u8bc6\u522b\u8bb0\u5f55\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<Integer> statistics() {
|
||||
try {
|
||||
Long startDay = DateUtils.todayStart((Date)DateUtils.getDateSubDay((int)-1));
|
||||
Long endDay = DateUtils.todayStart((Date)new Date());
|
||||
AcsOpenDoorRecordQueryDTO openDoorQueryDTO = new AcsOpenDoorRecordQueryDTO();
|
||||
openDoorQueryDTO.setStartDay(startDay);
|
||||
openDoorQueryDTO.setEndDay(endDay);
|
||||
openDoorQueryDTO.setRecordResult(Integer.valueOf(1));
|
||||
List openDoorRecordList = this.acsOpenDoorRecordManager.statisticsByDay(openDoorQueryDTO);
|
||||
List openDoorRecordBusinessIdList = openDoorRecordList.stream().map(AcsOpenDoorRecordStatisticsResultDTO::getBusinessId).collect(Collectors.toList());
|
||||
Map<String, AcsOpenDoorRecordStatisticsResultDTO> openDoorRecordMap = openDoorRecordList.stream().collect(Collectors.toMap(AcsOpenDoorRecordStatisticsResultDTO::getBusinessId, openDoorRecord -> openDoorRecord));
|
||||
AcsRecogRecordQueryDTO recogQueryDTO = new AcsRecogRecordQueryDTO();
|
||||
recogQueryDTO.setStartDay(startDay);
|
||||
recogQueryDTO.setEndDay(endDay);
|
||||
List recogRecordList = this.acsRecogRecordManager.statisticsByDay(recogQueryDTO);
|
||||
List recogRecordBusinessIdList = recogRecordList.stream().map(AcsRecogRecordStatisticsResultDTO::getBusinessId).collect(Collectors.toList());
|
||||
Map<String, AcsRecogRecordStatisticsResultDTO> recogRecordMap = recogRecordList.stream().collect(Collectors.toMap(AcsRecogRecordStatisticsResultDTO::getBusinessId, recogRecord -> recogRecord));
|
||||
openDoorRecordBusinessIdList.removeAll(recogRecordBusinessIdList);
|
||||
openDoorRecordBusinessIdList.addAll(recogRecordBusinessIdList);
|
||||
ArrayList<AcsRecordStatisticsAddDTO> list = new ArrayList<AcsRecordStatisticsAddDTO>();
|
||||
for (String businessId : openDoorRecordBusinessIdList) {
|
||||
AcsRecordStatisticsAddDTO addDTO = new AcsRecordStatisticsAddDTO();
|
||||
AcsOpenDoorRecordStatisticsResultDTO openDoorRecordStatistics = openDoorRecordMap.get(businessId);
|
||||
AcsRecogRecordStatisticsResultDTO recogRecordStatistics = recogRecordMap.get(businessId);
|
||||
addDTO.setId(this.genUUID());
|
||||
addDTO.setBusinessId(businessId);
|
||||
if (openDoorRecordStatistics != null) {
|
||||
addDTO.setOpenDoorCount(openDoorRecordStatistics.getOpenDoorCount().longValue());
|
||||
}
|
||||
if (recogRecordStatistics != null) {
|
||||
addDTO.setRecogCount(recogRecordStatistics.getRecogCount().longValue());
|
||||
}
|
||||
addDTO.setStatisticsDate(DateUtils.customFormat((String)DateUtils.stampToDate((String)startDay.toString()), (String)"yyyy-MM-dd"));
|
||||
list.add(addDTO);
|
||||
long currentTime = DateUtils.getCurrentTime();
|
||||
addDTO.setCreateTime(Long.valueOf(currentTime));
|
||||
addDTO.setLastUpdateTime(Long.valueOf(currentTime));
|
||||
}
|
||||
int addCount = 0;
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
addCount = this.acsRecordStatisticsManager.addList(list);
|
||||
}
|
||||
return CloudwalkResult.success((Object)addCount);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u6309\u65e5\u7edf\u8ba1\u95e8\u7981\u8bb0\u5f55\u6570\u636e\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
return CloudwalkResult.fail((String)"76260007", (String)this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
|
||||
@RequiredLock(name="T(cn.cloudwalk.common.ninca.accesscontrol.config.AcsLockConstants).LOCK_RECORD_STATISTICS_BUSINESSID_PREFIX.concat(#key)", lockWaitTime=5000L)
|
||||
public CloudwalkResult<Boolean> createCache(String key, long value) {
|
||||
if (!this.redisTemplate.hasKey((Object)key).booleanValue()) {
|
||||
this.redisTemplate.opsForValue().set((Object)key, (Object)value, 8L, TimeUnit.DAYS);
|
||||
}
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private List<String> acsRecordListDupRemove(List<AcsRecordDetailQueryResultDTO> list, String flag) {
|
||||
ArrayList<String> tempList = new ArrayList<String>();
|
||||
if (flag.equals(DISTRICT_FLAG)) {
|
||||
for (AcsRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getDistrictId());
|
||||
}
|
||||
} else if (flag.equals(AREA_FLAG)) {
|
||||
for (AcsRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getAreaId());
|
||||
}
|
||||
}
|
||||
HashSet set = new HashSet(tempList);
|
||||
tempList.clear();
|
||||
tempList.addAll(set);
|
||||
return tempList;
|
||||
}
|
||||
|
||||
private List<String> acsElevatorRecordListDupRemove(List<AcsElevatorRecordDetailQueryResultDTO> list, String flag) {
|
||||
ArrayList<String> tempList = new ArrayList<String>();
|
||||
if (flag.equals(DISTRICT_FLAG)) {
|
||||
for (AcsElevatorRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getDistrictId());
|
||||
}
|
||||
} else if (flag.equals(AREA_FLAG)) {
|
||||
for (AcsElevatorRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getAreaId());
|
||||
}
|
||||
}
|
||||
HashSet set = new HashSet(tempList);
|
||||
tempList.clear();
|
||||
tempList.addAll(set);
|
||||
return tempList;
|
||||
}
|
||||
|
||||
private List<String> acsTempRecordListDupRemove(List<AcsTemperatureRecordDetailQueryResultDTO> list, String flag) {
|
||||
ArrayList<String> tempList = new ArrayList<String>();
|
||||
if (flag.equals(DISTRICT_FLAG)) {
|
||||
for (AcsTemperatureRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getDistrictId());
|
||||
}
|
||||
} else if (flag.equals(AREA_FLAG)) {
|
||||
for (AcsTemperatureRecordDetailQueryResultDTO resultDTO : list) {
|
||||
tempList.add(resultDTO.getAreaId());
|
||||
}
|
||||
}
|
||||
HashSet set = new HashSet(tempList);
|
||||
tempList.clear();
|
||||
tempList.addAll(set);
|
||||
return tempList;
|
||||
}
|
||||
|
||||
public static long add24HoursWithinYear(long startTime) {
|
||||
long endTime = startTime + 86400000L;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(startTime);
|
||||
int year = calendar.get(1);
|
||||
calendar.set(year, 11, 31, 23, 59, 59);
|
||||
calendar.set(14, 999);
|
||||
long yearEndTime = calendar.getTimeInMillis();
|
||||
if (endTime > yearEndTime) {
|
||||
endTime = yearEndTime;
|
||||
}
|
||||
return endTime;
|
||||
}
|
||||
}
|
||||
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordStatisticsParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsByDay
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecordStatisticsService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* javax.annotation.Resource
|
||||
* org.springframework.data.redis.core.RedisTemplate
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsRecordStatisticsParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsByDay;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.result.AcsRecordStatisticsResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsRecordStatisticsService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.AcsCacheKeyUtil;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.cacheable.AcsRecordStatisticsCacheableService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service(value="acsRecordStatisticsService")
|
||||
public class AcsRecordStatisticsServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsRecordStatisticsService {
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@Resource
|
||||
private AcsRecordStatisticsCacheableService acsRecordStatisticsCacheableService;
|
||||
|
||||
public CloudwalkResult<AcsRecordStatisticsResult> recordStatistics(AcsRecordStatisticsParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
try {
|
||||
this.logger.info("\u6700\u8fd17\u65e5\u5f00\u95e8\u6b21\u6570\u548c\u8bc6\u522b\u6b21\u6570\u7edf\u8ba1\u5f00\u59cb,AcsRecordStatisticsParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
AcsRecordStatisticsResult acsRecordStatisticsResult = new AcsRecordStatisticsResult();
|
||||
List<AcsRecordStatisticsByDay> recordStatisticsByDays = this.acsRecordStatisticsCacheableService.list(DateUtils.parseDate((Date)new Date(), (String)"yyyy-MM-dd"), context.getCompany().getCompanyId());
|
||||
long openDoorCount = 0L;
|
||||
long recogCount = 0L;
|
||||
Object openDoorCountObj = this.redisTemplate.opsForValue().get((Object)AcsCacheKeyUtil.getOpenDoorCountKey((String)DateUtils.parseDate((Date)new Date(), (String)"yyyy-MM-dd"), (String)context.getCompany().getCompanyId()));
|
||||
Object recogCountObj = this.redisTemplate.opsForValue().get((Object)AcsCacheKeyUtil.getRecogCountKey((String)DateUtils.parseDate((Date)new Date(), (String)"yyyy-MM-dd"), (String)context.getCompany().getCompanyId()));
|
||||
if (openDoorCountObj != null) {
|
||||
openDoorCount = Long.parseLong(openDoorCountObj.toString());
|
||||
}
|
||||
if (recogCountObj != null) {
|
||||
recogCount = Long.parseLong(recogCountObj.toString());
|
||||
}
|
||||
acsRecordStatisticsResult.setTodayOpenDoorFlow(openDoorCount);
|
||||
acsRecordStatisticsResult.setTodayRecogFlow(recogCount);
|
||||
AcsRecordStatisticsByDay todayRecordStatistics = new AcsRecordStatisticsByDay();
|
||||
todayRecordStatistics.setOpenDoorFlow(openDoorCount);
|
||||
todayRecordStatistics.setRecogFlow(recogCount);
|
||||
todayRecordStatistics.setDays(DateUtils.parseDate((Date)new Date(), (String)"yyyy-MM-dd"));
|
||||
recordStatisticsByDays.add(todayRecordStatistics);
|
||||
acsRecordStatisticsResult.setDaysFlows(recordStatisticsByDays);
|
||||
return CloudwalkResult.success((Object)acsRecordStatisticsResult);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u95e8\u7981\u8bb0\u5f55\u7edf\u8ba1\u6570\u636e\u5e93\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("76260007", this.getMessage("76260007"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AcsConstants
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils
|
||||
* org.slf4j.Logger
|
||||
* org.slf4j.LoggerFactory
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.data.redis.connection.Message
|
||||
* org.springframework.data.redis.listener.KeyExpirationEventMessageListener
|
||||
* org.springframework.data.redis.listener.RedisMessageListenerContainer
|
||||
* org.springframework.stereotype.Component
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record.listener;
|
||||
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.param.AcsOpenDoorRecordEditParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.record.service.AcsOpenDoorRecordService;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AcsConstants;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsOpenDoorStatusEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.DateUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class RedisKeyExpirationListener
|
||||
extends KeyExpirationEventMessageListener {
|
||||
private Logger logger = LoggerFactory.getLogger(RedisKeyExpirationListener.class);
|
||||
@Autowired
|
||||
private AccessControlProperties accessControlProperties;
|
||||
@Autowired
|
||||
private AcsOpenDoorRecordService acsOpenDoorRecordService;
|
||||
|
||||
public RedisKeyExpirationListener(RedisMessageListenerContainer listenerContainer) {
|
||||
super(listenerContainer);
|
||||
}
|
||||
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
try {
|
||||
String expiredKey = message.toString();
|
||||
if (expiredKey.startsWith("acs:backendRegExpire:")) {
|
||||
CloudwalkResult modifyResult;
|
||||
this.logger.info("\u63a5\u6536\u5230\u5931\u6548\u7684\u540e\u7aef\u8bc6\u522b\u5f00\u95e8\u8bb0\u5f55\u8fc7\u671f\u65f6\u95f4\u7f13\u5b58\u7684key:[{}]", (Object)expiredKey);
|
||||
AcsOpenDoorRecordEditParam editParam = this.getEditParam(expiredKey);
|
||||
if (editParam != null && !(modifyResult = this.acsOpenDoorRecordService.modify(editParam)).isSuccess()) {
|
||||
this.logger.info("\u66f4\u65b0\u5f00\u95e8\u8bb0\u5f55\u72b6\u6001\u5931\u8d25\uff0c\u539f\u56e0\uff1a[{}]", (Object)modifyResult.getMessage());
|
||||
}
|
||||
this.logger.info("\u5931\u6548\u7684\u540e\u7aef\u8bc6\u522b\u5f00\u95e8\u8bb0\u5f55\u8fc7\u671f\u65f6\u95f4\u7f13\u5b58\u7684key\u5904\u7406\u5b8c\u6210:[{}]", (Object)expiredKey);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u5904\u7406\u5931\u6548\u7684\u540e\u7aef\u8bc6\u522b\u5f00\u95e8\u8bb0\u5f55\u8fc7\u671f\u65f6\u95f4\u7f13\u5b58\u5f02\u5e38\uff0c\u539f\u56e0\uff1a[{}]", (Object)e.getMessage(), (Object)e);
|
||||
}
|
||||
}
|
||||
|
||||
private AcsOpenDoorRecordEditParam getEditParam(String expiredKey) {
|
||||
String openDoorLogId;
|
||||
String businessId;
|
||||
String[] split = expiredKey.split("#");
|
||||
if (split.length < 3) {
|
||||
return null;
|
||||
}
|
||||
if (split.length == 3) {
|
||||
businessId = split[1];
|
||||
openDoorLogId = split[2];
|
||||
} else {
|
||||
String prefix = split[0];
|
||||
businessId = split[1];
|
||||
openDoorLogId = expiredKey.substring((prefix + "#" + businessId + "#").length());
|
||||
}
|
||||
long startDay = DateUtils.getCurrentTime() - this.accessControlProperties.getFaceCaptureOpenDoorFailMilliseconds() - AcsConstants.ONE_DAY_MILLISECONDS;
|
||||
long endDay = DateUtils.getCurrentTime();
|
||||
AcsOpenDoorRecordEditParam editParam = new AcsOpenDoorRecordEditParam();
|
||||
editParam.setBusinessId(businessId);
|
||||
editParam.setLogId(openDoorLogId);
|
||||
editParam.setStartDay(Long.valueOf(startDay));
|
||||
editParam.setEndDay(Long.valueOf(endDay));
|
||||
editParam.setRecordResult(AcsOpenDoorStatusEnum.FAIL.getCode());
|
||||
return editParam;
|
||||
}
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* org.springframework.context.annotation.Bean
|
||||
* org.springframework.context.annotation.Configuration
|
||||
* org.springframework.data.redis.connection.RedisConnectionFactory
|
||||
* org.springframework.data.redis.listener.RedisMessageListenerContainer
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.record.listener;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
|
||||
@Configuration
|
||||
public class RedisListenerConfig {
|
||||
@Bean
|
||||
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
return container;
|
||||
}
|
||||
}
|
||||
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceAttrQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceAttrService
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceIdentifyTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.setting;
|
||||
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceAttrQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceAttrService;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceIdentifyTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.cacheable.AcsDeviceAttrCacheableService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service(value="acsDeviceAttrService")
|
||||
public class AcsDeviceAttrServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceAttrService {
|
||||
@Autowired
|
||||
private AcsDeviceAttrCacheableService acsDeviceAttrCacheableService;
|
||||
|
||||
public CloudwalkResult<AcsDeviceSettingResult> query(AcsDeviceAttrQueryParam param, CloudwalkCallContext context) {
|
||||
AcsDeviceSettingResult result = new AcsDeviceSettingResult();
|
||||
result.setDeviceId(param.getDeviceId());
|
||||
try {
|
||||
this.logger.info("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u5c5e\u6027\u5f00\u59cb\uff1aAcsDeviceAttrQueryParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
DeviceResult device = super.getDevice(param.getDeviceId(), context);
|
||||
Map<String, AcsDeviceAttrResultDto> deviceAttrMap = new HashMap<String, AcsDeviceAttrResultDto>();
|
||||
if (device.getIdentifyType() == AcsDeviceIdentifyTypeEnum.BACKEND_REG.getCode().intValue()) {
|
||||
AcsDeviceAttrQueryDto acsDeviceAttrQueryDto = new AcsDeviceAttrQueryDto();
|
||||
acsDeviceAttrQueryDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
acsDeviceAttrQueryDto.setDeviceId(param.getDeviceId());
|
||||
List<AcsDeviceAttrResultDto> acsDeviceAttrs = this.acsDeviceAttrCacheableService.query(acsDeviceAttrQueryDto);
|
||||
if (CollectionUtils.isNotEmpty(acsDeviceAttrs)) {
|
||||
deviceAttrMap = acsDeviceAttrs.stream().collect(Collectors.toMap(AcsDeviceAttrResultDto::deviceAndAttrCode, deviceAttr -> deviceAttr));
|
||||
}
|
||||
List<AcsSettingAttr> attrs = super.setAcsDeviceAttrList(param.getDeviceId(), deviceAttrMap, YesNoTypeEnum.N);
|
||||
result.setAttrs(attrs);
|
||||
}
|
||||
this.logger.info("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u5c5e\u6027\u7ed3\u675f");
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.logger.error("\u83b7\u53d6\u95e8\u7981\u8bbe\u5907\u53c2\u6570\u5931\u8d25\uff0c\u539f\u56e0\uff1a{}", (Object)e.getMessage(), (Object)e);
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+384
@@ -0,0 +1,384 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceAttrManager
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingNotifyParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingNotifyParam$SettingAttr
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingQueryParam
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceSettingResult
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceSettingResult$DeviceSettings
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService
|
||||
* cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceSettingService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceDefaultSettingParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceSettingGetsParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceSettingParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceTemperatureSettingParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsSettingAttrParam
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceSettingService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.context.CloudwalkCallContext
|
||||
* cn.cloudwalk.cloud.exception.DataAccessException
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrAddDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrEditDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsApplicationSourceEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceIdentifyTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils
|
||||
* cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils
|
||||
* com.alibaba.fastjson.JSONObject
|
||||
* com.google.common.collect.Lists
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Service
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.setting;
|
||||
|
||||
import cn.cloudwalk.biz.ninca.accesscontrol.device.AcsDeviceAttrManager;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingNotifyParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.param.DeviceSettingQueryParam;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.result.DeviceSettingResult;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceNotifyService;
|
||||
import cn.cloudwalk.client.cwoscomponent.intelligent.device.service.DeviceSettingService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.param.AcsdeviceDetailQueryParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.result.AcsDeviceDetailResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.device.service.AcsDeviceService;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceDefaultSettingParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceSettingGetsParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceSettingParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsDeviceTemperatureSettingParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.param.AcsSettingAttrParam;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsDeviceSettingResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.result.AcsSettingAttr;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.setting.service.AcsDeviceSettingService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.context.CloudwalkCallContext;
|
||||
import cn.cloudwalk.cloud.exception.DataAccessException;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrAddDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrEditDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrQueryDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.bean.device.dto.AcsDeviceAttrResultDto;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.config.AccessControlProperties;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsApplicationSourceEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceIdentifyTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.AcsDeviceSettingEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.em.YesNoTypeEnum;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.CollectionUtils;
|
||||
import cn.cloudwalk.common.ninca.accesscontrol.util.StringUtils;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.cacheable.AcsDeviceAttrCacheableService;
|
||||
import cn.cloudwalk.service.ninca.accesscontrol.device.AbstractAcsDeviceService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AcsDeviceSettingServiceImpl
|
||||
extends AbstractAcsDeviceService
|
||||
implements AcsDeviceSettingService {
|
||||
@Autowired
|
||||
private DeviceSettingService deviceSettingService;
|
||||
@Autowired
|
||||
private DeviceNotifyService deviceNotifyService;
|
||||
@Autowired
|
||||
private AcsDeviceService acsDeviceService;
|
||||
@Autowired
|
||||
private AcsDeviceAttrManager acsDeviceAttrManager;
|
||||
@Autowired
|
||||
private AcsDeviceAttrCacheableService acsDeviceAttrCacheableService;
|
||||
@Autowired
|
||||
private AccessControlProperties accessControlProperties;
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<Boolean> setting(AcsDeviceSettingParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
this.logger.info("\u4fdd\u5b58\u8bbe\u5907\u53c2\u6570\u5f00\u59cb\uff1aAcsDeviceSettingParam=[{}], CloudwalkCallContext=[{}]", (Object)JSONObject.toJSONString((Object)param), (Object)JSONObject.toJSONString((Object)context));
|
||||
for (String deviceId : param.getDeviceIds()) {
|
||||
DeviceSettingNotifyParam notifyParam = new DeviceSettingNotifyParam();
|
||||
this.checkAcsDeviceIsExist(context, deviceId);
|
||||
DeviceResult deviceResult = super.getDevice(deviceId, context);
|
||||
try {
|
||||
this.saveAcsDeviceAttr(deviceId, param.getAttrs(), deviceResult.getIdentifyType(), context);
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u95e8\u7981\u5e94\u7528\u81ea\u5b9a\u4e49\u7684\u8bbe\u5907\u53c2\u6570\u4fdd\u5b58\u5931\u8d25,\u539f\u56e0\uff1a{}", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u95e8\u7981\u5e94\u7528\u81ea\u5b9a\u4e49\u7684\u8bbe\u5907\u53c2\u6570\u4fdd\u5b58\u6570\u636e\u5e93\u5f02\u5e38");
|
||||
}
|
||||
List cwosSettingAttrParamList = param.getAttrs().stream().filter(attr -> AcsDeviceSettingEnum.getEnumByCode((String)attr.getCode()) == null || !AcsApplicationSourceEnum.ACCESS_CONTROL.getCode().equals(AcsDeviceSettingEnum.getEnumByCode((String)attr.getCode()).getSource().getCode())).collect(Collectors.toList());
|
||||
notifyParam.setDeviceId(deviceResult.getDeviceCode());
|
||||
notifyParam.setLogId(String.valueOf(System.currentTimeMillis()));
|
||||
DeviceSettingQueryParam deviceSettingQueryParam = new DeviceSettingQueryParam();
|
||||
deviceSettingQueryParam.setDeviceIds((List)Lists.newArrayList((Iterable)param.getDeviceIds()));
|
||||
deviceSettingQueryParam.setHasDefault(Short.valueOf((short)0));
|
||||
CloudwalkResult deviceSettingResult = this.deviceSettingService.query(deviceSettingQueryParam);
|
||||
if (deviceSettingResult.isSuccess()) {
|
||||
if (!CollectionUtils.isNotEmpty((Collection)((Collection)deviceSettingResult.getData()))) continue;
|
||||
List oldAttrs = ((DeviceSettingResult)((List)deviceSettingResult.getData()).get(0)).getSettings();
|
||||
ArrayList<AcsSettingAttr> acsSettingAttrs = new ArrayList<AcsSettingAttr>();
|
||||
this.recursionSettingAttr(acsSettingAttrs, oldAttrs);
|
||||
if (!CollectionUtils.isNotEmpty(acsSettingAttrs)) continue;
|
||||
Map<String, AcsSettingAttrParam> newAttrMap = cwosSettingAttrParamList.stream().collect(Collectors.toMap(AcsSettingAttrParam::getCode, newAttr -> newAttr));
|
||||
Map<String, AcsSettingAttr> oldAttrCodeMap = acsSettingAttrs.stream().collect(Collectors.toMap(AcsSettingAttr::getCode, newAttr -> newAttr));
|
||||
Map<String, AcsSettingAttr> oldAttrIdMap = acsSettingAttrs.stream().collect(Collectors.toMap(AcsSettingAttr::getId, newAttr -> newAttr));
|
||||
this.buildAttrParent(newAttrMap, oldAttrCodeMap, oldAttrIdMap);
|
||||
List<DeviceSettingNotifyParam.SettingAttr> setttingAttrs = this.convertNotifyParam(newAttrMap, oldAttrs);
|
||||
notifyParam.setSetttingAttr(setttingAttrs);
|
||||
this.logger.info("\u5f00\u59cb\u4e0b\u53d1\u7ec8\u7aef\u53c2\u6570\u8bbe\u7f6e:{}", (Object)JSONObject.toJSONString((Object)notifyParam));
|
||||
CloudwalkResult notifyResult = this.deviceNotifyService.notifySetting(notifyParam);
|
||||
this.logger.info("\u5f00\u59cb\u4e0b\u53d1\u7ec8\u7aef\u53c2\u6570\u8bbe\u7f6e\u7ed3\u679c:{}", (Object)JSONObject.toJSONString((Object)notifyResult));
|
||||
continue;
|
||||
}
|
||||
this.logger.info("\u67e5\u8be2\u8bbe\u5907\u53c2\u6570\u5931\u8d25,code:{},message:{}", (Object)deviceSettingResult.getCode(), (Object)deviceSettingResult.getMessage());
|
||||
}
|
||||
this.logger.info("\u4fdd\u5b58\u8bbe\u5907\u53c2\u6570\u7ed3\u675f");
|
||||
return CloudwalkResult.success((Object)true);
|
||||
}
|
||||
|
||||
private void saveAcsDeviceAttr(String deviceId, List<AcsSettingAttrParam> attrs, int identifyType, CloudwalkCallContext context) throws DataAccessException {
|
||||
List acsSettingAttrParamList;
|
||||
if (identifyType == AcsDeviceIdentifyTypeEnum.BACKEND_REG.getCode() && CollectionUtils.isNotEmpty(acsSettingAttrParamList = attrs.stream().filter(attr -> AcsDeviceSettingEnum.getEnumByCode((String)attr.getCode()) != null && AcsApplicationSourceEnum.ACCESS_CONTROL.getCode().equals(AcsDeviceSettingEnum.getEnumByCode((String)attr.getCode()).getSource().getCode())).collect(Collectors.toList()))) {
|
||||
Map<String, AcsDeviceAttrResultDto> deviceAttrMap = this.getDeviceAttrMap(context, Collections.singletonList(deviceId));
|
||||
for (AcsSettingAttrParam attrParam : acsSettingAttrParamList) {
|
||||
if (deviceAttrMap.containsKey(deviceId + "_" + attrParam.getCode())) {
|
||||
AcsDeviceAttrEditDto attrEditDto = new AcsDeviceAttrEditDto();
|
||||
BeanCopyUtils.copyProperties((Object)attrParam, (CloudwalkCallContext)context, (Object)attrEditDto);
|
||||
attrEditDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
attrEditDto.setDeviceId(deviceId);
|
||||
attrEditDto.setAttrCode(attrParam.getCode());
|
||||
attrEditDto.setAttrValue(attrParam.getValue());
|
||||
this.acsDeviceAttrCacheableService.update(attrEditDto);
|
||||
continue;
|
||||
}
|
||||
AcsDeviceAttrAddDto attrAddDto = new AcsDeviceAttrAddDto();
|
||||
BeanCopyUtils.copyProperties((Object)attrParam, (CloudwalkCallContext)context, (Object)attrAddDto);
|
||||
attrAddDto.setId(this.genUUID());
|
||||
attrAddDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
attrAddDto.setDeviceId(deviceId);
|
||||
attrAddDto.setAttrCode(attrParam.getCode());
|
||||
attrAddDto.setAttrValue(attrParam.getValue());
|
||||
this.acsDeviceAttrCacheableService.insert(attrAddDto);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAcsDeviceIsExist(CloudwalkCallContext context, String deviceId) throws ServiceException {
|
||||
AcsdeviceDetailQueryParam acsdeviceDetailQueryParam = new AcsdeviceDetailQueryParam();
|
||||
acsdeviceDetailQueryParam.setDeviceId(deviceId);
|
||||
CloudwalkResult acsDeviceDetailResult = this.acsDeviceService.detail(acsdeviceDetailQueryParam, context);
|
||||
if (!acsDeviceDetailResult.isSuccess() || acsDeviceDetailResult.getData() == null || ((AcsDeviceDetailResult)acsDeviceDetailResult.getData()).getDeviceId() == null) {
|
||||
throw new ServiceException("76260115", this.getMessage("76260115"));
|
||||
}
|
||||
}
|
||||
|
||||
private void buildAttrParent(Map<String, AcsSettingAttrParam> newAttrMap, Map<String, AcsSettingAttr> oldAttrMap, Map<String, AcsSettingAttr> oldAttrIdMap) {
|
||||
HashMap<String, AcsSettingAttrParam> tempNewAttrMap = new HashMap<String, AcsSettingAttrParam>();
|
||||
tempNewAttrMap.putAll(newAttrMap);
|
||||
for (Map.Entry entry : tempNewAttrMap.entrySet()) {
|
||||
AcsSettingAttr acsSettingAttr = oldAttrMap.get(((AcsSettingAttrParam)entry.getValue()).getCode());
|
||||
this.recursionParentAttr(newAttrMap, acsSettingAttr, oldAttrIdMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void recursionParentAttr(Map<String, AcsSettingAttrParam> newAttrMap, AcsSettingAttr acsSettingAttr, Map<String, AcsSettingAttr> oldAttrIdMap) {
|
||||
AcsSettingAttr parent;
|
||||
if (StringUtils.isNotBlank((String)acsSettingAttr.getParentId()) && (parent = oldAttrIdMap.get(acsSettingAttr.getParentId())) != null && newAttrMap.get(parent.getCode()) == null) {
|
||||
AcsSettingAttrParam newParam = new AcsSettingAttrParam();
|
||||
newParam.setName(parent.getName());
|
||||
newParam.setValue(parent.getValue());
|
||||
newParam.setCode(parent.getCode());
|
||||
newAttrMap.put(parent.getCode(), newParam);
|
||||
this.recursionParentAttr(newAttrMap, parent, oldAttrIdMap);
|
||||
}
|
||||
}
|
||||
|
||||
private List<DeviceSettingNotifyParam.SettingAttr> convertNotifyParam(Map<String, AcsSettingAttrParam> newAttrMap, List<DeviceSettingResult.DeviceSettings> oldAttrs) {
|
||||
ArrayList<DeviceSettingNotifyParam.SettingAttr> notifyParam = new ArrayList<DeviceSettingNotifyParam.SettingAttr>();
|
||||
this.notifyRecursionAttr(notifyParam, newAttrMap, oldAttrs);
|
||||
return notifyParam;
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<List<AcsDeviceSettingResult>> gets(AcsDeviceSettingGetsParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceSettingQueryParam deviceSettingQueryParam = new DeviceSettingQueryParam();
|
||||
deviceSettingQueryParam.setDeviceIds(param.getDeviceIds());
|
||||
deviceSettingQueryParam.setHasDefault(Short.valueOf((short)0));
|
||||
CloudwalkResult deviceSettingResult = this.deviceSettingService.query(deviceSettingQueryParam);
|
||||
if (deviceSettingResult.isSuccess()) {
|
||||
List<AcsDeviceSettingResult> resultList = this.convert((List)deviceSettingResult.getData());
|
||||
this.addAcsSettingAttrs(context, resultList, YesNoTypeEnum.N);
|
||||
return CloudwalkResult.success(resultList);
|
||||
}
|
||||
return CloudwalkResult.fail((String)deviceSettingResult.getCode(), (String)deviceSettingResult.getMessage());
|
||||
}
|
||||
|
||||
private void addAcsSettingAttrs(CloudwalkCallContext context, List<AcsDeviceSettingResult> resultList, YesNoTypeEnum isDefault) throws ServiceException {
|
||||
try {
|
||||
List<String> deviceIds = resultList.stream().map(AcsDeviceSettingResult::getDeviceId).collect(Collectors.toList());
|
||||
Map<String, DeviceResult> deviceMap = this.getDeviceMap(context, deviceIds);
|
||||
if (deviceMap == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, AcsDeviceAttrResultDto> deviceAttrMap = this.getDeviceAttrMap(context, deviceIds);
|
||||
for (AcsDeviceSettingResult deviceSetting : resultList) {
|
||||
if (!deviceMap.containsKey(deviceSetting.getDeviceId()) || deviceMap.get(deviceSetting.getDeviceId()).getIdentifyType() != AcsDeviceIdentifyTypeEnum.BACKEND_REG.getCode().intValue()) continue;
|
||||
deviceSetting.getAttrs().addAll(super.setAcsDeviceAttrList(deviceSetting.getDeviceId(), deviceAttrMap, isDefault));
|
||||
}
|
||||
}
|
||||
catch (DataAccessException e) {
|
||||
this.logger.error("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u5c5e\u6027\u5f02\u5e38\uff0c\u539f\u56e0\uff1a{}", (Object)e.getMessage(), (Object)e);
|
||||
throw new ServiceException("\u67e5\u8be2\u95e8\u7981\u8bbe\u5907\u5c5e\u6027\u6570\u636e\u5e93\u5f02\u5e38");
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, DeviceResult> getDeviceMap(CloudwalkCallContext context, List<String> deviceIds) throws ServiceException {
|
||||
List<DeviceResult> deviceList = super.getDeviceList(deviceIds, context);
|
||||
if (CollectionUtils.isEmpty(deviceList)) {
|
||||
return null;
|
||||
}
|
||||
Map<String, DeviceResult> deviceMap = deviceList.stream().collect(Collectors.toMap(DeviceResult::getId, device -> device));
|
||||
return deviceMap;
|
||||
}
|
||||
|
||||
private Map<String, AcsDeviceAttrResultDto> getDeviceAttrMap(CloudwalkCallContext context, List<String> deviceIds) throws DataAccessException {
|
||||
List<AcsDeviceAttrResultDto> acsDeviceAttr = this.getAcsDeviceAttrByCode(deviceIds, context);
|
||||
if (CollectionUtils.isEmpty(acsDeviceAttr)) {
|
||||
return new HashMap<String, AcsDeviceAttrResultDto>();
|
||||
}
|
||||
Map<String, AcsDeviceAttrResultDto> deviceAttrMap = acsDeviceAttr.stream().collect(Collectors.toMap(AcsDeviceAttrResultDto::deviceAndAttrCode, deviceAttr -> deviceAttr));
|
||||
return deviceAttrMap;
|
||||
}
|
||||
|
||||
private List<AcsDeviceAttrResultDto> getAcsDeviceAttrByCode(List<String> deviceIds, CloudwalkCallContext context) throws DataAccessException {
|
||||
AcsDeviceAttrQueryDto acsDeviceAttrQueryDto = new AcsDeviceAttrQueryDto();
|
||||
acsDeviceAttrQueryDto.setBusinessId(context.getCompany().getCompanyId());
|
||||
acsDeviceAttrQueryDto.setDeviceIds(deviceIds);
|
||||
return this.acsDeviceAttrManager.query(acsDeviceAttrQueryDto);
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate(argsIndexs={0, 1})
|
||||
public CloudwalkResult<List<AcsDeviceSettingResult>> getDefault(AcsDeviceDefaultSettingParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
DeviceSettingQueryParam deviceSettingQueryParam = new DeviceSettingQueryParam();
|
||||
deviceSettingQueryParam.setDeviceIds(param.getDeviceIds());
|
||||
deviceSettingQueryParam.setHasDefault(Short.valueOf((short)1));
|
||||
CloudwalkResult deviceSettingResult = this.deviceSettingService.query(deviceSettingQueryParam);
|
||||
if (deviceSettingResult.isSuccess()) {
|
||||
List<AcsDeviceSettingResult> deviceSettingList = this.convert((List)deviceSettingResult.getData());
|
||||
this.addAcsSettingAttrs(context, deviceSettingList, YesNoTypeEnum.Y);
|
||||
return CloudwalkResult.success(deviceSettingList);
|
||||
}
|
||||
return CloudwalkResult.fail((String)deviceSettingResult.getCode(), (String)deviceSettingResult.getMessage());
|
||||
}
|
||||
|
||||
public CloudwalkResult<AcsDeviceSettingResult> getTemperatureSetting(AcsDeviceTemperatureSettingParam param, CloudwalkCallContext context) throws ServiceException {
|
||||
AcsDeviceSettingResult result = new AcsDeviceSettingResult();
|
||||
result.setDeviceId(param.getDeviceId());
|
||||
DeviceSettingQueryParam deviceSettingQueryParam = new DeviceSettingQueryParam();
|
||||
deviceSettingQueryParam.setDeviceIds((List)Lists.newArrayList((Object[])new String[]{param.getDeviceId()}));
|
||||
deviceSettingQueryParam.setHasDefault(Short.valueOf((short)0));
|
||||
CloudwalkResult deviceSettingQueryResult = this.deviceSettingService.query(deviceSettingQueryParam);
|
||||
if (deviceSettingQueryResult.isSuccess()) {
|
||||
DeviceSettingResult deviceSettingResult;
|
||||
List settingResult;
|
||||
if (CollectionUtils.isNotEmpty((Collection)((Collection)deviceSettingQueryResult.getData())) && CollectionUtils.isNotEmpty((Collection)(settingResult = (deviceSettingResult = (DeviceSettingResult)((List)deviceSettingQueryResult.getData()).get(0)).getSettings()))) {
|
||||
ArrayList<AcsSettingAttr> acsSettingAttrs = new ArrayList<AcsSettingAttr>();
|
||||
this.recursionSettingAttr(acsSettingAttrs, settingResult);
|
||||
List attrs = acsSettingAttrs.stream().filter(s -> AcsDeviceSettingEnum.TEMP_MIN.getCode().equals(s.getCode()) || AcsDeviceSettingEnum.TEMP_STATE.getCode().equals(s.getCode()) || AcsDeviceSettingEnum.TEMP_THRESHOLD.getCode().equals(s.getCode())).collect(Collectors.toList());
|
||||
result.setAttrs(attrs);
|
||||
}
|
||||
return CloudwalkResult.success((Object)result);
|
||||
}
|
||||
return CloudwalkResult.fail((String)deviceSettingQueryResult.getCode(), (String)deviceSettingQueryResult.getMessage());
|
||||
}
|
||||
|
||||
public CloudwalkResult<BigDecimal> getTemperatureInit() {
|
||||
return CloudwalkResult.success((Object)this.accessControlProperties.getTemperatureThreshold());
|
||||
}
|
||||
|
||||
private List<AcsDeviceSettingResult> convert(List<DeviceSettingResult> deviceSettingResults) {
|
||||
ArrayList<AcsDeviceSettingResult> result = new ArrayList<AcsDeviceSettingResult>();
|
||||
if (CollectionUtils.isNotEmpty(deviceSettingResults)) {
|
||||
for (DeviceSettingResult deviceSettingResult : deviceSettingResults) {
|
||||
result.add(this.convertDeviceSettingResult(deviceSettingResult));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private AcsDeviceSettingResult convertDeviceSettingResult(DeviceSettingResult deviceSettingResult) {
|
||||
AcsDeviceSettingResult acsDeviceSetting = new AcsDeviceSettingResult();
|
||||
acsDeviceSetting.setDeviceId(deviceSettingResult.getDeviceId());
|
||||
List deviceSettings = deviceSettingResult.getSettings();
|
||||
ArrayList<AcsSettingAttr> acsSettingAttrs = new ArrayList<AcsSettingAttr>();
|
||||
this.recursionSettingAttr(acsSettingAttrs, deviceSettings);
|
||||
acsDeviceSetting.setAttrs(acsSettingAttrs);
|
||||
return acsDeviceSetting;
|
||||
}
|
||||
|
||||
private void recursionSettingAttr(List<AcsSettingAttr> acsSettingAttrs, List<DeviceSettingResult.DeviceSettings> deviceSettings) {
|
||||
if (CollectionUtils.isNotEmpty(deviceSettings)) {
|
||||
for (DeviceSettingResult.DeviceSettings deviceSetting : deviceSettings) {
|
||||
AcsSettingAttr acsSettingAttr = new AcsSettingAttr();
|
||||
acsSettingAttr.setName(deviceSetting.getSettingAttrName());
|
||||
acsSettingAttr.setValue(deviceSetting.getSettingAttrValue());
|
||||
acsSettingAttr.setRemark(deviceSetting.getSettingAttrRemark());
|
||||
acsSettingAttr.setCode(deviceSetting.getSettingAttrCode());
|
||||
acsSettingAttr.setId(deviceSetting.getId());
|
||||
acsSettingAttr.setParentId(deviceSetting.getSettingParentId());
|
||||
acsSettingAttrs.add(acsSettingAttr);
|
||||
this.recursionSettingAttr(acsSettingAttrs, deviceSetting.getChild());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyRecursionAttr(List<DeviceSettingNotifyParam.SettingAttr> result, Map<String, AcsSettingAttrParam> newAttrsMap, List<DeviceSettingResult.DeviceSettings> oldAttrs) {
|
||||
if (CollectionUtils.isNotEmpty(oldAttrs)) {
|
||||
this.notifyAttrBuild(result, newAttrsMap, oldAttrs);
|
||||
}
|
||||
}
|
||||
|
||||
private List<DeviceSettingNotifyParam.SettingAttr> notifyGetChild(Map<String, AcsSettingAttrParam> newAttrsMap, List<DeviceSettingResult.DeviceSettings> oldAttrs) {
|
||||
ArrayList<DeviceSettingNotifyParam.SettingAttr> child = null;
|
||||
if (CollectionUtils.isNotEmpty(oldAttrs)) {
|
||||
child = new ArrayList<DeviceSettingNotifyParam.SettingAttr>();
|
||||
this.notifyAttrBuild(child, newAttrsMap, oldAttrs);
|
||||
}
|
||||
return child;
|
||||
}
|
||||
|
||||
private void notifyAttrBuild(List<DeviceSettingNotifyParam.SettingAttr> result, Map<String, AcsSettingAttrParam> newAttrsMap, List<DeviceSettingResult.DeviceSettings> oldAttrs) {
|
||||
for (DeviceSettingResult.DeviceSettings deviceSetting : oldAttrs) {
|
||||
DeviceSettingNotifyParam.SettingAttr attr = new DeviceSettingNotifyParam.SettingAttr();
|
||||
AcsSettingAttrParam newAttr = newAttrsMap.get(deviceSetting.getSettingAttrCode());
|
||||
if (newAttr == null) continue;
|
||||
attr.setName(deviceSetting.getSettingAttrName());
|
||||
attr.setRemark(deviceSetting.getSettingAttrRemark());
|
||||
attr.setChild(this.notifyGetChild(newAttrsMap, deviceSetting.getChild()));
|
||||
attr.setValue(newAttr.getValue());
|
||||
result.add(attr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartAppendParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartFinishParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.param.part.FilePartInitParam
|
||||
* cn.cloudwalk.client.davinci.portal.file.result.FilePartResult
|
||||
* cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService
|
||||
* cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate
|
||||
* cn.cloudwalk.cloud.exception.ServiceException
|
||||
* cn.cloudwalk.cloud.result.CloudwalkResult
|
||||
* cn.cloudwalk.cloud.utils.BeanCopyUtils
|
||||
* cn.cloudwalk.intelligent.davinci.common.exception.DavinciServiceException
|
||||
* cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartFinishDTO
|
||||
* cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartInitDTO
|
||||
* cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartInitResultDTO
|
||||
* cn.cloudwalk.intelligent.davinci.storage.manager.FilePartManager
|
||||
* cn.cloudwalk.intelligent.davinci.storage.manager.FileStorageManager
|
||||
* org.springframework.beans.factory.annotation.Autowired
|
||||
* org.springframework.stereotype.Component
|
||||
* org.springframework.util.FileCopyUtils
|
||||
* org.springframework.web.multipart.MultipartFile
|
||||
*/
|
||||
package cn.cloudwalk.service.ninca.accesscontrol.storage;
|
||||
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartAppendParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartFinishParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.param.part.FilePartInitParam;
|
||||
import cn.cloudwalk.client.davinci.portal.file.result.FilePartResult;
|
||||
import cn.cloudwalk.client.ninca.accesscontrol.storage.service.AcsFileStorageService;
|
||||
import cn.cloudwalk.cloud.annotation.CloudwalkParamsValidate;
|
||||
import cn.cloudwalk.cloud.exception.ServiceException;
|
||||
import cn.cloudwalk.cloud.result.CloudwalkResult;
|
||||
import cn.cloudwalk.cloud.utils.BeanCopyUtils;
|
||||
import cn.cloudwalk.intelligent.davinci.common.exception.DavinciServiceException;
|
||||
import cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartFinishDTO;
|
||||
import cn.cloudwalk.intelligent.davinci.storage.bean.part.dto.PartInitDTO;
|
||||
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.ninca.accesscontrol.common.AbstractCloudwalkService;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@Component
|
||||
public class AcsFileStorageServiceImpl
|
||||
extends AbstractCloudwalkService
|
||||
implements AcsFileStorageService {
|
||||
@Autowired
|
||||
private FilePartManager filePartManager;
|
||||
@Autowired
|
||||
private FileStorageManager fileStorageManager;
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<FilePartResult> filePartInit(FilePartInitParam param) throws ServiceException {
|
||||
PartInitDTO dto = (PartInitDTO)BeanCopyUtils.copyProperties((Object)param, PartInitDTO.class);
|
||||
try {
|
||||
PartInitResultDTO partInitResultDTO = this.filePartManager.init(dto);
|
||||
return CloudwalkResult.success((Object)BeanCopyUtils.copyProperties((Object)partInitResultDTO, FilePartResult.class));
|
||||
}
|
||||
catch (DavinciServiceException e) {
|
||||
this.logger.error("\u5206\u7247\u4e0a\u4f20\u6587\u4ef6\u521d\u59cb\u5316\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<FilePartResult> filePartAppend(FilePartAppendParam param) throws ServiceException {
|
||||
try {
|
||||
String filePrefix = "partFile";
|
||||
PartInitResultDTO partInitResultDTO = this.filePartManager.append(param.getFilePath(), param.getPartNumber(), param.getUploadId(), this.buildMultipartFile("partFile" + param.getPartNumber(), (byte[])param.getContent()));
|
||||
return CloudwalkResult.success((Object)BeanCopyUtils.copyProperties((Object)partInitResultDTO, FilePartResult.class));
|
||||
}
|
||||
catch (DavinciServiceException e) {
|
||||
this.logger.error("\u5206\u7247\u4e0a\u4f20\u6587\u4ef6\u8ffd\u52a0\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
@CloudwalkParamsValidate
|
||||
public CloudwalkResult<String> filePartFinish(FilePartFinishParam param) throws ServiceException {
|
||||
PartFinishDTO dto = (PartFinishDTO)BeanCopyUtils.copyProperties((Object)param, PartFinishDTO.class);
|
||||
try {
|
||||
return CloudwalkResult.success((Object)this.filePartManager.finish(dto));
|
||||
}
|
||||
catch (DavinciServiceException e) {
|
||||
this.logger.error("\u5206\u7247\u4e0a\u4f20\u6587\u4ef6\u7ed3\u675f\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
public CloudwalkResult<String> getFileBase64(String path) throws ServiceException {
|
||||
try {
|
||||
return CloudwalkResult.success((Object)this.fileStorageManager.getFileBase64(path));
|
||||
}
|
||||
catch (DavinciServiceException e) {
|
||||
this.logger.error("\u83b7\u53d6\u6587\u4ef6BASE64\u7f16\u7801\u5931\u8d25\uff0c\u539f\u56e0\uff1a", (Throwable)e);
|
||||
throw new ServiceException((Throwable)e);
|
||||
}
|
||||
}
|
||||
|
||||
private MultipartFile buildMultipartFile(final String fileName, final byte[] bytes) {
|
||||
MultipartFile file = new MultipartFile(){
|
||||
|
||||
public String getName() {
|
||||
return "file";
|
||||
}
|
||||
|
||||
public String getOriginalFilename() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return bytes.length == 0;
|
||||
}
|
||||
|
||||
public long getSize() {
|
||||
return bytes.length;
|
||||
}
|
||||
|
||||
public byte[] getBytes() throws IOException {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public InputStream getInputStream() throws IOException {
|
||||
return new ByteArrayInputStream(bytes);
|
||||
}
|
||||
|
||||
public void transferTo(File dest) throws IOException, IllegalStateException {
|
||||
FileCopyUtils.copy((byte[])bytes, (File)dest);
|
||||
}
|
||||
};
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
Summary for /tmp/crk_lib_extract_6o_f40r3/ninca-crk-access-control-service-2.9.1_210630-SNAPSHOT.jar
|
||||
Decompiled with CFR 0.152
|
||||
Reference in New Issue
Block a user