package cn.estsh.i3plus.pojo.mes.model;

import cn.estsh.i3plus.pojo.mes.bean.MesWorkOrder;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import javax.persistence.Transient;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description : 生产工单扩展
 * @Reference :
 * @Author : wangjie
 * @CreateDate : 2020-03-30 13:42
 * @Modify:
 **/
@Data
@Api(value="生产工单扩展",description = "生产工单扩展")
public class MesWorkOrderExtendModel extends MesWorkOrder {

    @Transient
    @ApiParam(value = "扩展数据MAP")
    public Map<String, Object> extendMap;

    public Map<String, Object> getExtendMap() {
        try {
            if (!StringUtils.isEmpty(super.extend)) {
                return JSONObject.parseObject(super.extend, Map.class);
            } else {
                return new HashMap<>();
            }
        } catch (Exception e) {
            return new HashMap<>();
        }
    }

}
