📄 insertpurvandorg.java
字号:
package com.doone.fj1w.fjmgr.sysmgr;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.doone.data.DacClient;
import com.doone.util.ExtString;
import com.doone.util.FileLogger;
import com.doone.uurm.StateEnum;
import com.doone.uurm.Sys_OPAndAuth;
import com.doone.uurm.Sys_PurvAndOrg;
/**
* Created by IntelliJ IDEA. User: lizhx Date: 2005-7-18 Time: 15:58:33
* Email:lizx@doone.com.cn
*/
public class InsertPurvAndOrg extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 800848931531673196L;
static final private String CONTENT_TYPE = "text/html; charset=GBK";
public void init() throws ServletException {
}
public void doGet(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
throws ServletException, IOException {
httpRequest.setCharacterEncoding("GBK");
httpResponse.setContentType(CONTENT_TYPE);
PrintWriter out = httpResponse.getWriter();
try {
String sPurvId = httpRequest.getParameter("PURVID").trim();
String sOrgId = httpRequest.getParameter("ORGID").trim();
String sStartTime = httpRequest.getParameter("STARTTIME").trim();
String sEndTime = httpRequest.getParameter("ENDTIME").trim();
String sState = httpRequest.getParameter("STATE");
if (ExtString.isEmpty(sState)) {
sState = "E";
}
String[] aAuthCode = httpRequest.getParameterValues("AUTHCODE");
SimpleDateFormat f1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sPurvId = Util.Replace(sPurvId);
sOrgId = Util.Replace(sOrgId);
sStartTime = Util.Replace(sStartTime);
sEndTime = Util.Replace(sEndTime);
sState = Util.Replace(sState);
DacClient db = new DacClient();
try {
db.beginTransaction(-1);
long lPurvId = Long.parseLong(sPurvId);
long lOrgId = Long.parseLong(sOrgId);
if ( Sys_PurvAndOrg.hasRelation(db, lPurvId, lOrgId) ) {
throw new RuntimeException("组织与权限的关联已经存在,不能再添加。");
}
Sys_PurvAndOrg oSys_PurvAndOrg = Sys_PurvAndOrg.newInstance(db);
Date d_createtime = new Date();
oSys_PurvAndOrg.setCreateTime(d_createtime);
try {
if (sEndTime != null && sEndTime.length() > 0)
oSys_PurvAndOrg.setEndTime(f1.parse(sEndTime + " 23:59:59"));
} catch (ParseException e) {
FileLogger.getLogger().warn(e.getMessage(), e);
}
oSys_PurvAndOrg.setOrganiseId(lOrgId);
oSys_PurvAndOrg.setPurviewId(lPurvId);
try {
if (sStartTime != null && sStartTime.length() > 0)
oSys_PurvAndOrg.setStartTime(f1.parse(sStartTime + " 00:00:00"));
} catch (ParseException e) {
FileLogger.getLogger().warn(e.getMessage(), e);
}
oSys_PurvAndOrg.setState(StateEnum.ENABLED);
oSys_PurvAndOrg.setPurviewType(sState);
if (oSys_PurvAndOrg.getStartTime() != null && oSys_PurvAndOrg.getEndTime() != null) {
if (oSys_PurvAndOrg.getStartTime().getTime() > oSys_PurvAndOrg.getEndTime()
.getTime())
throw new RuntimeException("开始时间不能大于结束时间。");
}
oSys_PurvAndOrg.save();
if ( aAuthCode != null ) {
for ( int i=0; i<aAuthCode.length; i++) {
if ( aAuthCode[i] != null && aAuthCode[i].length() > 0 ) {
Sys_OPAndAuth op = new Sys_OPAndAuth(db);
op.setPurvAndOrgID(oSys_PurvAndOrg.getPurvAndOrgId());
op.setAuthCode(aAuthCode[i].toLowerCase());
op.save();
}
}
}
db.endTransaction(true);
out.write("<script language=javascript>window.location.href='"
+ httpRequest.getContextPath() + "/view/sysmgr/OperSuccess.jsp';</script>");
} catch (SQLException ex) {
db.endTransaction(false);
}
} catch (RuntimeException e) {
out.write("<script language=javascript>window.location.href='"
+ httpRequest.getContextPath() + "/view/sysmgr/OperFailure.jsp?error="
+ Util.Replace(e.getMessage()) + "';</script>");
} catch (Exception e) {
out.write("<script language=javascript>window.location.href='"
+ httpRequest.getContextPath() + "/view/sysmgr/OperFailure.jsp';</script>");
}
}
public void doPost(HttpServletRequest httpRequest, HttpServletResponse httpResponse)
throws ServletException, IOException {
doGet(httpRequest, httpResponse);
}
// Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -