All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.icc.multiinone.vims.vo.PersonAuthRequest Maven / Gradle / Ivy

The newest version!
package com.dahuatech.icc.multiinone.vims.vo;

import com.dahuatech.icc.brm.model.v202010.card.BrmCard;
import com.dahuatech.icc.brm.model.v202010.card.BrmCardBatchAddRequest;
import com.dahuatech.icc.brm.model.v202010.person.BrmPersonBatchAddRequest;
import com.dahuatech.icc.exception.ClientException;
import com.dahuatech.icc.multiinone.accesscontrol.domain.CardBatchAdd;
import com.dahuatech.icc.multiinone.accesscontrol.domain.PersonBatchAdd;
import com.dahuatech.icc.multiinone.vo.BaseRequest;
import com.dahuatech.icc.util.CollectionUtil;
import com.dahuatech.icc.vims.model.v202207.auth.CardAuthRequest;
import com.dahuatech.icc.vims.model.v202207.auth.FaceAuthRequest;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * program:java-sdk
 *
 * Author: 312013
 * Date:2022-08-16 09:36
 * Description: 人员卡片授权请求类
 */
public class PersonAuthRequest extends BaseRequest {
    //人员信息
    private PersonBatchAdd personInfos;
    //卡片信息
    private CardBatchAdd cardInfos;
    //卡片授权信息
    private CardAuthInfo cardAuthInfo;
    //人像授权信息
    private FaceAuthInfo faceAuthInfo;

    public BrmPersonBatchAddRequest parseToBrmPersonBatchAddRequest(){
        BrmPersonBatchAddRequest brmPersonBatchAddRequest = null;

        try{
            brmPersonBatchAddRequest = BrmPersonBatchAddRequest.builder().personList(this.getPersonInfos().getPersonList()).build();
            brmPersonBatchAddRequest.setService(this.getPersonInfos().getService());
        }catch (ClientException e){
            e.printStackTrace();
        }
        return brmPersonBatchAddRequest;


    }

    public BrmCardBatchAddRequest parseToBrmCardBatchAddRequest(){
        BrmCardBatchAddRequest brmCardBatchAddRequest = null;
        try {
            List cardList = this.cardInfos.getCardList();
            List personList = this.personInfos.getPersonList();

            final Map cardNumberMap = new HashMap();
            for(BrmCard brmCard : cardList){cardNumberMap.put(brmCard.getCardNumber(), brmCard);}

            for(BrmPersonBatchAddRequest.PersonBatchData personBatchData : personList){
                List personCardNumbers = personBatchData.getCardNumbers();
                if(!CollectionUtil.isEmpty(personCardNumbers)){
                    for(String personCardNumber : personCardNumbers) {
                        if(cardNumberMap.containsKey(personCardNumber)){
                            //设置卡片对应的人员id
                            cardNumberMap.get(personCardNumber).setPersonId(personBatchData.getId());
                        }
                    }
                }
            }
            List brmCards = new ArrayList();
            for(BrmCard brmCard : cardNumberMap.values()) {
                brmCards.add(brmCard);
            }
            this.cardInfos.setCardList(brmCards);
            brmCardBatchAddRequest = BrmCardBatchAddRequest.builder().cardList(this.cardInfos.getCardList()).build();
            brmCardBatchAddRequest.setFieldExt(this.getCardInfos().getFieldExt());
            return brmCardBatchAddRequest;
        }catch (ClientException clientException){
            clientException.printStackTrace();
        }
        return brmCardBatchAddRequest;
    }

    public CardAuthRequest converToCardAuthRequest(){
        CardAuthRequest cardAuthRequest = null;

        cardAuthRequest = new CardAuthRequest();
        cardAuthRequest.setGroups(this.getCardAuthInfo().getGroups());
        cardAuthRequest.setCardDevRels(this.getCardAuthInfo().getCardDevRels());
        cardAuthRequest.setCards(this.getCardAuthInfo().getCards());
        return cardAuthRequest;
    }

    public FaceAuthRequest converToFaceAuthRequest(){
        FaceAuthRequest faceAuthRequest = null;
        faceAuthRequest = new FaceAuthRequest();
        faceAuthRequest.setFaceDevRels(this.getFaceAuthInfo().getFaceDevRels());
        faceAuthRequest.setGroups(this.getFaceAuthInfo().getGroups());
        faceAuthRequest.setOwners(this.getFaceAuthInfo().getOwners());
        return faceAuthRequest;
    }

    public PersonBatchAdd getPersonInfos() {
        return personInfos;
    }

    public void setPersonInfos(PersonBatchAdd personInfos) {
        this.personInfos = personInfos;
    }

    public CardBatchAdd getCardInfos() {
        return cardInfos;
    }

    public void setCardInfos(CardBatchAdd cardInfos) {
        this.cardInfos = cardInfos;
    }

    public CardAuthInfo getCardAuthInfo() {
        return cardAuthInfo;
    }

    public void setCardAuthInfo(CardAuthInfo cardAuthInfo) {
        this.cardAuthInfo = cardAuthInfo;
    }

    public FaceAuthInfo getFaceAuthInfo() {
        return faceAuthInfo;
    }

    public void setFaceAuthInfo(FaceAuthInfo faceAuthInfo) {
        this.faceAuthInfo = faceAuthInfo;
    }

//    public class CardAuthInfo {
//      private List cards;
//      private Map> groups;
//      private Map> cardDevRels;
//
//        public List getCards() {
//            return cards;
//        }
//
//        public void setCards(List cards) {
//            this.cards = cards;
//        }
//
//        public Map> getGroups() {
//            return groups;
//        }
//
//        public void setGroups(Map> groups) {
//            this.groups = groups;
//        }
//
//        public Map> getCardDevRels() {
//            return cardDevRels;
//        }
//
//        public void setCardDevRels(Map> cardDevRels) {
//            this.cardDevRels = cardDevRels;
//        }
//    }

//    public class FaceAuthInfo {
//        private List owners;
//        private Map> groups;
//        private Map> faceDevRels;
//
//        public List getOwners() {
//            return owners;
//        }
//
//        public void setOwners(List owners) {
//            this.owners = owners;
//        }
//
//        public Map> getGroups() {
//            return groups;
//        }
//
//        public void setGroups(Map> groups) {
//            this.groups = groups;
//        }
//
//        public Map> getFaceDevRels() {
//            return faceDevRels;
//        }
//
//        public void setFaceDevRels(Map> faceDevRels) {
//            this.faceDevRels = faceDevRels;
//        }
//    }

    public void businessValid() {

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy