package com.engine.htsc.wdzx.dao;


import weaver.general.Util;
import weaver.interfaces.htsc.GlobatTools.DBTools;
import weaver.interfaces.htsc.GlobatTools.Uploadcory;
import weaver.interfaces.htsc.util.UploadDocUtil;
import weaver.messager.UploadUtil;


import java.util.HashMap;
import java.util.Map;


public class GetcchangedetailDao  {

    public static Map<String,String>  getchangfile(String wdzxid){
        Map<String,String> returnmap=new HashMap<>();
       if("".equals(wdzxid)){
           return null;
       }

       String sql2="select t.docid,t.imagefileid,t.imagefilename,t.operatedate,t.operatetime,tf.imagefiletype,tf.filesize from docimagefile t join imagefile tf on t.imagefileid=tf.imagefileid where " +
               "t.docid in   (select wj from  uf_wdzx   where id =? ) ";
       Map<String,Object> map2= DBTools.getsqltomap(sql2,wdzxid);
        if(map2!=null && map2.size()>0){
          Map<String,Integer> map=Uploadcory.coryfile(Util.null2String(map2.get("docid")));
            if(map==null || map.size()<=0){
                return null;
            }
            String docid =Util.null2String(map.get("docid"));
            String imagefileid =Util.null2String(map.get("imagefileid"));
            returnmap.put("docid",docid);
            returnmap.put("imagefileid",imagefileid);
            returnmap.put("imagefilename",Util.null2String(map2.get("imagefilename")));
            returnmap.put("operatedate",Util.null2String(map2.get("operatedate")));
            returnmap.put("operatetime",Util.null2String(map2.get("operatetime")));
            returnmap.put("imagefiletype",Util.null2String(map2.get("imagefiletype")));
            returnmap.put("filesize",Util.null2String(map2.get("filesize")));
            returnmap.put("docimagefile",Util.null2String(map2.get("docimagefile")));

        }
   //     returnmap.put("version",Util.null2String(version)+"版本");
        return returnmap;
    }

    public static String getversion(String wdzxid){
        if("".equals(wdzxid)){
            return "V1";
        }
        int version=1;
       String sql="   select count(*)+1 as countsum from uf_wdzx_dt1 dt1 left join uf_wdzx t on dt1.mainid =t.id where t.id=? ";
       Map<String,Object> map= DBTools.getsqltomap(sql,wdzxid);
       if(map!=null && map.size()>0){
           version=Util.getIntValue(Util.null2String(map.get("countsum")));
       }
        return "V"+ version;
    }
}

