⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 workplanmgr.java

📁 oa 源码
💻 JAVA
字号:
package com.redmoon.oa.workplan;import java.util.Calendar;import cn.js.fan.db.Conn;import cn.js.fan.util.*;import java.sql.*;import cn.js.fan.util.ErrMsgException;import javax.servlet.http.*;import org.apache.log4j.Logger;import cn.js.fan.web.Global;import com.redmoon.kit.util.FileUpload;import java.io.IOException;import javax.servlet.ServletContext;import cn.js.fan.web.SkinUtil;import com.redmoon.oa.message.MessageDb;import com.cloudwebsoft.framework.aop.ProxyFactory;import com.cloudwebsoft.framework.aop.base.Advisor;import com.cloudwebsoft.framework.aop.Pointcut.MethodNamePointcut;import com.redmoon.oa.message.IMessage;import com.redmoon.oa.message.MobileAfterAdvice;import com.redmoon.oa.person.UserMgr;public class WorkPlanMgr {  Logger logger = Logger.getLogger( WorkPlanMgr.class.getName() );  public WorkPlanMgr() {  }  public FileUpload doUpload(ServletContext application,                             HttpServletRequest request) throws          ErrMsgException {      FileUpload fileUpload = new FileUpload();      fileUpload.setMaxFileSize(Global.FileSize);                   int ret = 0;      try {          ret = fileUpload.doUpload(application, request);          if (ret != fileUpload.RET_SUCCESS) {              throw new ErrMsgException("ret=" + ret + " " +                                        fileUpload.getErrMessage());          }      } catch (IOException e) {          logger.error("doUpload:" + e.getMessage());      }      return fileUpload;  }  public boolean modify(ServletContext application, HttpServletRequest request) throws ErrMsgException {      Privilege privilege = new Privilege();      if (!privilege.isUserLogin(request))          throw new ErrMsgException("请先登录!");      boolean re = true;      String errmsg = "";      FileUpload fu = doUpload(application, request);      String strId = fu.getFieldValue("id");      int id = Integer.parseInt(strId);      String title = StrUtil.getNullStr(fu.getFieldValue("title"));      if (title.equals(""))          errmsg += "计划标题不能为空!\\n";      String content = fu.getFieldValue("content");      String strBeginDate = fu.getFieldValue("beginDate");      String strEndDate = fu.getFieldValue("endDate");      String strTypeId = fu.getFieldValue("typeId");      int typeId = Integer.parseInt(strTypeId);      String strdepts = fu.getFieldValue("depts");      if (strdepts==null || strdepts.equals(""))          errmsg += "请选择部门!\\n";      String strusers = fu.getFieldValue("users");      if (strusers==null || strusers.equals(""))          errmsg += "请选择参与人员!\\n";      String remark = fu.getFieldValue("remark");      String principal = fu.getFieldValue("principal");      java.util.Date beginDate = null;      java.util.Date endDate = null;      try {          beginDate = DateUtil.parse(strBeginDate, "yyyy-MM-dd");          endDate = DateUtil.parse(strEndDate, "yyyy-MM-dd");      }      catch (Exception e) {          logger.error("modify:" + e.getMessage());      }      if (beginDate==null || endDate==null)          errmsg += "请填写开始和结束日期!\\n";      if (!errmsg.equals(""))          throw new ErrMsgException(errmsg);      WorkPlanDb wpd = getWorkPlanDb(id);      wpd.setTitle(title);      wpd.setContent(content);      wpd.setBeginDate(beginDate);      wpd.setEndDate(endDate);      wpd.setTypeId(typeId);      wpd.setRemark(remark);      wpd.setPrincipal(principal);      String[] depts = strdepts.split(",");      String[] users = strusers.split(",");      wpd.setDepts(depts);      wpd.setUsers(users);      re = wpd.save(fu);      if (re) {          String strIsMessageRemind = StrUtil.getNullString(fu.getFieldValue(                  "isMessageRemind"));          boolean isToMobile = StrUtil.getNullStr(fu.getFieldValue("isToMobile")).equals("true");          IMessage imsg = null;          String t = SkinUtil.LoadString(request,                                         "res.module.workplan",                                         "msg_workplan_modified_title");          t = t.replaceFirst("\\$title", title);          String c = SkinUtil.LoadString(request,                                         "res.module.workplan",                                         "msg_workplan_modified_content");          UserMgr um = new UserMgr();          String realName = um.getUserDb(wpd.getAuthor()).getRealName();          if (isToMobile && strIsMessageRemind.equals("true")) {              ProxyFactory proxyFactory = new ProxyFactory(                      "com.redmoon.oa.message.MessageDb");              Advisor adv = new Advisor();              MobileAfterAdvice mba = new MobileAfterAdvice();              adv.setAdvice(mba);              adv.setPointcut(new MethodNamePointcut("sendSysMsg", false));              proxyFactory.addAdvisor(adv);              imsg = (IMessage) proxyFactory.getProxy();              c = c.replaceFirst("\\$user", realName);              int len = users.length;              for (int i = 0; i < len; i++) {                  imsg.sendSysMsg(users[i], t, c);              }          }          else if (strIsMessageRemind.equals("true")) {                            MessageDb md = new MessageDb();              c = c.replaceFirst("\\$user", realName);              int len = users.length;              for (int i = 0; i < len; i++) {                  md.sendSysMsg(users[i], t, c);              }          }      }      return re;  }  public WorkPlanDb getWorkPlanDb(HttpServletRequest request, int id, String op) throws ErrMsgException {      Privilege privilege = new Privilege();      if (op.equals("see")) {          if (!privilege.canUserSeeWorkPlan(request, id))              throw new ErrMsgException(SkinUtil.LoadString(request, "pvg_invalid"));      }      if (op.equals("edit")) {          if (!privilege.canUserManageWorkPlan(request, id))              throw new ErrMsgException(SkinUtil.LoadString(request, "pvg_invalid"));      }      if (op.equals("del")) {          if (!privilege.canUserManageWorkPlan(request, id))              throw new ErrMsgException(SkinUtil.LoadString(request, "pvg_invalid"));      }      WorkPlanDb wpd = getWorkPlanDb(id);      return wpd;  }  public WorkPlanDb getWorkPlanDb(int id) {      WorkPlanDb addr = new WorkPlanDb();      return addr.getWorkPlanDb(id);  }  public boolean delAttachment(HttpServletRequest request) throws ErrMsgException {      int workPlanId = ParamUtil.getInt(request, "workPlanId");      int attachId = ParamUtil.getInt(request, "attachId");      WorkPlanDb wpd = getWorkPlanDb(request, workPlanId, "del");      return wpd.delAttachment(attachId);  }  public boolean create(ServletContext application, HttpServletRequest request) throws ErrMsgException {      Privilege privilege = new Privilege();      if (!privilege.isUserLogin(request))          throw new ErrMsgException("请先登录!");      boolean re = true;      FileUpload fu = doUpload(application, request);      String errmsg = "";      String title = StrUtil.getNullStr(fu.getFieldValue("title"));      if (title.equals(""))          errmsg += "计划标题不能为空!\\n";      String content = fu.getFieldValue("content");      String strBeginDate = fu.getFieldValue("beginDate");      String strEndDate = fu.getFieldValue("endDate");      String strTypeId = fu.getFieldValue("typeId");      int typeId = 0;      if (!StrUtil.isNumeric(strTypeId))          errmsg += "计划类型不能为空,请添加计划类型!\\n";      else          typeId = Integer.parseInt(strTypeId);      String strdepts = fu.getFieldValue("depts");      if (strdepts==null || strdepts.equals(""))          errmsg += "请选择部门!\\n";      String strusers = fu.getFieldValue("users");      if (strusers==null || strusers.equals(""))          errmsg += "请选择参与人员!\\n";      String remark = fu.getFieldValue("remark");      String principal = fu.getFieldValue("principal");      java.util.Date beginDate = null;      java.util.Date endDate = null;      try {          beginDate = DateUtil.parse(strBeginDate, "yyyy-MM-dd");          endDate = DateUtil.parse(strEndDate, "yyyy-MM-dd");      }      catch (Exception e) {          logger.error("create:" + e.getMessage());      }      if (beginDate==null || endDate==null)          errmsg += "请填写开始和结束日期!\\n";      if (!errmsg.equals(""))          throw new ErrMsgException(errmsg);      WorkPlanDb wpd = new WorkPlanDb();      wpd.setTitle(title);      wpd.setContent(content);      wpd.setBeginDate(beginDate);      wpd.setEndDate(endDate);      wpd.setTypeId(typeId);      wpd.setRemark(remark);      wpd.setPrincipal(principal);            String[] depts = strdepts.split(",");      String[] users = strusers.split(",");      wpd.setDepts(depts);      wpd.setUsers(users);      wpd.setAuthor(privilege.getUser(request));      re = wpd.create(fu);      if (re) {          String strIsMessageRemind = StrUtil.getNullString(fu.getFieldValue(                  "isMessageRemind"));          boolean isToMobile = StrUtil.getNullStr(fu.getFieldValue("isToMobile")).equals("true");          IMessage imsg = null;          String t = SkinUtil.LoadString(request,                                         "res.module.workplan",                                         "msg_workplan_create_title");          t = t.replaceFirst("\\$title", title);          String c = SkinUtil.LoadString(request,                                         "res.module.workplan",                                         "msg_workplan_create_content");          UserMgr um = new UserMgr();          String realName = um.getUserDb(wpd.getAuthor()).getRealName();          if (isToMobile && strIsMessageRemind.equals("true")) {              ProxyFactory proxyFactory = new ProxyFactory(                      "com.redmoon.oa.message.MessageDb");              Advisor adv = new Advisor();              MobileAfterAdvice mba = new MobileAfterAdvice();              adv.setAdvice(mba);              adv.setPointcut(new MethodNamePointcut("sendSysMsg", false));              proxyFactory.addAdvisor(adv);              imsg = (IMessage) proxyFactory.getProxy();              c = c.replaceFirst("\\$user", realName);              int len = users.length;              for (int i = 0; i < len; i++) {                  imsg.sendSysMsg(users[i], t, c);              }          }          else if (strIsMessageRemind.equals("true")) {                            MessageDb md = new MessageDb();              c = c.replaceFirst("\\$user", realName);              int len = users.length;              for (int i = 0; i < len; i++) {                  md.sendSysMsg(users[i], t, c);              }          }      }      return re;  }  public boolean del(HttpServletRequest request) throws ErrMsgException {      int id = ParamUtil.getInt(request, "id");      WorkPlanDb wpd = getWorkPlanDb(request, id, "del");      if (wpd==null || !wpd.isLoaded())          throw new ErrMsgException("该项已不存在!");      return wpd.del();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -