cptcardtabsetop.jsp
7.63 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<%@page import="weaver.conn.RecordSetTrans"%>
<%@page import="weaver.proj.util.LabelUtil"%>
<%@page import="weaver.systeminfo.SystemEnv"%>
<%@page import="weaver.hrm.HrmUserVarify"%>
<%@page import="weaver.hrm.User"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="net.sf.json.JSONArray"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="java.util.*,java.util.regex.*" %>
<jsp:useBean id="rs2" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="CptFieldManager" class="weaver.cpt.util.CptFieldManager" scope="page"/>
<jsp:useBean id="RecordSet" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page"/>
<jsp:useBean id="LabelComInfo" class="weaver.systeminfo.label.LabelComInfo" scope="page" />
<jsp:useBean id="RecordSetTrans" class="weaver.conn.RecordSetTrans" scope="page" />
<jsp:useBean id="BrowserComInfo" class="weaver.workflow.field.BrowserComInfo" scope="page" />
<jsp:useBean id="CptFieldComInfo" class="weaver.cpt.util.CptCardTabComInfo" scope="page" />
<jsp:useBean id="LanguageComInfo" class="weaver.systeminfo.language.LanguageComInfo" scope="page" />
<jsp:useBean id="LabelUtil" class="weaver.proj.util.LabelUtil" scope="page" />
<%
User user=HrmUserVarify.getUser(request, response);
if(user==null){
out.print("[]");
return;
}
int currentLanguageid=user.getLanguage();
String grouptablename="cpt_cptcardtab";
/**
if(!HrmUserVarify.checkUserRight("DeptDefineInfo1:DeptMaintain1", user)){
response.sendRedirect("/notice/noright.jsp");
return;
}**/
boolean isoracle = (RecordSet.getDBType()).equals("oracle") ;
boolean isdb2 = (RecordSet.getDBType()).equals("db2") ;
boolean issqlserver = (RecordSet.getDBType()).equals("sqlserver") ;
String ajax=Util.null2String(request.getParameter("ajax"));
String src = Util.null2String(request.getParameter("src"));
int groupid=0;
String groupnamecn="";
String groupnameen="";
String groupnametw="";
String linkurl="";
String isopen="";
if(src.equals("editgroupbatch")){//批量编辑分组
String dtinfo = Util.null2String(request.getParameter("dtinfo"));
String keepgroupids = Util.null2String(request.getParameter("keepgroupids")).replaceAll("on", "0");
if(keepgroupids.endsWith(",")){
keepgroupids=keepgroupids.substring(0,keepgroupids.length()-1);
}
//System.out.println("dtinfo:"+dtinfo);
JSONArray dtJsonArray=JSONArray.fromObject(dtinfo);
if(dtJsonArray!=null&&dtJsonArray.size()>0){
RecordSet.executeSql("delete from "+grouptablename+" where id not in("+keepgroupids+")");
for(int i=0;i<dtJsonArray.size();i++){
JSONArray dtJsonArray2= JSONArray.fromObject( dtJsonArray.get(i));
if(dtJsonArray2!=null&&dtJsonArray2.size()>=4){
groupnamecn=Util.null2String( dtJsonArray2.getJSONObject(0).getString("groupnamecn"));
groupnameen=Util.null2String( dtJsonArray2.getJSONObject(1).getString("groupnameen"));
groupnametw=Util.null2String( dtJsonArray2.getJSONObject(2).getString("groupnametw"));
linkurl=Util.null2String( dtJsonArray2.getJSONObject(3).getString("linkurl"));
groupid= Util.getIntValue( dtJsonArray2.getJSONObject(4).getString("groupid"),0);
isopen=Util.null2String( dtJsonArray2.getJSONObject(5).getString("isopen"));
if("".equals( isopen)){
isopen="0";
}else{
isopen="1";
}
boolean newlabel=false;
String labelname=7==currentLanguageid?groupnamecn:8==currentLanguageid?groupnameen:9==currentLanguageid?groupnametw:groupnamecn;
int lableid= 0;
RecordSetTrans=new RecordSetTrans();
RecordSetTrans.setAutoCommit(false);
String mysql=""+
" select distinct t2.indexid from HtmlLabelInfo t2 where "+
" exists (select 1 from HtmlLabelInfo t1 where t1.indexid=t2.indexid and t1.labelname='"+groupnamecn+"' and t1.languageid=7) "+
" and exists (select 1 from HtmlLabelInfo t1 where t1.indexid=t2.indexid and t1.labelname='"+groupnameen+"' and t1.languageid=8) "+
" and exists (select 1 from HtmlLabelInfo t1 where t1.indexid=t2.indexid and t1.labelname='"+groupnametw+"' and t1.languageid=9) " ;
RecordSetTrans.executeSql(mysql);
if(newlabel=(!RecordSetTrans.next())){
lableid = CptFieldManager.getNewIndexId(RecordSetTrans);
RecordSetTrans.executeSql("delete from HtmlLabelIndex where id="+lableid);
RecordSetTrans.executeSql("delete from HtmlLabelInfo where indexid="+lableid);
RecordSetTrans.executeSql("INSERT INTO HtmlLabelIndex values("+lableid+",'"+groupnamecn+"')");
RecordSetTrans.executeSql("INSERT INTO HtmlLabelInfo values("+lableid+",'"+groupnamecn+"',7)");//中文
RecordSetTrans.executeSql("INSERT INTO HtmlLabelInfo values("+lableid+",'"+groupnameen+"',8)");//英文
RecordSetTrans.executeSql("INSERT INTO HtmlLabelInfo values("+lableid+",'"+groupnametw+"',9)");//繁体
}else{
lableid=RecordSetTrans.getInt("indexid");
}
RecordSetTrans.commit();
if(newlabel){
LabelComInfo.addLabeInfoCache(""+lableid);//更新缓存
}
String sql="";
if(groupid>0){
sql="update "+grouptablename+" set isopen='"+isopen+"',linkurl='"+linkurl+"',groupname='"+labelname+"',grouplabel="+lableid+",dsporder="+(i+1)+" where id="+groupid;
}else{
sql="insert into "+grouptablename+"(linkurl,groupname,grouplabel,dsporder,isopen) values('"+linkurl+"','"+labelname+"','"+lableid+"','"+(i+1)+"','"+isopen+"') ";
}
RecordSet.executeSql(sql);
}
}
}
CptFieldComInfo.removeCache();
out.print("[]");
}else if("loadgroupdata".equalsIgnoreCase(src)){//读取保存的信息
JSONArray arr=new JSONArray();
CptFieldComInfo.setTofirstRow();
while(CptFieldComInfo.next()){
JSONArray jsonArray=new JSONArray();
JSONObject jsonObject=new JSONObject();
jsonObject.put("name", "groupnamecn");
jsonObject.put("value", SystemEnv.getHtmlLabelName(Util.getIntValue( CptFieldComInfo.getLabel(),0),7));
jsonObject.put("iseditable", true);
jsonObject.put("type", "input");
jsonArray.add(jsonObject);
jsonObject=new JSONObject();
jsonObject.put("name", "groupnameen");
jsonObject.put("value", SystemEnv.getHtmlLabelName(Util.getIntValue( CptFieldComInfo.getLabel(),0),8));
jsonObject.put("iseditable", true);
jsonObject.put("type", "input");
jsonArray.add(jsonObject);
jsonObject=new JSONObject();
jsonObject.put("name", "groupnametw");
jsonObject.put("value", SystemEnv.getHtmlLabelName(Util.getIntValue( CptFieldComInfo.getLabel(),0),9));
jsonObject.put("iseditable", true);
jsonObject.put("type", "input");
jsonArray.add(jsonObject);
jsonObject=new JSONObject();
jsonObject.put("name", "linkurl");
jsonObject.put("value", Util.null2String( CptFieldComInfo.getLinkurl()));
jsonObject.put("iseditable", (!"1".equals( CptFieldComInfo.getIsSystem())));
jsonObject.put("type", "input");
jsonArray.add(jsonObject);
jsonObject=new JSONObject();
jsonObject.put("name", "isopen");
jsonObject.put("value", Util.null2String( CptFieldComInfo.getIsopen()));
jsonObject.put("iseditable", (!"1".equals( CptFieldComInfo.getIsSystem())));
jsonObject.put("checked", ("1".equals( CptFieldComInfo.getIsopen())));
jsonObject.put("type", "checkbox");
jsonArray.add(jsonObject);
jsonObject=new JSONObject();
jsonObject.put("name", "groupid");
jsonObject.put("value", CptFieldComInfo.getGroupid());
if("1".equals( CptFieldComInfo.getIsSystem())||"1".equals(CptFieldComInfo.getIsmand())){
jsonObject.put("display", "none");
}
jsonObject.put("type", "checkbox");
jsonArray.add(jsonObject);
arr.add(jsonArray);
}
//System.out.println("loadtime:\n"+new Date());
out.print(arr.toString());
}
%>