xinyb
2024-08-30 f5cc47742dd3d2f2ffd8443ffc82a912683f7824
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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);
    }        
}