package com.zksy.pole.factory.impl;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zksy.pole.domain.po.DgRelayControl;
import com.zksy.pole.domain.po.DgReportEnvironmentalData;
import com.zksy.pole.factory.IHandleCmd;
import com.zksy.pole.mapper.DgRelayControlMapper;
import com.zksy.pole.mapper.DgReportEnvironmentalDataMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HandleDgReportEnvironmentalDataCmd implements IHandleCmd {
    @Autowired
    private DgReportEnvironmentalDataMapper dgReportEnvironmentalDataMapper;
    @Override
    public <T> String HandleCmdMethod(T data) {
        JSONObject obj = JSONUtil.createObj();
        obj.set("cmd",2000);
        obj.set("sersor_id",1);
        try {
            DgReportEnvironmentalData d = (DgReportEnvironmentalData) data;
            dgReportEnvironmentalDataMapper.insert(d);
            return obj.toString();
        } catch (Exception e) {
            return obj.toString();
        }
    }
}