fs-danaus
2023-06-16 b2156e90e361afd9746eb9c491cb2f235c65de98
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
package com.yc.action.conmmons;
 
import com.yc.multiData.SpObserver;
import com.yc.service.commons.SqlQueryIfc;
import com.yc.service.impl.DBHelper;
import com.yc.service.panel.SystemSettingsDao;
import com.yc.utils.ResponseUtils;
import com.yc.utils.SessionKey;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
 
 
 
/**
 * 
 * @author heqing.hbs@gmail.com
 * @updatedBy
 * @updateTime 2011-5-26 下午05:15:34
 */
@Controller
public class GformAction{
    
    @Autowired
    SqlQueryIfc sqlQueryIfc;
     @Autowired
    SystemSettingsDao sDao;
    
    //检查功能号是否存折函数
    @RequestMapping("/existsFormid.do")
    public void repace(HttpServletRequest request,HttpServletResponse response) throws IOException{
        String str_formid = request.getParameter("formid");
        String flg = request.getParameter("flg");
        String str_doc = str_formid.replaceAll("[^a-zA-Z].+$", "");
        if(StringUtils.isBlank(str_formid))return;
        Map<String, Object> map=null;
         Map<String, Object> dMap=null;
        boolean bol=("".equals(str_doc)?false:true);
        int formId = -1;
        try{
            formId = Integer.parseInt(str_formid);
        }catch(Exception e){
            map=sqlQueryIfc.queryForMap("select formid,codeFlag from gdoctype where codeFlag=?",str_doc);
            if (map==null||map.size()<1) {return;}
            formId=DBHelper.getValueInt(map, "formid");
        }        
        List<Map<String,Object>> list =null;
        //----开发者用户增加判断是否有打开功能号权限  by danaus 2022/4/23 10:25
        String noTdeveSql="";
        if(!"DeveloperUser".equalsIgnoreCase(request.getSession().getAttribute(SessionKey.USERTYPE)+"")){
            noTdeveSql=" and exists(select top 1 formid from gform where formid="+formId+" and isnull(isAuthorizedForDeveloperUser,0)=0)";
        }
        //-----
         try{
            SpObserver.setDBtoInstance("_"+request.getSession().getAttribute(SessionKey.DATA_BASE_ID));
                 if(flg!=null){
                      list=sqlQueryIfc.queryForList("select menuname,formtype,query_string from _sysmenu where formid=? and actived=1 "+noTdeveSql, formId);
                  }else{
                      list=sqlQueryIfc.queryForList("select menuname,formtype,query_string from _sysmenu where formid=? "+noTdeveSql, formId);
                 }
                 if(bol){
                      Map<String, Object> hmap = sDao.getFormIdInTable(DBHelper.getValueInt(map, "formid"));
                      dMap=sqlQueryIfc.queryForMap("select doccode as query_string from "+DBHelper.getValue(hmap, "hdtable")+" where doccode=?", str_formid);                      
                 }
         }finally{
             SpObserver.setDBtoInstance();
         }
        int formtype = -1;
        String info ="{";
        if(list.size()>0){
            try{
                formtype = (Integer)list.get(0).get("formtype");
            if (bol) {
                switch ((Integer)list.get(0).get("formtype")) {
                case 9:
                    formtype=5;
                    break;
                case 17:
                    formtype=16;
                    break;
                case 15://在功能号输入框填写单号不跳转到对应单号的问题(8类型)xin 2018-10-12 10:18:54
                    formtype=8;
                    break;
                case 497:
                    formtype=496;
                    break;
 
                default:
                    break;
                }                
             }
                info+="\"type\":\""+formtype+"\",\"menuname\":\""
                     +list.get(0).get("menuname")+"\",";
                info+=(!bol?"\"query_string\":\""+(list.get(0).get("query_string")==null?"":
                    list.get(0).get("query_string"))+"\"":"\"query_string\":\"doccode='"+DBHelper.getValue(dMap, "query_string")+"'\","
                            + "\"id\":\""+formId+"\"");                     
            }catch(Exception e){}
        }
        info+="}";
        ResponseUtils.printJson(response, info);
    }
}