编码 解码

jbxx_word.jsp

 

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/public/biz/include/taglibs.jsp"%>
<%@page import="com.css.yj.yjzs.ctrlCommon.UserInfoUtility"%>
<html>
<title>生成word的界面</title>
<meta name="path" content="jsp/yjzs/yjzsProd/jbxt/jbxx_word.jsp" />
<meta name="description" content="" />

<%
UserInfoUtility commUI = new UserInfoUtility(request,response);
String serverIpAndPort = commUI.getServerIpAndPort();  //获取服务器地址和端口
%>
<head>
<%@ include file="/public/biz/include/header.jsp"%>
<meta name="path"  />
<style>
.myButton {
 border: 1px solid #90bceb;
 height: 28px;
 width: 120px;
 font-family: "宋体";
 font-size: 20;
}
</style>
<SCRIPT LANGUAGE="JavaScript">
var kongJianExist = "yes";  //声明一个变量,判断word控件是否存在,先假设其存在
function initPage(){
 try{
     insToMark1();
    }catch(e){
     kongJianExist = "no";  //如果捕获到异常,说明word控件不存在,将变量kongJianExist的值设置为no
     navigatePageWithoutControls();
    }
}

//如果没有安装控件,就跳转到安装控件的页面
function navigatePageWithoutControls(){
    alert("本机未安装控件,请安装后使用");
 window.location("/public/biz/default/yjzs/wordDep/download/reg.htm");
}

function insToMark1(){
 document.all.DSOFramer1.Toolbars = true;
    document.all.DSOFramer1.Menubar = true;
    document.all.DSOFramer1.Titlebar = false;
 
    
 var jzps = document.getElementById("jzps").innerHTML;
 jzps = jzps.replace(new RegExp("<br>","gm"),"");
 jzps=jzps.replace(new RegExp("&amp;","gm"),"&");
 
 var zgjzps = document.getElementById("zgjzps").innerHTML;
 zgjzps = zgjzps.replace(new RegExp("<br>","gm"),"");
 zgjzps=zgjzps.replace(new RegExp("&amp;","gm"),"&");
 
 var nbyj = document.getElementById("nbyj").innerHTML;
 nbyj = nbyj.replace(new RegExp("<br>","gm"),"");
 nbyj=nbyj.replace(new RegExp("&amp;","gm"),"&");
 
 var clqk = document.getElementById("clqk").innerHTML;
 clqk = clqk.replace(new RegExp("<br>","gm"),"");
 clqk=clqk.replace(new RegExp("&amp;","gm"),"&");
 
 var jbnr = document.getElementById("jbnr").innerHTML;
 jbnr = jbnr.replace(new RegExp("<br>","gm"),"");
 jbnr=jbnr.replace(new RegExp("&amp;","gm"),"&");
 
 var xxqh = document.getElementById('xxqh').value;
 var jbrxm = document.getElementById('jbrxm').value;
 var jbdh = document.getElementById('jbdh').value;
 var jbrmz = document.getElementById('jbrmz').value;
 var jbsj = document.getElementById('jbsj').value;
 
 document.all.DSOFramer1.Open("<%=serverIpAndPort%><%=request.getContextPath()%>/jsp/yjzs/yjzsProd/word/jbxxbg.doc",false, "Word.Document");
 document.all.DSOFramer1.SetFieldValue("xxqh",xxqh,"");//编号
 document.all.DSOFramer1.SetFieldValue("jbrxm",jbrxm,"");//举报人姓名
 document.all.DSOFramer1.SetFieldValue("jbdh",jbdh,"");//举报人电话
 document.all.DSOFramer1.SetFieldValue("jbrmz",jbrmz,"");//接报人姓名
 document.all.DSOFramer1.SetFieldValue("jbsj",jbsj,"");//接报时间
 document.all.DSOFramer1.SetFieldValue("jbnr",jbnr,"");//举报内容
 
 document.all.DSOFramer1.SetFieldValue("jzps",jzps,"");//局长批示
 document.all.DSOFramer1.SetFieldValue("zgjzps",zgjzps,"");//主管局长批示
 document.all.DSOFramer1.SetFieldValue("nbyj",nbyj,"");//拟办意见
 document.all.DSOFramer1.SetFieldValue("clqk",clqk,"");//处理情况
 
 document.all.DSOFramer1.ShowView(3);
}


var timesOfClicking=0;
function saveWord(){
 var flagWordSuccessOrNot = fileUpload1();  //flagWordSuccessOrNot为word是否保存成功的标记
 if(flagWordSuccessOrNot!="flagWordSaveSuccess"){
  alert("保存失败");
  setTimeout("processParent()",1000);
 }else{
  document.all.DSOFramer1.close();
  alert("保存成功!");
  window.opener.document.getElementById("zdyb").disabled = false;//"确定"按钮可用
  window.opener.document.getElementById("scword").disabled = true;//"确定"按钮可用
  setTimeout("processParent()",1000);
  
  window.close();
 }
}
function processParent(){
 window.close();
}
function fileUpload1(){
 document.all.DSOFramer1.HttpInit();
 //上传打开的文件
 timesOfClicking=timesOfClicking+1;
 document.all.DSOFramer1.HttpAddPostCurrFile("file", "jbxxbg.doc");
 document.all.DSOFramer1.HttpAddPostString("blobName","jbxxbg.doc");
 var jzps = document.getElementById("jzps").innerHTML;
 var zgjzps = document.getElementById("zgjzps").innerHTML;
 var nbyj = document.getElementById("nbyj").innerHTML;
 var clqk = document.getElementById("clqk").innerHTML;
 var zby = document.getElementById("zby").value;
 
 var jbssbh = document.getElementById("jbssbh").value;
 var jbxxbh = document.getElementById("jbxxbh").value;
 var phone = document.getElementById("phone").value;
 var qh = document.getElementById("qh").value;
 
 
 document.all.DSOFramer1.HttpAddPostString("jzps",escape(jzps));
 document.all.DSOFramer1.HttpAddPostString("zgjzps",escape(zgjzps));
 document.all.DSOFramer1.HttpAddPostString("nbyj",escape(nbyj));
 document.all.DSOFramer1.HttpAddPostString("clqk",escape(clqk));
 document.all.DSOFramer1.HttpAddPostString("jbssbh",jbssbh);
 document.all.DSOFramer1.HttpAddPostString("phone",phone);
 document.all.DSOFramer1.HttpAddPostString("zby",escape(zby));
 document.all.DSOFramer1.HttpAddPostString("qh",qh);
 document.all.DSOFramer1.HttpAddPostString("jbxxbh",jbxxbh);
 
 //执行上传动作
 var flagPost =document.all.DSOFramer1.HttpPost("<%=serverIpAndPort%><%=request.getContextPath()%>/JbxxCtrl-saveWord.pfv");
 return flagPost;
}


function printWord()
{
 document.all.DSOFramer1.printout();
}

function closeWindow() {
 if(kongJianExist=="yes"){  //假如控件存在的情况,执行保存
  if (timesOfClicking>0){
       return;
  }
  if(confirm("关闭前是否要储存")){
   fileUpload1();
   document.all.DSOFramer1.close();
   alert("保存成功!");
   window.opener.document.getElementById("zdyb").disabled = false;//"确定"按钮可用
   window.opener.document.getElementById("scword").disabled = true;//"确定"按钮可用
   setTimeout("processParent()",1000);
  }
 }else{
  navigatePageWithoutControls();
 }
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" οnlοad="initPage();"  οnbefοreunlοad="javascript:closeWindow();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form name="form1" method="post" action="" enctype="multipart/form-data">
<textarea style="display:none" title="局长批示" id="jzps" name="jzps" value="<c:out value="${jzps}" escapeXml="{false}" />"><c:out value="${jzps}" escapeXml="{false}" /></textarea>
<textarea style="display:none" title="主管局长批示" id="zgjzps" name="zgjzps" value="<c:out value="${zgjzps}" escapeXml="{false}" />"><c:out value="${zgjzps}" escapeXml="{false}" /></textarea>
<textarea style="display:none" title="拟办意见" id="nbyj" name="nbyj" value="<c:out value="${nbyj}" escapeXml="{false}" />"><c:out value="${nbyj}" escapeXml="{false}" /></textarea>
<textarea style="display:none" title="处理情况" id="clqk" name="clqk" value="<c:out value="${clqk}" escapeXml="{false}" />"><c:out value="${clqk}" escapeXml="{false}" /></textarea>
<input type="hidden" title="举报送审信息编号" name="jbssbh" id="jbssbh" value="<c:out value='${jbssbh}'/>">
<input type="hidden" title="电话" name="phone" id="phone" value="<c:out value='${phone}'/>">
<input type="hidden" title="值班员" name="zby" id="zby" value="<c:out value='${zby}'/>">
<input type="hidden" title="期号" name="qh" id="qh" value="<c:out value='${qh}'/>">
<input type="hidden" title="举报信息编号" name="jbxxbh" id="jbxxbh" value="<c:out value='${jbxxbh}'/>">
<input type="hidden" title="编号" name="xxqh" id="xxqh" value="<c:out value='${xxqh}'/>">
<input type="hidden" title="举报人姓名" name="jbrxm" id="jbrxm" value="<c:out value='${jbrxm}'/>">
<input type="hidden" title="举报电话" name="jbdh" id="jbdh" value="<c:out value='${jbdh}'/>">
<input type="hidden" title="接报人姓名" name="jbrmz" id="jbrmz" value="<c:out value='${jbrmz}'/>">
<input type="hidden" title="接报时间" name="jbsj" id="jbsj" dateFormat="YYYY-MM-DD HH:MI:SS" value="<c:out value='${jbsj}'/>">
<textarea style="display:none" title="举报内容" id="jbnr" name="jbnr"><c:out value="${jbnr}" escapeXml="{false}" /></textarea>

<div align="center">
 <input type="button" id="word" class="button"   value="保存" οnclick="javascript:saveWord();"/>
 <input  type="button" id="print" class="button" value="打印" οnclick="javascript:printWord();"  />
 <input  type="button" id="close" class="button" value="关闭" οnclick="window.close()"  />
</div>
</form>
</body>
</html>
<script>
 var s1 = ""
s1 += "<OBJECT id='DSOFramer1' align='middle' style='LEFT: 0px; WIDTH: 100%; TOP: 0px; HEIGHT: 100%'"
s1 += "classid=clsid:00460182-9E5E-11D5-B7C8-B8269041DD57 codeBase=DSOFramer.ocx#Version=2,2,0,6' >"
s1 += "</OBJECT>"
document.write(s1) ;

</script>

 

 

Escape.java

 

package com.css.yj.yjzs.proxyCommon;


public class Escape {
   private final static String[] hex = {
       "00","01","02","03","04","05","06","07","08","09","0A","0B","0C","0D","0E","0F",
       "10","11","12","13","14","15","16","17","18","19","1A","1B","1C","1D","1E","1F",
       "20","21","22","23","24","25","26","27","28","29","2A","2B","2C","2D","2E","2F",
       "30","31","32","33","34","35","36","37","38","39","3A","3B","3C","3D","3E","3F",
       "40","41","42","43","44","45","46","47","48","49","4A","4B","4C","4D","4E","4F",
       "50","51","52","53","54","55","56","57","58","59","5A","5B","5C","5D","5E","5F",
       "60","61","62","63","64","65","66","67","68","69","6A","6B","6C","6D","6E","6F",
       "70","71","72","73","74","75","76","77","78","79","7A","7B","7C","7D","7E","7F",
       "80","81","82","83","84","85","86","87","88","89","8A","8B","8C","8D","8E","8F",
       "90","91","92","93","94","95","96","97","98","99","9A","9B","9C","9D","9E","9F",
       "A0","A1","A2","A3","A4","A5","A6","A7","A8","A9","AA","AB","AC","AD","AE","AF",
       "B0","B1","B2","B3","B4","B5","B6","B7","B8","B9","BA","BB","BC","BD","BE","BF",
       "C0","C1","C2","C3","C4","C5","C6","C7","C8","C9","CA","CB","CC","CD","CE","CF",
       "D0","D1","D2","D3","D4","D5","D6","D7","D8","D9","DA","DB","DC","DD","DE","DF",
       "E0","E1","E2","E3","E4","E5","E6","E7","E8","E9","EA","EB","EC","ED","EE","EF",
       "F0","F1","F2","F3","F4","F5","F6","F7","F8","F9","FA","FB","FC","FD","FE","FF"
   };
   private final static byte[] val = {
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
       0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F
   };
   public static String escape(String s) {
       StringBuffer sbuf = new StringBuffer();
       int len = s.length();
       for (int i = 0; i < len; i++) {
           int ch = s.charAt(i);
           if (ch == ' ') {                        // space : map to '+'
               sbuf.append('+');
           } else if ('A' <= ch && ch <= 'Z') {    // 'A'..'Z' : as it was
               sbuf.append((char)ch);
           } else if ('a' <= ch && ch <= 'z') {    // 'a'..'z' : as it was
               sbuf.append((char)ch);
           } else if ('0' <= ch && ch <= '9') {    // '0'..'9' : as it was
               sbuf.append((char)ch);
           } else if (ch == '-' || ch == '_'       // unreserved : as it was
               || ch == '.' || ch == '!'
               || ch == '~' || ch == '*'
               || ch == '/'' || ch == '('
               || ch == ')') {
               sbuf.append((char)ch);
           } else if (ch <= 0x007F) {              // other ASCII : map to %XX
               sbuf.append('%');
               sbuf.append(hex[ch]);
           } else {                                // unicode : map to %uXXXX
               sbuf.append('%');
               sbuf.append('u');
               sbuf.append(hex[(ch >>> 8)]);
               sbuf.append(hex[(0x00FF & ch)]);
           }
     }
       return sbuf.toString();
   }
   public static String unescape(String s) {
       StringBuffer sbuf = new StringBuffer();
       int i = 0;
       int len = s.length();
       while (i < len) {
           int ch = s.charAt(i);
           if (ch == '+') {                        // + : map to ' '
               sbuf.append(' ');
           } else if ('A' <= ch && ch <= 'Z') {    // 'A'..'Z' : as it was
               sbuf.append((char)ch);
           } else if ('a' <= ch && ch <= 'z') {    // 'a'..'z' : as it was
               sbuf.append((char)ch);
           } else if ('0' <= ch && ch <= '9') {    // '0'..'9' : as it was
               sbuf.append((char)ch);
           } else if (ch == '-' || ch == '_'       // unreserved : as it was
               || ch == '.' || ch == '!'
               || ch == '~' || ch == '*'
               || ch == '/'' || ch == '('
               || ch == ')') {
               sbuf.append((char)ch);
           } else if (ch == '%') {
               int cint = 0;
               if ('u' != s.charAt(i+1)) {         // %XX : map to ascii(XX)
                   cint = (cint << 4) | val[s.charAt(i+1)];
                   cint = (cint << 4) | val[s.charAt(i+2)];
                   i+=2;
               } else {                            // %uXXXX : map to unicode(XXXX)
                   cint = (cint << 4) | val[s.charAt(i+2)];
                   cint = (cint << 4) | val[s.charAt(i+3)];
                   cint = (cint << 4) | val[s.charAt(i+4)];
                   cint = (cint << 4) | val[s.charAt(i+5)];
                   i+=5;
               }
               sbuf.append((char)cint);
           }
           i++;
       }
       return sbuf.toString();
   }
  
   public static void main(String[] args) {
       String stest = "  中文,来了。";
       System.out.println(stest);
       System.out.println(escape(stest));
       //System.out.println(unescape(escape(stest)));
       System.out.println(unescape(unescape("%25u5C40%25u957F%25u6279%25u793A")));
   }
}

 

业务类处理解码:

 

public void saveWord(List<Map> byteList, SwordDao dabo) throws CSSBaseBizCheckedException {

  try {
  Map filedMap = (HashMap) byteList.get(0);
  Map<String, byte[]> fjFileMap = (HashMap<String, byte[]>) (HashMap) byteList.get(1);
  String fjmc = (String) filedMap.get("blobName");
  String jbssbhTmp = (String) filedMap.get("jbssbh");
  //保存送审信息
  ObjectTypeConvert objectTypeConvert = new ObjectTypeConvert();
  IJbxxBiz jbxx = new JbxxBizImpl();
  logger.debug("saveWord jbxxbh is="+filedMap.get("jbxxbh"));
  String jzps = (String) filedMap.get("jzps");
  String zgjzps = (String) filedMap.get("zgjzps");
  String nbyj = (String) filedMap.get("nbyj");
  String clqk = (String) filedMap.get("clqk");
  String zby = (String) filedMap.get("zby");
  logger.debug("jzps is:"+jzps);
  filedMap.put("jzps", Escape.unescape(jzps));
  filedMap.put("zgjzps", Escape.unescape(zgjzps));
  filedMap.put("nbyj", Escape.unescape(nbyj));
  filedMap.put("clqk", Escape.unescape(clqk));
  filedMap.put("zby", Escape.unescape(zby));
  logger.debug("Escape.unescape(jzps) is:"+Escape.unescape(jzps));
  //通过举报送审编号判断是否已经送审过,如果送审过就更新送审信息,若没送审过,保存送审信息。
  String jbssbh = "";
  if("".equals(jbssbhTmp)||jbssbhTmp==null){
   logger.debug("执行保存举报送审信息。");
   ZsJbssBO zsJbssBO = new ZsJbssBO();
   jbssbh = jbxx.getJbssBh(dabo);
   //filedMap.put("jbssbh", jbssbh);
   zsJbssBO = (ZsJbssBO) objectTypeConvert.mapToBO(filedMap, new ZsJbssBO());
   zsJbssBO.setJbssbh(jbssbh);
      //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
   Date date = new Date();
   //String mydate = format.format(date);
   zsJbssBO.setSslrrq(DateUtility.convUtilDateToUtilCalendar(date));
   logger.debug("DateUtility.convUtilDateToUtilCalendar(date):"+DateUtility.convUtilDateToUtilCalendar(date));
   dabo.saveBO(zsJbssBO);
   //同时更新流水号表记录
   logger.debug("saveWord qh is:"+zsJbssBO.getQh());
   Map lshMap = new HashMap();
   lshMap.put("lx", JbxxParams.JBXX_JBBG);
   lshMap.put("lsh", zsJbssBO.getQh());
   this.updateLsh(lshMap,dabo);
  }else{
   ZsJbssBO zsJbssBO = new ZsJbssBO();
   logger.debug("执行编辑举报送审信息。");
   zsJbssBO = (ZsJbssBO) objectTypeConvert.mapToBO(filedMap, new ZsJbssBO());
   dabo.updateBO(zsJbssBO);
   String deleteSql = "delete t_zs_jbfj t where t.xxxh=? ";
   List params = new ArrayList();
   params.add(jbssbhTmp);
   dabo.execute(deleteSql, params);
  }
  //保存word
  logger.debug("开始执行保存举报报告");
  InputStream in = null;
  Iterator<String> iter = fjFileMap.keySet().iterator();
  int fileCount=0;
  while (iter.hasNext()) {
   fileCount=fileCount+1;
   String wjmc = iter.next();
   in = new ByteArrayInputStream((byte[]) fjFileMap.get("fileName-content"+Integer.toString(fileCount)));
   ZsJbfjBO zsJbfjBO = new ZsJbfjBO();
   String fjbh = jbxx.getJbfjBh(dabo);
   if("".equals(jbssbhTmp)||jbssbhTmp==null){
    zsJbfjBO.setXxxh(jbssbh);
   }else{
    zsJbfjBO.setXxxh((String)filedMap.get("jbssbh"));
   }
   zsJbfjBO.setFjmc(fjmc);
   zsJbfjBO.setFjbh(fjbh);
   dabo.saveBO(zsJbfjBO);
   dabo.fillBlob(zsJbfjBO, "fj", in);
  }

  
  } catch (PersistenceCheckedException e) {
    logger.error("异常信息:", e);
    throw new CSSBaseBizCheckedException(1000, e);
  }
  
 
 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值