package com.sw.mes.yb.ipc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.sw.mes.base.system.entity.DictionaryItem;
import com.sw.mes.base.system.service.DictionaryItemService;
import com.sw.mes.utils.EAPHttpUtil;
import com.sw.mes.yb.ipc.dto.ButtonClickDto;
import com.sw.mes.yb.ipc.service.IBaseButtonHandler;

/**
 * 漏硅焖锅 点击处理
 * @author 李儒
 *
 */
@Service
@Transactional
public class LgmgClickServiceImpl implements IBaseButtonHandler {

	@Autowired
    private DictionaryItemService dictionaryItemService;

	@Override
	public Object execute(ButtonClickDto dto) throws Exception {
		//自动添加操作记录 已添加 无业务处理
		if (dto.getButtonName().equals("漏硅焖锅")) {

			DictionaryItem dic = dictionaryItemService.findByThemeValueAndNameAndEnable("EapApi", "EapUser", true);

			try {
				String params = "{\"deviceCode\":\""+dto.getEquipmentCode()+"\",\"key\":\"equipmentState\",\"value\":\"漏硅焖锅\"}";
				String result = EAPHttpUtil.post(dic.getValue(), params, 1000);
			}catch (Exception e) {
			}


		}
		return null;
	}

	@Override
	public void writeWorkHours(ButtonClickDto dto) {
		//不记录工时 懒得写了
	}

}
