📄 updatepurvandorg.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 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.PurviewTypeEnum;
import com.doone.uurm.Sys_OPAndAuth;
import com.doone.uurm.Sys_PurvAndOrg;
/**
* Created by IntelliJ IDEA. User: lizhx Date: 2005-7-18 Time: 16:47:39 Email:lizx@doone.com.cn
*/
public class UpdatePurvAndOrg extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = -6776636526322418585L;
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 sPurvAndOrgId = httpRequest.getParameter("PURVANDORGID").trim();
String sStartTime = httpRequest.getParameter("STARTTIME").trim();
String sEndTime = httpRequest.getParameter("ENDTIME").trim();
String sPurviewType = httpRequest.getParameter("PURVIEWTYPE");
if ( ExtString.isEmpty(sPurviewType)) {
sPurviewType = "E";
}
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");
sPurvAndOrgId = Util.Replace(sPurvAndOrgId);
sStartTime = Util.Replace(sStartTime);
sEndTime = Util.Replace(sEndTime);
sState = Util.Replace(sState);
DacClient db = new DacClient();
try {
db.beginTransaction(-1);
Sys_PurvAndOrg pao = Sys_PurvAndOrg.getInstance(db, Long.parseLong(sPurvAndOrgId));
try {
if (sEndTime.length() > 0)
pao.setEndTime(f1.parse(sEndTime + " 23:59:59"));
} catch (ParseException e) {
FileLogger.getLogger().debug(e.getMessage(), e);
}
try {
if (sStartTime.length() > 0)
pao.setStartTime(f1.parse(sStartTime + " 00:00:00"));
} catch (ParseException e) {
FileLogger.getLogger().debug(e.getMessage(), e);
}
pao.setState(sState);
sPurviewType = PurviewTypeEnum.ENABLED.equalsIgnoreCase(sPurviewType) ? "E" : "D";
pao.setPurviewType(sPurviewType);
if (pao.getStartTime() != null && pao.getEndTime() != null
&& pao.getStartTime().getTime() > pao.getEndTime().getTime()) {
throw new RuntimeException("开始时间不能大于结束时间。");
}
pao.save();
Sys_OPAndAuth[] opa = Sys_OPAndAuth.getOPAndAuthByPurvAndOrgID(db, pao.getPurvAndOrgId());
// 清队已经被取消的权限集。
for (int i = 0; opa != null && i < opa.length; i++) {
if (aAuthCode == null || aAuthCode.length == 0) {
opa[i].delete();
opa[i].save();
} else {
boolean hasPurv = false;
for (int j = 0; j < aAuthCode.length; j++) {
if (aAuthCode[j] != null && opa[i].getAuthCode().equalsIgnoreCase(aAuthCode[j])) {
hasPurv = true;
break;
}
}
if (!hasPurv) {
opa[i].delete();
opa[i].save();
}
}
}
if (aAuthCode != null) {
for (int i = 0; i < aAuthCode.length; i++) {
if (aAuthCode[i] != null && aAuthCode[i].length() > 0) {
boolean hasPurv = false;
for (int kk = 0; opa != null && kk < opa.length; kk++) {
if (opa[kk].getAuthCode().equalsIgnoreCase(aAuthCode[i])) {
hasPurv = true;
break;
}
}
if (!hasPurv) {
Sys_OPAndAuth op = new Sys_OPAndAuth(db);
op.setPurvAndOrgID(pao.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) {
FileLogger.getLogger().warn(ex.getMessage(), 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) {
FileLogger.getLogger().warn(e.getMessage(), 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 + -