Browse Source

Merge branch 'feature/visit_zhy' into dev

dev
zhangyuan 3 years ago
parent
commit
ce1b358cc4
  1. 6
      epmet-plugins-common/src/main/java/com/epmet/plugin/commons/redis/RedisKeys.java
  2. 5
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/DhTokenDTO.java
  3. 29
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhCardPageFormDTO.java
  4. 23
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhChannelPageFormDTO.java
  5. 27
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhDeptFormDTO.java
  6. 29
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhIdentityFormDTO.java
  7. 23
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhLoginPassFormDTO.java
  8. 22
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonCardListFormDTO.java
  9. 22
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonDelFormDTO.java
  10. 25
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonPageFormDTO.java
  11. 27
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPlanFormDTO.java
  12. 25
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPlanPageFormDTO.java
  13. 21
      epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPublicKeyFormDTO.java
  14. 33
      epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml
  15. 17
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/config/DhCloudProperties.java
  16. 1
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/controller/VisitVisitorController.java
  17. 10
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/service/VisitVisitorService.java
  18. 20
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/service/impl/VisitVisitorServiceImpl.java
  19. 353
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/utils/DhDeviceUtil.java
  20. 1
      epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml

6
epmet-plugins-common/src/main/java/com/epmet/plugin/commons/redis/RedisKeys.java

@ -23,21 +23,21 @@ public class RedisKeys {
* 海康accessToken
*/
public static String getHikTokenKey() {
return "hik:token";
return rootPrefix.concat("hik:token");
}
/**
* 大华publicKey
*/
public static String getDhPublicKey() {
return "dh:public";
return rootPrefix.concat("dh:public");
}
/**
* 大华token
*/
public static String getDhToken() {
return "dh:token";
return rootPrefix.concat("dh:token");
}
}

5
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/utils/DhToken.java → epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/DhTokenDTO.java

@ -1,8 +1,7 @@
package com.epmet.plugin.power.modules.visit.utils;
package com.epmet.plugin.power.dto.visit;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
@ -13,7 +12,7 @@ import java.io.Serializable;
* @since v1.0.0 2022-04-22
*/
@Data
public class DhToken implements Serializable {
public class DhTokenDTO implements Serializable {
private static final long serialVersionUID = 1L;

29
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhCardPageFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhCardPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String personCode;
private String cardNumber;
private String cardStatus;
}

23
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhChannelPageFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhChannelPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
}

27
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhDeptFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.plugin.power.dto.visit.form;
import com.epmet.plugin.power.dto.visit.result.DhChannelResultDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhDeptFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private String description;
private Long parentId;
}

29
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhIdentityFormDTO.java

@ -0,0 +1,29 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhIdentityFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String name;
private Double subsidyAmount;
private Integer isCashRecharge;
private Integer isMachineRecharge;
private String description;
}

23
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhLoginPassFormDTO.java

@ -0,0 +1,23 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhLoginPassFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String loginName;
private String loginPass;
}

22
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonCardListFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonCardListFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<DhPersonCardFormDTO> objectList;
}

22
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonDelFormDTO.java

@ -0,0 +1,22 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonDelFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private List<Integer> personIds;
}

25
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPersonPageFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPersonPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String code;
}

27
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPlanFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPlanFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String detail;
private String memo;
private String name;
private Integer type;
}

25
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPlanPageFormDTO.java

@ -0,0 +1,25 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPlanPageFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Integer pageNum;
private Integer pageSize;
private String singleCondition;
}

21
epmet-plugins-module/pli-power-base/pli-power-base-client/src/main/java/com/epmet/plugin/power/dto/visit/form/DhPublicKeyFormDTO.java

@ -0,0 +1,21 @@
package com.epmet.plugin.power.dto.visit.form;
import lombok.Data;
import java.io.Serializable;
/**
* 海康社区人员信息下放
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-05-20
*/
@Data
public class DhPublicKeyFormDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String loginName;
}

33
epmet-plugins-module/pli-power-base/pli-power-base-server/pom.xml

@ -175,8 +175,9 @@
<hik.cloud.client>111</hik.cloud.client>
<hik.cloud.secret>222</hik.cloud.secret>
<!--大华-->
<dh.cloud.url>https://api2.hik-cloud.com</dh.cloud.url>
<dh.cloud.loginName>111</dh.cloud.loginName>
<dh.cloud.url>http://112.6.213.175:8314</dh.cloud.url>
<dh.cloud.loginName>shundeju</dh.cloud.loginName>
<dh.cloud.loginPass>hg123456</dh.cloud.loginPass>
</properties>
</profile>
<profile>
@ -190,10 +191,10 @@
<!-- 数据库配置-->
<spring.datasource.druid.url>
<![CDATA[jdbc:mysql://rm-bp1l2b53j508j1176xo.mysql.rds.aliyuncs.com:3306/epmet_pli_power?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
<![CDATA[jdbc:mysql://192.168.1.140:3306/epmet_pli_power?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai]]>
</spring.datasource.druid.url>
<spring.datasource.druid.username>root</spring.datasource.druid.username>
<spring.datasource.druid.password>Abc@123456</spring.datasource.druid.password>
<spring.datasource.druid.username>epmet_pli_power_user</spring.datasource.druid.username>
<spring.datasource.druid.password>EpmEt-db-UsEr</spring.datasource.druid.password>
<!-- redis配置 -->
<spring.redis.index>0</spring.redis.index>
<spring.redis.host>192.168.1.140</spring.redis.host>
@ -206,7 +207,7 @@
<nacos.config.namespace></nacos.config.namespace>
<nacos.config.group></nacos.config.group>
<nacos.config-enabled>false</nacos.config-enabled>
<nacos.ip>192.168.43.186</nacos.ip>
<nacos.ip>192.168.43.33</nacos.ip>
<!--是否开启服务列表变更监听-->
<nacos.service-list-changed-listening.enable>false</nacos.service-list-changed-listening.enable>
@ -233,8 +234,9 @@
<hik.cloud.client>111</hik.cloud.client>
<hik.cloud.secret>222</hik.cloud.secret>
<!--大华-->
<dh.cloud.url>https://api2.hik-cloud.com</dh.cloud.url>
<dh.cloud.loginName>111</dh.cloud.loginName>
<dh.cloud.url>http://112.6.213.175:8314</dh.cloud.url>
<dh.cloud.loginName>shundeju</dh.cloud.loginName>
<dh.cloud.loginPass>hg123456</dh.cloud.loginPass>
</properties>
</profile>
<profile>
@ -295,8 +297,9 @@
<hik.cloud.client>111</hik.cloud.client>
<hik.cloud.secret>222</hik.cloud.secret>
<!--大华-->
<dh.cloud.url>https://api2.hik-cloud.com</dh.cloud.url>
<dh.cloud.loginName>111</dh.cloud.loginName>
<dh.cloud.url>http://112.6.213.175:8314</dh.cloud.url>
<dh.cloud.loginName>shundeju</dh.cloud.loginName>
<dh.cloud.loginPass>hg123456</dh.cloud.loginPass>
</properties>
</profile>
<profile>
@ -352,8 +355,9 @@
<hik.cloud.client>90688b09bb9d40088f7be404ccb347c7</hik.cloud.client>
<hik.cloud.secret>7b1940707a4240be9c794c5a967a30c9</hik.cloud.secret>
<!--大华-->
<dh.cloud.url>https://api2.hik-cloud.com</dh.cloud.url>
<dh.cloud.loginName>111</dh.cloud.loginName>
<dh.cloud.url>http://112.6.213.175:8314</dh.cloud.url>
<dh.cloud.loginName>shundeju</dh.cloud.loginName>
<dh.cloud.loginPass>hg123456</dh.cloud.loginPass>
</properties>
</profile>
<profile>
@ -412,8 +416,9 @@
<hik.cloud.client>90688b09bb9d40088f7be404ccb347c7</hik.cloud.client>
<hik.cloud.secret>7b1940707a4240be9c794c5a967a30c9</hik.cloud.secret>
<!--大华-->
<dh.cloud.url>https://api2.hik-cloud.com</dh.cloud.url>
<dh.cloud.loginName>111</dh.cloud.loginName>
<dh.cloud.url>http://112.6.213.175:8314</dh.cloud.url>
<dh.cloud.loginName>shundeju</dh.cloud.loginName>
<dh.cloud.loginPass>hg123456</dh.cloud.loginPass>
</properties>
</profile>
</profiles>

17
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/config/DhCloudProperties.java

@ -14,16 +14,22 @@ import org.springframework.context.annotation.Configuration;
public class DhCloudProperties {
/**
* 应用ID
* URL
*/
private String url;
/**
* 应用KEY
* 账号
*/
private String loginName;
/**
* 账号密码
*/
private String loginPass;
public String getUrl() {
return url;
}
@ -40,4 +46,11 @@ public class DhCloudProperties {
this.loginName = loginName;
}
public String getLoginPass() {
return loginPass;
}
public void setLoginPass(String loginPass) {
this.loginPass = loginPass;
}
}

1
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/controller/VisitVisitorController.java

@ -86,6 +86,7 @@ public class VisitVisitorController {
//效验数据
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
visitVisitorService.visit(dto);
visitVisitorService.doorAuthority(dto);
return new Result();
}

10
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/service/VisitVisitorService.java

@ -89,6 +89,16 @@ public interface VisitVisitorService extends BaseService<VisitVisitorEntity> {
*/
void visit(VisitVisitorFormDTO dto);
/**
* 临时授权
*
* @param dto
* @return void
* @author generator
* @date 2022-07-26
*/
void doorAuthority(VisitVisitorFormDTO dto);
/**
* 人流量
*

20
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/service/impl/VisitVisitorServiceImpl.java

@ -133,6 +133,12 @@ public class VisitVisitorServiceImpl extends BaseServiceImpl<VisitVisitorDao, Vi
insert(entity);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void doorAuthority(VisitVisitorFormDTO dto) {
sendAuth(dto);
}
@Override
@Transactional(rollbackFor = Exception.class)
public List<VisitVisitorChartResultDTO> getTraffic(VisitVisitorChartFormDTO dto) {
@ -150,7 +156,7 @@ public class VisitVisitorServiceImpl extends BaseServiceImpl<VisitVisitorDao, Vi
* @author zhy
* @date 2022/7/28 9:13
*/
private void send(VisitVisitorFormDTO dto) {
private void sendAuth(VisitVisitorFormDTO dto) {
DhPersonFormDTO formDTO = new DhPersonFormDTO();
formDTO.setPaperType("身份证");
formDTO.setPaperNumber(dto.getIdCard());
@ -163,4 +169,16 @@ public class VisitVisitorServiceImpl extends BaseServiceImpl<VisitVisitorDao, Vi
dhDeviceUtil.addPersonAuth(formDTO, dto.getFaceImg());
}
/**
* 删除权限
*
* @param idCard
* @return void
* @author zhy
* @date 2022/7/28 9:13
*/
private void delAuth(String idCard) {
dhDeviceUtil.dataHandle(idCard.substring(idCard.length() - 10));
}
}

353
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/java/com/epmet/plugin/power/modules/visit/utils/DhDeviceUtil.java

@ -11,10 +11,8 @@ import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.plugin.commons.redis.RedisKeys;
import com.epmet.plugin.power.config.DhCloudProperties;
import com.epmet.plugin.power.dto.visit.form.DhAuthFormDTO;
import com.epmet.plugin.power.dto.visit.form.DhPersonCardFormDTO;
import com.epmet.plugin.power.dto.visit.form.DhPersonFormDTO;
import com.epmet.plugin.power.dto.visit.form.DhPersonImgFormDTO;
import com.epmet.plugin.power.dto.visit.DhTokenDTO;
import com.epmet.plugin.power.dto.visit.form.*;
import com.epmet.plugin.power.dto.visit.result.DhChannelResultDTO;
import net.coobird.thumbnailator.Thumbnails;
import org.apache.commons.lang3.StringUtils;
@ -54,9 +52,13 @@ public class DhDeviceUtil {
private final String GET_PERSON_IDENTITY = "/CardSolution/card/person/personidentity";
private final String GET_DOOR_PLAN = "/CardSolution/card/accessControl/timeQuantum/1/page";
private final String GET_DOOR_CHANNEL = "/CardSolution/card/accessControl/channel/bycondition/combined";
private final String ADD_PERSON = " /CardSolution/card/person";
private final String ADD_PERSON = "/CardSolution/card/person";
private final String LIST_PERSON = "/CardSolution/card/person/bycondition/combined";
private final String DEL_PERSON = "/CardSolution/card/person/delete";
private final String ADD_PERSON_IMG = "/CardSolution/common/saveMobileBase64ImageToByte";
private final String ADD_AUTH = "/CardSolution/card/accessControl/doorAuthority/update";
private final String LIST_CARD = "/CardSolution/card/card/bycondition/combined";
private final String DEL_CARD = "/CardSolution/card/card/returnByNumber/";
private final String OPEN_CARD = "/CardSolution/card/card/open/batch";
/**
@ -75,10 +77,13 @@ public class DhDeviceUtil {
}
String url = dhCloudProperties.getUrl().concat(GET_PUBLIC_KEY);
Map<String, Object> paramsMap = new HashMap<>(4);
paramsMap.put("loginName", dhCloudProperties.getLoginName());
Map<String, String> paramsMap = new HashMap<>(4);
DhPublicKeyFormDTO dto = new DhPublicKeyFormDTO();
dto.setLoginName(dhCloudProperties.getLoginName());
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
String data = HttpClientManager.getInstance().sendPost(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败");
}
@ -87,10 +92,10 @@ public class DhDeviceUtil {
if (!toResult.containsKey("publicKey")) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "publicKey获取失败");
}
String accessToken = toResult.get("publicKey").toString();
String publicKey = toResult.get("publicKey").toString();
redisUtils.set(key, accessToken, RedisUtils.MINUTE_THIRTY_EXPIRE);
return accessToken;
redisUtils.set(key, publicKey, RedisUtils.MINUTE_THIRTY_EXPIRE);
return publicKey;
}
/**
@ -101,19 +106,28 @@ public class DhDeviceUtil {
* @author zhy
* @date 2022/5/20 16:40
*/
public DhToken getLoginPass(String publicKey) {
public DhTokenDTO getLoginPass(String publicKey) {
String key = RedisKeys.getDhToken();
Object obj = redisUtils.get(key);
if (null != obj) {
return (DhToken) obj;
return (DhTokenDTO) obj;
}
String url = dhCloudProperties.getUrl().concat(GET_LOGIN_PASS);
Map<String, Object> paramsMap = new HashMap<>(8);
paramsMap.put("loginName", dhCloudProperties.getLoginName());
paramsMap.put("loginPass", publicKey);
Map<String, String> paramsMap = new HashMap<>(4);
DhLoginPassFormDTO dto = new DhLoginPassFormDTO();
dto.setLoginName(dhCloudProperties.getLoginName());
String pwd;
try {
pwd = RSAUtils.getPwdByRsa(publicKey, dhCloudProperties.getLoginPass());
} catch (Exception e) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass加密失败");
}
dto.setLoginPass(pwd);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
String data = HttpClientManager.getInstance().sendPost(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败");
}
@ -122,7 +136,7 @@ public class DhDeviceUtil {
if (!toResult.containsKey("token")) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "loginPass获取失败");
}
DhToken token = new DhToken();
DhTokenDTO token = new DhTokenDTO();
token.setId(toResult.get("id").toString());
token.setLoginName(toResult.get("loginName").toString());
token.setPublicKey(toResult.get("publicKey").toString());
@ -132,7 +146,7 @@ public class DhDeviceUtil {
}
/**
* 查询部门列表
* 新增部门
*
* @param
* @return java.lang.String
@ -144,9 +158,12 @@ public class DhDeviceUtil {
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
Map<String, Object> paramsMap = new HashMap<>(4);
// DhDeptFormDTO dto = new DhDeptFormDTO();
// dto.setName("访客部门");
// dto.setParentId(1L);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败");
@ -158,15 +175,154 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询部门列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
JSONObject jsonObject = jsonArray.getJSONObject(0);
if (null != jsonObject) {
return Long.parseLong(jsonObject.get("deptId").toString());
for (int i = 0; i < jsonArray.size(); i++) {
if ("临时人员".equals(jsonArray.getJSONObject(i).get("name").toString())) {
return Long.parseLong(jsonArray.getJSONObject(i).get("id").toString());
}
}
return null;
}
/**
* 人员预处理
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
public void personHandle(String code) {
String url = dhCloudProperties.getUrl().concat(LIST_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhPersonPageFormDTO dto = new DhPersonPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setCode(code);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询人员列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询人员列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
List<Integer> ids = new ArrayList<>();
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
for (int i = 0; i < jsonArray.size(); i++) {
ids.add(Integer.parseInt(jsonArray.getJSONObject(i).get("id").toString()));
}
if (!ids.isEmpty()) {
DhPersonDelFormDTO del = new DhPersonDelFormDTO();
del.setPersonIds(ids);
delPerson(del);
}
}
/**
* 卡片预处理
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
public void cardHandle(String code) {
String url = dhCloudProperties.getUrl().concat(LIST_CARD);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhCardPageFormDTO dto = new DhCardPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setPersonCode(code);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询卡片列表失败");
}
JSONObject toResult = JSON.parseObject(data);
DhResult result = ConvertUtils.mapToEntity(toResult, DhResult.class);
if (null != toResult.get("success")) {
result.setCode(200);
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询卡片列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
for (int i = 0; i < jsonArray.size(); i++) {
delCard(jsonArray.getJSONObject(i).get("cardNumber").toString());
}
}
/**
* 删除人员
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
public void delPerson(DhPersonDelFormDTO dto) {
String url = dhCloudProperties.getUrl().concat(DEL_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除人员失败");
}
}
/**
* 退卡
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 10:08
*/
public void delCard(String cardNum) {
String url = dhCloudProperties.getUrl().concat(DEL_CARD);
url = url + cardNum;
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "删除卡片失败");
}
return 0L;
}
/**
@ -182,9 +338,14 @@ public class DhDeviceUtil {
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
Map<String, Object> paramsMap = new HashMap<>(4);
// DhIdentityFormDTO dto = new DhIdentityFormDTO();
// dto.setName("访客");
// dto.setSubsidyAmount(0D);
// dto.setIsCashRecharge(1);
// dto.setIsMachineRecharge(1);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
String data = HttpClientManager.getInstance().sendGet(url, paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败");
@ -196,33 +357,39 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
JSONObject jsonObject = jsonArray.getJSONObject(0);
if (null != jsonObject) {
return jsonObject.get("id").toString();
for (int i = 0; i < jsonArray.size(); i++) {
if ("默认身份".equals(jsonArray.getJSONObject(i).get("name").toString())) {
return jsonArray.getJSONObject(i).get("id").toString();
}
}
return "";
}
/**
* 查询开门计划
* 获取开门计划
*
* @param
* @return java.lang.String
* @author zhy
* @date 2022/5/23 11:04
*/
public String getPlan() {
public Long getPlan() {
String url = dhCloudProperties.getUrl().concat(GET_DOOR_PLAN);
String urlParam = getDhUrlParams();
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhPlanPageFormDTO dto = new DhPlanPageFormDTO();
dto.setPageNum(1);
dto.setPageSize(100);
dto.setSingleCondition("默认");
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败");
@ -234,15 +401,19 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询开门计划失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
JSONObject jsonObject = jsonArray.getJSONObject(0);
if (null != jsonObject) {
return jsonObject.get("id").toString();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
if (jsonArray.size() > 0) {
return Long.parseLong(jsonArray.getJSONObject(0).get("id").toString());
}
return "";
return null;
}
/**
@ -259,8 +430,11 @@ public class DhDeviceUtil {
url = url + urlParam;
Map<String, String> paramsMap = new HashMap<>(4);
DhChannelPageFormDTO dto = new DhChannelPageFormDTO();
dto.setPageSize(100);
dto.setPageSize(1);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, StringUtils.EMPTY, paramsMap).getData();
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(dto), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败");
@ -272,17 +446,20 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询通道列表失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONArray jsonArray = JSON.parseArray(registerResult.toString());
List<DhChannelResultDTO> list = new ArrayList<>();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
JSONArray jsonArray = JSON.parseArray(jsonObject.get("pageData").toString());
List<DhChannelResultDTO> list = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(0);
JSONObject jsonItem = jsonArray.getJSONObject(0);
DhChannelResultDTO channel = new DhChannelResultDTO();
channel.setPrivilegeType("1");
channel.setResouceCode(jsonObject.get("channelCode").toString());
channel.setResouceCode(jsonItem.get("channelCode").toString());
list.add(channel);
}
@ -298,17 +475,20 @@ public class DhDeviceUtil {
* @date 2022/5/23 11:04
*/
public Long addPerson(DhPersonFormDTO dto) {
// 数据预处理
dataHandle(dto.getCode());
String url = dhCloudProperties.getUrl().concat(ADD_PERSON);
String urlParam = getDhUrlParams();
url = url + urlParam;
Long deptId = getDept();
if (0L == deptId) {
return null;
if (null == deptId) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询临时人员部门失败");
}
String identity = getIdentity();
if (StringUtils.isBlank(identity)) {
return null;
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取身份失败");
}
dto.setDeptId(deptId);
dto.setPersonIdentityId(identity);
@ -327,12 +507,11 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败");
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "新增人员失败!" + result.getErrMsg());
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
if (null != jsonObject) {
return Long.parseLong(jsonObject.toString());
if (null != registerResult) {
return Long.parseLong(registerResult.toString());
}
return null;
}
@ -368,14 +547,10 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败");
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
if (null != jsonObject) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员头像失败!" + result.getErrMsg());
} else {
return "success";
}
return "";
}
/**
@ -389,8 +564,10 @@ public class DhDeviceUtil {
public String addPersonCard(DhPersonFormDTO dto) {
Long personId = addPerson(dto);
if (personId == null) {
return "添加人员信息失败";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "添加人员信息失败");
}
DhPersonCardListFormDTO cardListFormDTO = new DhPersonCardListFormDTO();
List<DhPersonCardFormDTO> cardList = new ArrayList<>();
DhPersonCardFormDTO cardFormDTO = new DhPersonCardFormDTO();
String url = dhCloudProperties.getUrl().concat(OPEN_CARD);
String urlParam = getDhUrlParams();
@ -412,10 +589,12 @@ public class DhDeviceUtil {
}
cardFormDTO.setCardPassword(pwd);
cardFormDTO.setSubSystems("1");
cardList.add(cardFormDTO);
cardListFormDTO.setObjectList(cardList);
Map<String, String> paramsMap = new HashMap<>(4);
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(cardFormDTO), paramsMap).getData();
String data = HttpClientManager.getInstance().sendPostByJSONAndHeader(url, JSON.toJSONString(cardListFormDTO), paramsMap).getData();
if (null == data) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败");
@ -427,14 +606,10 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败");
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
if (null != jsonObject) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "人员开卡失败!" + result.getErrMsg());
} else {
return cardFormDTO.getCardNumber();
}
return "";
}
/**
@ -447,27 +622,29 @@ public class DhDeviceUtil {
*/
public String addPersonAuth(DhPersonFormDTO dto, String imgUrl) {
String personCard = addPersonCard(dto);
List<DhChannelResultDTO> channel = getChannel();
String plan = getPlan();
if (StringUtils.isBlank(personCard)) {
return "开卡失败";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "开卡失败");
} else if (StringUtils.isNotBlank(imgUrl)) {
addPersonImg(dto, imgUrl);
}
List<DhChannelResultDTO> channel = getChannel();
if (channel.isEmpty()) {
return "获取通道失败";
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取通道失败");
}
if (StringUtils.isBlank(plan)) {
return "获取开门计划失败";
Long plan = getPlan();
if (plan == null) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取开门计划失败");
}
DhAuthFormDTO authFormDTO = new DhAuthFormDTO();
String url = dhCloudProperties.getUrl().concat(ADD_AUTH);
String urlParam = getDhUrlParams();
url = url + urlParam;
authFormDTO.setCardNumber(personCard);
authFormDTO.setTimeQuantumId(plan);
authFormDTO.setTimeQuantumId(plan.toString());
authFormDTO.setCardPrivilegeDetails(channel);
Map<String, String> paramsMap = new HashMap<>(4);
@ -484,14 +661,10 @@ public class DhDeviceUtil {
}
if (!result.getSuccess()) {
logger.info(result.getErrMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败");
}
Object registerResult = result.getData();
JSONObject jsonObject = JSON.parseObject(registerResult.toString());
if (null != jsonObject) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下发人员权限失败!" + result.getErrMsg());
} else {
return "success";
}
return "";
}
/**
@ -503,7 +676,7 @@ public class DhDeviceUtil {
* @date 2022/7/28 16:09
*/
private String getDhUrlParams() {
DhToken token = getLoginPass(getPublicKey());
DhTokenDTO token = getLoginPass(getPublicKey());
return "?userId=" + token.getId() + "&username=" + token.getLoginName() + "&token=" + token.getToken();
}
@ -585,5 +758,19 @@ public class DhDeviceUtil {
return sb.toString().toUpperCase();
}
/**
* 退卡然后删除人员
*
* @param code
* @return void
* @author zhy
* @date 2022/8/3 10:48
*/
public void dataHandle(String code) {
// 先退卡
cardHandle(code);
// 再删人员
personHandle(code);
}
}

1
epmet-plugins-module/pli-power-base/pli-power-base-server/src/main/resources/bootstrap.yml

@ -136,6 +136,7 @@ dh:
cloud:
url: @dh.cloud.url@
loginName: @dh.cloud.loginName@
loginPass: @dh.cloud.loginPass@
# 停机选项
shutdown:

Loading…
Cancel
Save