package com.engine.htsc.system.service.impl;
import com.engine.core.impl.Service;
import com.engine.htsc.system.dao.WfAttentionTypeSetDao;
import com.engine.htsc.system.entity.Workflow_attentionTypeSet;
import com.engine.htsc.system.service.WfAttentionTypeSetService;
import com.engine.integration.util.StringUtils;
import weaver.general.BaseBean;
import weaver.general.StringUtil;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.JAVATools;
import weaver.interfaces.htsc.comInfo.PropBean;

import java.util.Map;

/**
 * @ClassName WfAttentionTypeSetServiceImpl
 * @Author K1810015
 * @Date 2022/2/14 11:33
 * Version 1.0
 */
public class WfAttentionTypeSetServiceImpl extends Service implements WfAttentionTypeSetService {

    @Override
    public String getAttentionTypeSet(Map<String, Object> map) {
        String value="";
        if(map==null || map.size()<=0) {
            return value;
        }
        int userid= Util.getIntValue(Util.null2String(map.get("userid")));
        String showname= Util.null2String(map.get("showname"));
        if(0>userid || StringUtils.isBlank(showname)){
            return  value;
        }
        //id
        value= WfAttentionTypeSetDao.getUsertolabelname(map);
        if(StringUtils.isBlank(value)){
            boolean flag=false;
            String operatedate = TimeUtil.getCurrentDateString();
            String operatetime = TimeUtil.getOnlyCurrentTimeString();
            String colorvalue=new PropBean().getPropName("jgxt.label.color");
          //如果是空的情况先添加
            Workflow_attentionTypeSet workflowattentionTypeSet=new Workflow_attentionTypeSet();
            workflowattentionTypeSet.setShowname(showname);
            workflowattentionTypeSet.setUserid(userid);
            workflowattentionTypeSet.setColorval(colorvalue);
            workflowattentionTypeSet.setUsertype(0);
            workflowattentionTypeSet.setShoworder(-1);
            workflowattentionTypeSet.setOperatedate(operatedate);
            workflowattentionTypeSet.setOperatetime(operatetime);
            try {
                //建表插入数据 成功了true 失败了false
                flag=workflowattentionTypeSet.create();
            }catch (Exception e){
                JAVATools.SetCmdwritelog("监管协同标签写入失败"+"Params:"+workflowattentionTypeSet.toString());
            }
            if(!flag){
                //id
                return value;
            }
            //id
            value= WfAttentionTypeSetDao.getUsertolabelname(map);
        }
        return value;
    }

    @Override
    public String getAttentionTypeSettoName(Map<String, Object> map) {
        String value="";
        if(map==null || map.size()<=0) {
            return value;
        }
        int userid= Util.getIntValue(Util.null2String(map.get("userid")));
        String showname= Util.null2String(map.get("showname"));
        if(0>userid || StringUtils.isBlank(showname)){
            return  value;
        }
        value= WfAttentionTypeSetDao.getUsertolabelname(map);
        return value;

    }
}
