package com.ccgj.platform.admin; import com.base.common.enums.Enums; import com.base.common.spring.TransactionManager; import com.ccgj.database.beans.LMB; import com.ccgj.database.beans.YHB; import com.ccgj.database.beans.ZQB; import com.ccgj.database.business.YHBService; import com.ccgj.database.business.ZQBService; import com.ccgj.database.factory.DatabaseFactory; import com.ccgj.database.interfaces.YHBIF; import com.ccgj.database.interfaces.ZQBIF; import com.ccgj.database.manager.LMBManager; import com.ccgj.database.manager.YHBManager; import com.ccgj.database.manager.ZQBManager; import com.ccgj.database.tool.MD5; import com.ccgj.database.tool.Website; import com.ccgj.database.tool.writeFile; import com.ccgj.platform.common.CommonAction; import com.ccgj.platform.util.*; import com.opensymphony.xwork2.ActionContext; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import javax.servlet.http.HttpServletRequest; public class YHBAction extends CommonAction { private Long id; private String yhmc; private String yhzh; private String yhmm; private String passd; private int yhzt; private int yhsx; private String sjid; private String zdmc; private String zdbs; private int zdpx; private String zdmb; private String yhqx; private String yhsm; private String tjsj; private String tjyh; private String bgsj; private int dlcs; private String by1; private String by2; private String by3; private String oldPass; private String newPwd; private String newPwds; private Object[] datas; private String data; private String type; private YHB yhb; private List lmbList; private String zqbId; private String searchZhmc; private List zqbList; public Long getId() { return this.id; } public void setId(Long id) { this.id = id; } public String getYhmc() { return this.yhmc; } public void setYhmc(String yhmc) { this.yhmc = yhmc; } public String getYhzh() { return this.yhzh; } public void setYhzh(String yhzh) { this.yhzh = yhzh; } public String getYhmm() { return this.yhmm; } public void setYhmm(String yhmm) { this.yhmm = yhmm; } public String getPassd() { return this.passd; } public void setPassd(String passd) { this.passd = passd; } public int getYhzt() { return this.yhzt; } public void setYhzt(int yhzt) { this.yhzt = yhzt; } public int getYhsx() { return this.yhsx; } public void setYhsx(int yhsx) { this.yhsx = yhsx; } public String getSjid() { return this.sjid; } public void setSjid(String sjid) { this.sjid = sjid; } public String getZdmc() { return this.zdmc; } public void setZdmc(String zdmc) { this.zdmc = zdmc; } public String getZdbs() { return this.zdbs; } public void setZdbs(String zdbs) { this.zdbs = zdbs; } public int getZdpx() { return this.zdpx; } public void setZdpx(int zdpx) { this.zdpx = zdpx; } public String getZdmb() { return this.zdmb; } public void setZdmb(String zdmb) { this.zdmb = zdmb; } public String getYhqx() { return this.yhqx; } public void setYhqx(String yhqx) { this.yhqx = yhqx; } public String getYhsm() { return this.yhsm; } public void setYhsm(String yhsm) { this.yhsm = yhsm; } public String getTjsj() { return this.tjsj; } public void setTjsj(String tjsj) { this.tjsj = tjsj; } public String getTjyh() { return this.tjyh; } public void setTjyh(String tjyh) { this.tjyh = tjyh; } public String getBgsj() { return this.bgsj; } public void setBgsj(String bgsj) { this.bgsj = bgsj; } public int getDlcs() { return this.dlcs; } public void setDlcs(int dlcs) { this.dlcs = dlcs; } public String getBy1() { return this.by1; } public void setBy1(String by1) { this.by1 = by1; } public String getBy2() { return this.by2; } public void setBy2(String by2) { this.by2 = by2; } public String getBy3() { return this.by3; } public void setBy3(String by3) { this.by3 = by3; } public YHB getYhb() { return this.yhb; } public void setYhb(YHB yhb) { this.yhb = yhb; } public String getOldPass() { return this.oldPass; } public void setOldPass(String oldPass) { this.oldPass = oldPass; } public String getNewPwd() { return this.newPwd; } public void setNewPwd(String newPwd) { this.newPwd = newPwd; } public String getNewPwds() { return this.newPwds; } public void setNewPwds(String newPwds) { this.newPwds = newPwds; } public Object[] getDatas() { return this.datas; } public void setDatas(Object[] datas) { this.datas = datas; } public String getData() { return this.data; } public void setData(String data) { this.data = data; } public String getSearchZhmc() { return this.searchZhmc; } public void setSearchZhmc(String searchZhmc) { this.searchZhmc = searchZhmc; } public String getType() { return this.type; } public void setType(String type) { this.type = type; } public List getLmbList() { return this.lmbList; } public void setLmbList(List lmbList) { this.lmbList = lmbList; } public List getZqbList() { return this.zqbList; } public void setZqbList(List zqbList) { this.zqbList = zqbList; } public String getZqbId() { return this.zqbId; } public void setZqbId(String zqbId) { this.zqbId = zqbId; } public String init() { try { if ((this.yhsx > 0) && (this.yhsx == 1)) { yhbById(); } else if ((this.yhsx > 0) && (this.yhsx == 2)) { yhbById(); } else if ((this.yhsx > 0) && (this.yhsx == 3)) { yhbById(); } } catch (Exception e) { logger.debug(e); e.printStackTrace(); } return "init"; } public String yhbById() { try { if (this.id != null) { YHBIF yhbIF = DatabaseFactory.getYHBIF(); YHB yhb = yhbIF.getYHBService().searchYHBByID(this.id); setYhb(yhb); } } catch (Exception e) { e.printStackTrace(); } return "data"; } public String edit() { try { Date date = new Date(); if (this.id != null) { YHBIF yhbIF = DatabaseFactory.getYHBIF(); YHB yhbBean = yhbIF.getYHBService().searchYHBByID(this.id); if (yhbBean != null) { if ((this.newPwd != null) && (this.newPwds != null) && (this.newPwd.equals(this.newPwds))) { if ((this.oldPass != null) && (this.oldPass.length() > 0)) { String decodePwd = StringCode.decrypt(yhbBean.getYhmm()); if (decodePwd.equals(this.oldPass)) { /**确认旧密码正确后,判断新密码强度**/ if(CheckStrength.checkPasswordStrength(newPwd)< 6){ setJsondata(JsonResult.ajax(Boolean.valueOf(true), "4")); return "data"; } yhbBean.setYhmm(StringCode.encrypt(this.newPwd)); yhbBean.setTjsj(DateFormat.shortDate(date)); yhbIF.getYHBService().updateYHB(yhbBean); setJsondata(JsonResult.ajax(Boolean.valueOf(true), "3")); } else { setJsondata(JsonResult.ajax(Boolean.valueOf(true), "2")); return "data"; } } } else { setJsondata(JsonResult.ajax(Boolean.valueOf(true), "1")); return "data"; } } } } catch (Exception e) { e.printStackTrace(); } return "data"; } public String adminList() { try { YHBIF yhbIF = DatabaseFactory.getYHBIF(); YHB yhbBean = yhbIF.createYHB(); yhbBean.setYhsx(2); yhbBean.setYhzt(4); if ((this.searchZhmc != null) && (this.searchZhmc.length() > 0)) { yhbBean.setYhzh(this.searchZhmc); } List lists = new ArrayList(); List listCount = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean); List listData = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean); for (int i = 0; i < listData.size(); i++) { YHB yhb = (YHB)listData.get(i); lists.add(yhb); } setJsondata(JsonResult.listByLigerUI(lists, Integer.valueOf(listCount.isEmpty() ? 0 : listCount.size())).toString()); } catch (Exception e) { e.printStackTrace(); setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR"))); } return "list"; } public String manageAdminList() { YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user"); try { YHBIF yhbIF = DatabaseFactory.getYHBIF(); YHB yhbBean = yhbIF.createYHB(); yhbBean.setYhsx(3); yhbBean.setYhzt(4); yhbBean.setZdbsid(yhbBeans.getZdbsid()); if ((this.searchZhmc != null) && (this.searchZhmc.length() > 0)) { yhbBean.setYhzh(this.searchZhmc); } List lists = new ArrayList(); List listCount = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean); List listData = yhbIF.getYHBService().getYhbManager().searchListYhbByBean(yhbBean); for (int i = 0; i < listData.size(); i++) { YHB yhb = (YHB)listData.get(i); lists.add(yhb); } setJsondata(JsonResult.listByLigerUI(lists, Integer.valueOf(listCount.isEmpty() ? 0 : listCount.size())).toString()); } catch (Exception e) { e.printStackTrace(); setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR"))); } return "list"; } public String adminDel() { String returnType = null; try { YHBIF yhbIF = DatabaseFactory.getYHBIF(); if ((this.data != null) && (this.data.length() > 0)) { YHB bean = yhbIF.searchYHBByID(Long.valueOf(Long.parseLong(this.data))); // 假删除改为真删除 // bean.setYhzt(4); // yhbIF.getYHBService().updateYHB(bean); yhbIF.getYHBService().deleteYHB(bean); } else { StringTokenizer st = new StringTokenizer(SystemUtil.getStringByObject(this.datas), ","); while (st.hasMoreTokens()) { yhbIF.getYHBService().getTransactionManager().begin(); String id = st.nextToken(); YHB bean = yhbIF.searchYHBByID(Long.valueOf(Long.parseLong(id))); // 假删除改为真删除 // bean.setYhzt(4); // yhbIF.getYHBService().updateYHB(bean); yhbIF.getYHBService().deleteYHB(bean); yhbIF.getYHBService().getTransactionManager().commit(); } } } catch (Exception e) { logger.debug(e); e.printStackTrace(); setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR"))); } if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { returnType = manageAdminList(); } } else { returnType = adminList(); } return returnType; } public String saveXTGLY() { YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user"); String returnType = null; try { Date data = new Date(); YHBIF yhbIF = DatabaseFactory.getYHBIF(); ZQBIF zqbIF = DatabaseFactory.getZQBIF(); yhbIF.getYHBService().getTransactionManager().begin(); YHB bean = yhbIF.createYHB(); bean.setYhmc(this.yhmc); bean.setYhzh(this.yhzh); bean.setYhzt(this.yhzt); bean.setYhmm(StringCode.encrypt("123456")); if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { bean.setYhsx(3); } bean.setZdbsid(yhbBeans.getZdbsid()); bean.setZdbs(yhbBeans.getZdbs()); } else { ZQB zqbBean = zqbIF.createZQB(); zqbBean.setId(Long.valueOf(Long.parseLong(this.zqbId))); List zqbList = zqbIF.getZQBService().getZqbManager().searchListZqbByBean(zqbBean); bean.setYhsx(2); bean.setZdbsid(((ZQB)zqbList.get(0)).getId().toString()); bean.setZdbs(((ZQB)zqbList.get(0)).getZqbs()); } bean.setSjid("1"); bean.setYhsm(this.yhsm); bean.setTjsj(DateFormat.shortDate(data)); yhbIF.getYHBService().saveYHB(bean); yhbIF.getYHBService().getTransactionManager().commit(); } catch (Exception e) { e.printStackTrace(); } if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { returnType = manageAdminList(); } } else { returnType = adminList(); } return returnType; } public String getXtglyById() { String returnType = null; try { if (this.id != null) { YHBIF yhbIF = DatabaseFactory.getYHBIF(); ZQBIF zqbIF = DatabaseFactory.getZQBIF(); List listDatas = new ArrayList(); YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id); if (searchbean != null) { String mm = searchbean.getYhmm(); String pwd = StringCode.decrypt(mm); searchbean.setYhmm(pwd); setYhb(searchbean); getRequest().setAttribute("yhb", searchbean); ZQB zqbBean = zqbIF.createZQB(); zqbBean.setFlag("1"); List listData = zqbIF.getZQBService().getZqbManager().searchListZqbByBean(zqbBean); for (ZQB list : listData) { listDatas.add(list); } setZqbList(listData); getRequest().setAttribute("zdbsid", searchbean.getZdbsid()); } } } catch (Exception e) { e.printStackTrace(); } if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { returnType = "manageAdminEdit"; } else { returnType = "yhbManageCompetenceEdit"; } } else { returnType = "yhbManageEdit"; } return returnType; } public String editXTGLY() { Date data = new Date(); YHB yhbBeans = (YHB)ActionContext.getContext().getSession().get("zfmb_user"); String returnType = null; try { if (this.id != null) { YHBIF yhbIF = DatabaseFactory.getYHBIF(); ZQBIF tZqbIF = DatabaseFactory.getZQBIF(); YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id); if (searchbean != null) { searchbean.setYhmc(this.yhmc); searchbean.setYhzh(this.yhzh); searchbean.setYhmm(StringCode.encrypt(this.yhmm)); searchbean.setYhzt(this.yhzt); searchbean.setYhsm(this.yhsm); searchbean.setTjsj(DateFormat.shortDate(data)); if (this.zqbId != null) { ZQB bean = tZqbIF.createZQB(); bean.setId(Long.valueOf(Long.parseLong(this.zqbId))); List zqbList = tZqbIF.getZQBService().getZqbManager().searchListZqbByBean(bean); searchbean.setZdbsid(((ZQB)zqbList.get(0)).getId().toString()); searchbean.setZdbs(((ZQB)zqbList.get(0)).getZqbs()); } else { searchbean.setZdbsid(yhbBeans.getZdbsid()); searchbean.setZdbs(yhbBeans.getZdbs()); } yhbIF.getYHBService().updateYHB(searchbean); } } } catch (Exception e) { e.printStackTrace(); } if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { returnType = manageAdminList(); } } else { returnType = adminList(); } return returnType; } public String editYHBbyCompetence() { String returnType = null; try { YHBIF yhbIF = DatabaseFactory.getYHBIF(); YHB searchbean = yhbIF.getYHBService().searchYHBByID(this.id); String[] right = getRequest().getParameterValues("right"); String rights = ","; if (right != null) { for (int i = 0; i < right.length; i++) { rights = rights + right[i] + ","; } } if (searchbean != null) { searchbean.setYhzt(this.yhzt); searchbean.setYhqx(rights); yhbIF.getYHBService().updateYHB(searchbean); } } catch (Exception e) { e.printStackTrace(); } if ((this.type != null) && (this.type.length() > 0)) { if (this.type.equals("wzgl")) { returnType = manageAdminList(); } } else { returnType = adminList(); } return returnType; } public String zqbList() { try { List listDatas = new ArrayList(); ZQBIF tZqbIF = DatabaseFactory.getZQBIF(); ZQB searchbean = tZqbIF.createZQB(); searchbean.setFlag("1"); List listData = tZqbIF.getZQBService().getZqbManager().searchListZqbByBean(searchbean); for (ZQB list : listData) { listDatas.add(list); } setZqbList(listDatas); } catch (Exception e) { logger.debug(e); e.printStackTrace(); setJsondata(JsonResult.submit(Boolean.valueOf(false), Enums.getInstance().getDescByName("CommonMessage", "SYSTEM_ERROR"))); } return "zqbList"; } private YHBManager yhbdao = new YHBManager(); private LMBManager lmdao = new LMBManager(); private YHB dqyhb = null; private static writeFile log = new writeFile(); public List getLmbOFyhQx(YHB yhb, String lmid) { if ((lmid == null) || ("".equals(lmid)) || ("0".equals(lmid))) { return null; } List qxlist = null; List slmblist = this.lmdao.getSecondLMB(yhb.getZdbs(), lmid); if (slmblist != null) { qxlist = new ArrayList(); for (LMB slmb : slmblist) { if ("1".equals(slmb.getLmlx())) { List sqxlist = getLmbOFyhQx(yhb, slmb.getId().toString()); if ((sqxlist != null) || (sqxlist.size() > 0)) { for (LMB sslmb : sqxlist) { qxlist.add(sslmb); } } } else if (checkYhbOfyhqx(yhb, slmb.getId().toString()) > 0) { qxlist.add(slmb); } } } return qxlist; } public YHB getZdOfZdbs(String zdbs) { YHB yhb = getManagerByZdbs(zdbs); if (yhb != null) { yhb.setId(Long.valueOf(0L)); yhb.setYhmc(""); yhb.setYhmm(""); yhb.setSjid(""); yhb.setYhqx(""); yhb.setYhsm(""); yhb.setTjyh(""); } else { yhb = new YHB(); } return yhb; } public YHB getManagerByZdbs(String zdbs) { return this.yhbdao.getMangerByzdbs(zdbs); } public int setYhbOfYhzt(String yhid, int yhzt) { int recode = 1; try { recode = this.yhbdao.modifyYhbOfYhzt(yhid, yhzt); } catch (Exception e) { writeFile.println(3, e); recode = 0; } return recode; } public int setYhbOfYhqx(String yhid, String yhqx) { int recode = 1; try { recode = this.yhbdao.setYhbOfYhqx(yhid, yhqx); } catch (Exception e) { writeFile.println(3, e); recode = 0; } return recode; } public int checkYhbOfyhqx(YHB yhb, String lmid) { int recode = 1; try { if (yhb.getYhqx().indexOf("news" + lmid + "_") > 0) { return recode; } } catch (Exception e) { writeFile.println(3, e); recode = -1; } return 0; } public int checkYhbOfyhqx(YHB yhb, String lmid, int qxlx) { int recode = 1; try { switch (qxlx) { case 1: if (yhb.getYhqx().indexOf("news" + lmid + "_view,") > 0) { return 1; } case 2: if (yhb.getYhqx().indexOf("news" + lmid + "_check,") > 0) { return 2; } case 3: if (yhb.getYhqx().indexOf("news" + lmid + "_add,") > 0) { return 3; } case 4: if (yhb.getYhqx().indexOf("news" + lmid + "_edit,") > 0) { return 4; } case 5: if (yhb.getYhqx().indexOf("news" + lmid + "_del,") > 0) { return 5; } case 6: if (yhb.getYhqx().indexOf("news" + lmid + "_comm,") > 0) { return 6; } break; } return 0; } catch (Exception e) { writeFile.println(3, e); recode = 0; } return recode; } public int DropYhb(String yhid) { int recode = 1; YHB yhb = this.yhbdao.getYhbByYhid(yhid); if (yhb.getYhsx() == 3) { recode = this.yhbdao.removeyhb(yhid); if (recode < 0) { return -14; } } return recode; } public int ModifyYhbOfUser(String zdbs, YHB yhb) { try { int recode = 0; recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh()); if (recode < 1) { return recode; } yhb.setZdbs(zdbs); yhb.setYhsx(3); recode = this.yhbdao.modifyYhbofManager(yhb); if (recode < 1) { return -13; } } catch (Exception e) { e.printStackTrace(); } return 1; } public int ModifyYhbOfManager(YHB yhb) { int recode = 0; recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh()); if (recode < 1) { return recode; } recode = checkZdbsUnique(yhb.getId().toString(), yhb.getZdbs()); if (recode < 1) { return recode; } yhb.setYhsx(2); recode = this.yhbdao.modifyYhbofManager(yhb); if (recode < 1) { return -13; } return 1; } public int ModifyYhbOfYhmm(String yyhmm, String xyhmm, YHB yhb) { int recode = 0; MD5 md5 = new MD5(); if (!yhb.getYhmm().equals(md5.getMD5ofStr(yyhmm))) { return -16; } yhb.setYhmm(md5.getMD5ofStr(xyhmm)); recode = this.yhbdao.modifyYhbOfYhmm(yhb); if (recode < 1) { return -17; } return 1; } public int ResetYhbOfYhmm(String yhid) { try { int recode = 0; MD5 md5 = new MD5(); YHB yhb = new YHB(); yhb.setId(Long.valueOf(Long.parseLong(yhid))); yhb.setYhmm(md5.getMD5ofStr(Website.getDefault_passd())); recode = this.yhbdao.modifyYhbOfYhmm(yhb); if (recode < 1) { return -17; } } catch (Exception e) { e.printStackTrace(); } return 1; } public int AddYhbOfUser(String zdbs, YHB yhb) { int recode = 0; recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh()); if (recode < 1) { return recode; } yhb.setZdbs(zdbs); yhb.setYhsx(3); MD5 md5 = new MD5(); yhb.setYhmm(md5.getMD5ofStr(yhb.getYhmm())); recode = this.yhbdao.addYhb(yhb); if (recode < 1) { return -13; } return 1; } public int AddYhbOfManager(YHB yhb) { int recode = 0; recode = checkYhzhUnique(yhb.getId().toString(), yhb.getYhzh()); if (recode < 1) { return recode; } recode = checkZdbsUnique(yhb.getId().toString(), yhb.getZdbs()); if (recode < 1) { return recode; } yhb.setYhsx(2); MD5 md5 = new MD5(); yhb.setYhmm(md5.getMD5ofStr(yhb.getYhmm())); recode = this.yhbdao.addYhb(yhb); if (recode < 1) { return -13; } return 1; } public int checkYhzhUnique(String yhid, String yhzh) { YHB yhb = this.yhbdao.getYhbByYhzh(yhzh); if ((yhb != null) && (!yhb.getId().toString().equals(yhid))) { return -11; } return 1; } public int checkZdbsUnique(String yhid, String zdbs) { List yhlist = this.yhbdao.getAllManager(); for (YHB yhb : yhlist) { if ((yhb.getZdbs().equalsIgnoreCase(zdbs)) && (!yhb.getId().equals(yhid))) { return -12; } } return 1; } public YHB getWSYhbByYhid(String yhid) { YHB yhb = this.yhbdao.getYhbByYhid(yhid); if ((yhb != null) && (yhb.getYhsx() == 2)) { return yhb; } return null; } public YHB getYhbByYhid(String yhid) { YHB yhb = this.yhbdao.getYhbByYhid(yhid); if ((yhb != null) && (yhb.getYhsx() == 3)) { return yhb; } return null; } public List getAllManager() { return this.yhbdao.getAllManager(); } public List getAllUserByzdbs(String zdbs) { return this.yhbdao.getAllUserByzdbs(zdbs); } public int getLoginYh(String username, String userpassword) { int recode = 1; if ((getString(username).length() == 0) || (getString(userpassword).length() == 0)) { return 0; } YHB dlyhb = new YHB(); dlyhb = this.yhbdao.getYhbByYhzh(username); if ((dlyhb == null) || (dlyhb.getId().toString().length() == 0)) { return -1; } MD5 md5 = new MD5(); if (!dlyhb.getYhmm().equals(md5.getMD5ofStr(userpassword))) { return -2; } if (dlyhb.getYhzt() > 2) { return -3; } this.dqyhb = dlyhb; return recode; } public YHB getCurrentYhb() { return this.dqyhb; } public String getMessage(int msgnum) { switch (msgnum) { case 0: return "输入信息错误,请重新输入!"; case -1: return "此帐号不存在,请重新输入!"; case -2: return "用户名或密码错误,请重新输入!"; case -3: return "此帐号已经被锁定!"; case -11: return "此帐号已经存在,请重新输入!"; case -12: return "此站点标识已经存在,请重新输入!"; case -13: return "添加站点管理员账号失败!"; case -14: return "删除用户失败!"; case -15: return "删除站点失败!"; case -16: return "原密码错误!"; case -17: return "修改用户密码失败!"; } return "用户名或密码错误!"; } private String getString(String str) { if ((str != null) && (str.length() > 0)) { return str.trim(); } return ""; } }