package com.yc.action.select;
|
|
import java.io.IOException;
|
import java.io.PrintWriter;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpSession;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.dao.DataAccessException;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import com.yc.action.BaseAction;
|
import com.yc.service.panel.select.selectInfoIfc;
|
import com.yc.utils.SessionKey;
|
|
import net.sf.json.JSONArray;
|
|
@Controller
|
public class SelectInfoAction extends BaseAction {
|
@Autowired
|
selectInfoIfc sInfoIfc;
|
HttpSession session = null;
|
private Map<String, Object> map;
|
|
@RequestMapping("/sava38Info.do")
|
public void sava(int formid, int formtype, String value, String select,
|
HttpServletRequest request, HttpServletResponse response)
|
throws IOException {
|
PrintWriter out=response.getWriter();
|
try {
|
session = request.getSession();
|
String usercode = session.getAttribute("@usercode").toString();
|
sInfoIfc.sava(usercode, formid, formtype, value, select);
|
out.print(1);
|
} catch (Exception e) {
|
out.print(e.getMessage());
|
}
|
out.flush();
|
out.close();
|
}
|
|
@RequestMapping("/get38Info.do")
|
public void get(int formid, int formtype,
|
HttpServletRequest request, HttpServletResponse response)
|
throws IOException {
|
session = request.getSession();
|
String usercode = session.getAttribute("@usercode").toString();
|
Map<String, Object> selMap = sInfoIfc.getInfo(usercode, formid,
|
formtype);
|
String retString = "";
|
PrintWriter out = response.getWriter();
|
if (selMap != null) {
|
retString = selMap.get("panelInitValue") + ";pan#"
|
+ selMap.get("selectInitValue");
|
}
|
out.print(retString);
|
out.flush();
|
out.close();
|
}
|
|
/**
|
* \43控件类型
|
* @param request
|
* @param response
|
*/
|
@RequestMapping("/select43.do")
|
public void getonlineMess(HttpServletRequest request, HttpServletResponse response) {
|
Map<String, String> maps = null;
|
List<Map<String, String>> lis = new ArrayList<Map<String, String>>();
|
String date = "";
|
int cont = 0;
|
try {
|
HttpSession session = request.getSession();
|
String userCode = (String) session.getAttribute(SessionKey.USERCODE);
|
String formid = request.getParameter("formid");
|
formid = (formid == null ? "" : formid);
|
String sql = request.getParameter("sql");
|
sql = (sql == null ? "" : sql);
|
if (sql.equals("")) {
|
this.print(response, "error:43控件缺少SQL语句查询!");
|
return;
|
}
|
List<Map<String, Object>> list = sInfoIfc.getSelect43(userCode, formid, sql);// (sql,
|
// new
|
// Object[]{formid,doccode,userCode});
|
|
for (Map<String, Object> map : list) {
|
maps = new HashMap<String, String>();
|
cont = 0;
|
for (String key : map.keySet()) {
|
if (cont == 0) {
|
maps.put("id", map.get(key).toString());// 获取固定id值
|
} else {
|
maps.put("text", map.get(key).toString());// 获取固定text值
|
}
|
cont++;
|
}
|
lis.add(maps);// 组装
|
}
|
} catch (DataAccessException e) {
|
date = "error:" + e.getCause().getMessage();
|
} catch (Exception e) {
|
date = "error:" + e.getMessage();
|
}
|
date = JSONArray.fromObject(lis).toString();// 转换json
|
this.printJson(response, date);
|
}
|
}
|