package com.engine.htsc.seal.xctoeseal.dao;

import com.engine.integration.util.StringUtils;
import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.DBTools;
import weaver.interfaces.htsc.GlobatTools.JAVATools;
import weaver.interfaces.htsc.comInfo.PropBean;
import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName XcCreateWfDao
 * @Author K1810015
 * @Date 2022/3/3 16:53
 * Version 1.0
 */
public class XcCreateWfDao {

    /**
     * @title getyzbh
     * @author K1810015
     * @updateTime 2022/3/11 14:46
     * @Remark  根据印章编号获取印章id
     * @throws
     */
    public static String getyzbh(String yzbh){
        if(StringUtils.isBlank(yzbh)){
            return "";
        }
        String sql="select id from uf_yinzhang where 1=1 ";
        Map<String,String> wheremap=new HashMap<>(1);
        wheremap.put("yzbh",yzbh);
        JAVATools.SetCmdwritelog("用印编号转id"+sql+" yzbh:"+yzbh);
        Map<String,Object> map=JAVATools.GetTableToMap(sql,wheremap);
        if(map==null || map.size()<=0){
            return "";
        }

        return Util.null2String(map.get("id"));
    }

    /**
     * @title getFileInfo
     * @author K1810015
     * @updateTime 2022/3/11 14:46
     * @Remark  获取附件信息
     * @throws
     */
    public static Map<String,Object> getFileInfo(String docid){
        if(StringUtils.isBlank(docid)){
            return null;
        }
        String xcoa=new PropBean().getPropName("xcoa.datasource");

        String sql =" select t.maincategory,docsubject,t.subcategory,t.seccategory,t.docextendname,l.imagefilename,p.imagefileid,t.doctype,p.filesize,\n" +
                " l.docfiletype,p.imagefiletype,t.doccreaterid ,p.imagefileused,p.filerealpath,p.iszip,p.filesize,p.tokenkey,p.ftpconfigid,p.isaesencrypt,p.aescode \n" +
                " from docdetail t\n" +
                " inner join docimagefile l on l.docid = t.id\n" +
                " inner join imagefile p on p.imagefileid = l.imagefileid\n" +
                " where docid="+docid+" and versionid IN(select max(versionid) from DocImageFile where docid="+docid+" ) ";
        JAVATools.SetCmdwritelog("查看信创环境下附件的sql"+sql);
       return DBTools.othersqltomap(xcoa,sql);
    }


}
