package com.yuchen.saas.park.service.util;

import com.alibaba.fastjson.JSON;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.entity.park.PmgBatParkPeople;
import com.yuchen.saas.park.api.entity.park.PmgBatParkVisitor;
import com.yuchen.saas.park.service.util.iot.client.ResourceUtils;

import java.util.HashMap;
import java.util.Map;

public class MianBanJiUtils {

    /**
     * 面板机
     * @param pmgBatParkPeople
     * @return
     */
    public Map<String, Object> mianBanCRUD(PmgBatSmartEquipment smartEquipment, PmgBatParkPeople pmgBatParkPeople, String identify, int cmd) {
        // 封装设备对象
        Map<String, Object> propertySetRequest = new HashMap<>();
        propertySetRequest.put("productKey", smartEquipment.getProductKey());
        propertySetRequest.put("deviceName", smartEquipment.getDeviceName());
        propertySetRequest.put("identify", identify);
        // 封装 params
        Map<String, Object> params = new HashMap<>();
        if(!ResourceUtils.DELETE_FACE_INFO.equals(identify)) {
            params.put("facePhoto_src", pmgBatParkPeople.getImgsrc());
            params.put("user_name", pmgBatParkPeople.getName());
            params.put("card", pmgBatParkPeople.getIdCard());
        }
        params.put("cmd", cmd);
        params.put("user_id", pmgBatParkPeople.getId());

        propertySetRequest.put("params", params);
        System.out.println("REQUEST************:" + JSON.toJSONString(propertySetRequest));
        return propertySetRequest;
    }
    public Map<String, Object>  mianBanCRUDVisitor(PmgBatSmartEquipment smartEquipment,
                                                   PmgBatParkVisitor pmgBatParkVisitor,
                                                   String identify, int cmd) {
        // 封装设备对象
        Map<String, Object> propertySetRequest = new HashMap<String, Object>();
        propertySetRequest.put("productKey", smartEquipment.getProductKey());
        propertySetRequest.put("deviceName", smartEquipment.getDeviceName());
        propertySetRequest.put("identify", identify);
        // 封装 params
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("facePhoto_src", pmgBatParkVisitor.getFaceImg());
        params.put("cmd", cmd);
        params.put("user_name", pmgBatParkVisitor.getName());
        params.put("user_id", pmgBatParkVisitor.getId());
        params.put("card", "身份证号码");
        propertySetRequest.put("params", params);
        System.out.println("REQUEST************:" + propertySetRequest);
        return propertySetRequest;
    }
}
