📄 zboameetingcontentmanager.java
字号:
/**
* author tanhb
* 2005-12-18
*/
package com.litsoft.zboa.meetingcontent.core;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import org.apache.struts.action.ActionForm;
import com.litsoft.fw.core.AbstractManager;
import com.litsoft.fw.db.ZboaMeetingcontent;
import com.litsoft.fw.db.ZboaMeetingroom;
import com.litsoft.fw.db.base._BaseRootDAO;
import com.litsoft.fw.db.dao.SessionDAO;
import com.litsoft.fw.db.dao.ZboaMeetingcontentDAO;
import com.litsoft.fw.db.dao.ZboaMeetingroomDAO;
import com.litsoft.fw.db.dao.ZboaMeetinguserDAO;
import com.litsoft.fw.exception.FWException;
import com.litsoft.fw.form.AbstractForm;
import com.litsoft.fw.util.FwConst;
import com.litsoft.fw.util.TodoManager;
import com.litsoft.fw.util.Tools;
import com.litsoft.zboa.meetingcontent.form.MeetingcontentForm;
public class ZboaMeetingcontentManager extends AbstractManager
{
private static ZboaMeetingcontentDAO meetingDao = new ZboaMeetingcontentDAO();
private static ZboaMeetingroomDAO roomDao = new ZboaMeetingroomDAO();
// private static ZboaMeetinguserDAO meetinguserDao = new
// ZboaMeetinguserDAO();
/**
* 添加一条会议记录,先添加会议记录表,后添加会议人员表
* @param form
* @throws Exception
*/
public static void AddEntiny(ActionForm form) throws Exception
{
Session session = SessionDAO.createSession();
Transaction tx = session.beginTransaction();
try
{
MeetingcontentForm meeting = (MeetingcontentForm) form;
int meetingid = getIntegerKey("zboa_meetingcontent", session).intValue();
// 添加会议记录表
Addmeeting(meetingid, meeting, session);
tx.commit();
ApplyToDoAdd(meetingid,meeting);
}
catch (Exception ex)
{
tx.rollback();
ex.printStackTrace();
throw new FWException(ex.getMessage());
}
}
//生成会议审批待办
public static void ApplyToDoAdd(int meetingid,ActionForm form)throws Exception
{
MeetingcontentForm meeting = (MeetingcontentForm) form;
String userid="0";
String todotitle="会议审批";
String todolink="./ViewMeeting.do?id="+meetingid;
if (meeting.getMeetinchargeleader() != null && !meeting.getMeetinchargeleader().equals(""))
{
userid=meeting.getMeetinchargeleader();
}
String opera="";
if (meeting.getMeetopera() != null && !meeting.getMeetopera().equals(""))
{
opera=meeting.getMeetopera();
}
TodoManager.AddTodoItem(Integer.toString(meetingid), new Integer(userid), FwConst.TODO_HUIYI, todotitle, todolink, opera);
}
// 生成会议安排待办
public static void ArangeToDoAdd(int meetingid,String userids,String username)throws Exception
{
String userid="0";
String todotitle="会议安排";
String todolink="./toArrange.do?id="+meetingid;
String[] ids=userids.split(",");
for(int i=0;i<ids.length;i++)
{
if(!ids[i].equals(""))
{
TodoManager.AddTodoItem(Integer.toString(meetingid), new Integer(ids[i]), FwConst.TODO_HUIYI, todotitle, todolink, username);
}
}
}
//生成会议发送通知待办
public static void PostNoticeToDoAdd(int meetingid,String userid,String username)throws Exception
{
String todotitle="发送会议通知";
String todolink="./tochangeMeeting.do?id="+meetingid;
if(userid!=null&&!userid.equals(""))
{
TodoManager.AddTodoItem(Integer.toString(meetingid), new Integer(userid), FwConst.TODO_HUIYI, todotitle, todolink, username);
}
}
//生成会议通知待办
public static void NoticeToDoAdd(int meetingid,ActionForm form)throws Exception
{
MeetingcontentForm meeting = (MeetingcontentForm) form;
String todotitle="会议通知";
String todolink="./toNoticeRefle.do?id="+meetingid;
String leaders="";
String users="";
if (meeting.getMeetingleaderid() != null && !meeting.getMeetingleaderid().equals(""))
{
leaders=meeting.getMeetingleaderid();
}
if (meeting.getMeetingdepartid() != null && !meeting.getMeetingdepartid().equals(""))
{
users=checkUsers(meeting.getMeetingleaderid(),meeting.getMeetingdepartid());
}
ManyToDoAdd(meetingid, todolink,todotitle, leaders, meeting.getMeetopera());
ManyToDoAdd(meetingid, todolink,todotitle, users, meeting.getMeetopera());
}
//给多个人发待办
public static void ManyToDoAdd(int meetingid,String link,String title,String userids,String username)throws Exception
{
if(userids!=null)
{
String[] ids=userids.split(",");
for(int i=0;i<ids.length;i++)
{
if(!ids[i].equals(""))
{
TodoManager.AddTodoItem(Integer.toString(meetingid), new Integer(ids[i]), FwConst.TODO_HUIYI, title, link, username);
}
}
}
}
// 给多个人发待办
public static void ManymanToDoAdd(Integer id,String userids,String todoname,String title,String link,String username)throws Exception
{
if(userids!=null)
{
String[] ids=userids.split(",");
for(int i=0;i<ids.length;i++)
{
if(!ids[i].equals(""))
{
TodoManager.AddTodoItem(String.valueOf(id), new Integer(ids[i]), todoname, title, link, username);
}
}
}
}
/**
* 添加会议记录表
* @param meetingid 会议id
* @param form actionform
* @param session session
* @throws Exception
*/
public static void Addmeeting( int meetingid,
ActionForm form,
Session session) throws Exception
{
MeetingcontentForm meeting = (MeetingcontentForm) form;
Calendar star = Calendar.getInstance();
star.clear();
star.setTime(Tools.getDateTime(meeting.getStarttime()));
Calendar end = Calendar.getInstance();
end.clear();
end.setTime(Tools.getDateTime(meeting.getEndtime()));
ZboaMeetingcontent meetingcontent = new ZboaMeetingcontent();
meetingcontent.setMeetingid(new Integer(meetingid));
meetingcontent.setMeetingstatus(new Integer(meeting.getIsaccept()));
meetingcontent.setStarttime(star);
meetingcontent.setEndtime(end);
meetingcontent.setIndexorno(new Integer(meeting.getIsindex()));
if (meeting.getMeetinchargeleader() != null && !meeting.getMeetinchargeleader().equals(""))
{
meetingcontent.setAudituser(new Integer(Integer.parseInt(meeting.getMeetinchargeleader())));
}
if (meeting.getMeetingleaderid() != null && !meeting.getMeetingleaderid().equals(""))
{
meetingcontent.setMeetingleaders(meeting.getMeetingleaderid());
}
if (meeting.getMeetingdepartid() != null && !meeting.getMeetingdepartid().equals(""))
{
meetingcontent.setMeetingusers(checkUsers(meeting.getMeetingleaderid(),meeting.getMeetingdepartid()));
//meetingcontent.setMeetingusers(meeting.getMeetingdepartid());
}
meetingcontent.setMeetingcontent(meeting.getMeetcontent());
if (meeting.getMeetoperaid() != null && !meeting.getMeetoperaid().equals(""))
{
meetingcontent.setMeetingcharge(new Integer(Integer.parseInt(meeting.getMeetoperaid())));
}
meetingcontent.setMeetingtitle(meeting.getMeettitle());
if (meeting.getMeetingType() != null && !meeting.getMeetingType().equals(""))
{
meetingcontent.setMeetingtype(new Integer(meeting.getMeetingType()));
}
meetingcontent.setSignify(new Integer(meeting.getImportant()));
meetingcontent.setRoomid(null);
meetingDao.save(meetingcontent, session);
}
/**
* 根据不同的条件返回分页查询的语句
* @param form Actionform
* @param session session
*/
public String getHql( AbstractForm form,
Session session)
{
MeetingcontentForm meeting = (MeetingcontentForm) form;
int userid = Integer.parseInt(meeting.getOaUserId());
String flag = meeting.getFlag();
String Hql = "";
if (flag.equals("noaccepted"))
{
// String sql = "select t.* from zboa_meetingcontent t where
// t.meetingstatus=0";
Hql = "from ZboaMeetingcontent meeting order by meeting.Starttime desc where meeting.Meetingstatus=0 and meeting.Audituser="
+ userid;
}
else if (flag.equals("accepted"))
{
Hql = "from ZboaMeetingcontent meeting order by meeting.Starttime desc where meeting.Meetingstatus=1";
}
/*
* else if(flag.equals("Noticed")){ Hql = "from ZboaMeetingcontent
* s,ZboaMeetinguser t where s.Meetingid=t.PKId.Meetingid and
* s.Meetingstatus=3" +" and t.PKId.Userid="+userid; }
*/
return Hql;
}
/**
* 数据筛选,如果参会领导id与参会人员id相同,就从参会人员id中去掉相同的id
* @param leader 参会领导
* @param users 参会人员
* @return
*/
public static String checkUsers( String leader,
String users)
{
String[] leadidtemp = leader.split(",");
String[] departidtemp = users.split(",");
String sv = "";
String person = "";
String ccc="";
String sss = users;
for (int i = 0; i < departidtemp.length; i++)
{
for (int j = 0; j < leadidtemp.length; j++)
{
sv = departidtemp[i];
if (leadidtemp[j].equals(sv))
{
int idx = sss.indexOf(departidtemp[i]);
int s = departidtemp[i].length();
String scn = sss.substring(0, idx);
if(idx==sss.length()-1||idx==sss.length()-2)
{
sss=scn;
}
else{
String svn = sss.substring(idx + s + 1, sss.length());
sss = scn + svn;
}
}
}
}
return sss;
}
/**
* 分页查询的结果
* @param List 执行结果后传回来的list
*/
protected List handleList(List listQueryResult) throws Exception
{
// Session session = SessionDAO.createSession();
List lst = new ArrayList();
for (int i = 0; i < listQueryResult.size(); i++)
{
ZboaMeetingcontent meetingcontent = (ZboaMeetingcontent) listQueryResult.get(i);
// Object[] group = (Object[]) listQueryResult.get(i);
// ZboaMeetingcontent meetingcontent = (ZboaMeetingcontent)
// group[0];
MeetingcontentForm meeting = new MeetingcontentForm();
meeting.setId((meetingcontent.getMeetingid()).intValue());
meeting.setMeettitle(meetingcontent.getMeetingtitle());
// meeting.setStarttime(Tools.getDateTimeString(meetingcontent.getStarttme()));
// meeting.setEndtime(Tools.getDateTimeString(meetingcontent.getEndtime()));
meeting.setStarttime(Tools.getDateTimeString((meetingcontent.getStarttime()).getTime()));
meeting.setEndtime(Tools.getDateTimeString((meetingcontent.getEndtime()).getTime()));
int signify = (meetingcontent.getSignify().intValue());
String important = "";
if (signify == 0)
{
important = FwConst.Meeting_impotr_sign_light;
}
else if (signify == 1)
{
important = FwConst.Meeting_impotr_sign_high;
}
meeting.setSigndeep(important);
int userid = (meetingcontent.getMeetingcharge()).intValue();
String username = JzdepartmentuserManger.IdtransName(userid);
meeting.setMeetopera(username);
ZboaMeetingroom rooms = meetingcontent.getRoomid();
if (rooms != null)
{
meeting.setMeetingaddress(rooms.getRoomaddress());
meeting.setRoomname(rooms.getRoomname());
}
else
{
meeting.setMeetingaddress("");
meeting.setRoomname("");
}
lst.add(meeting);
}
return lst;
}
/**
* 检测安排的会议室是否与已安排的会议室相冲突,不冲突返回true,冲突返回false
*/
public static boolean checkArrang(ActionForm form) throws Exception
{
Session session = SessionDAO.createSession();
boolean flag = false;
MeetingcontentForm meeting = (MeetingcontentForm) form;
int roomid = Integer.parseInt(meeting.getRoomid());
String date = meeting.getMeetingDate();
String inittime = date + " " + "08:00:00";
String overtime = date + " " + "17:30:00";
String startime = meeting.getStarttime();
String endtime = meeting.getEndtime();
String sqls = "from ZboaMeetingcontent meeting where meeting.Roomid=" + roomid
+ " and meeting.Starttime between to_date('" + startime + "', 'YYYY-MM-DD HH24:MI:SS')"
+ " and to_date('" + endtime + "', 'YYYY-MM-DD HH24:MI:SS')" + " and meeting.Meetingstatus in (2,3) ";
String sqle = "from ZboaMeetingcontent meeting where meeting.Roomid=" + roomid
+ " and meeting.Endtime between to_date('" + startime + "', 'YYYY-MM-DD HH24:MI:SS')"
+ " and to_date('" + endtime + "', 'YYYY-MM-DD HH24:MI:SS')" + " and meeting.Meetingstatus in (2,3) ";
Query query1 = session.createQuery(sqls);
Query query2 = session.createQuery(sqle);
List lst = query1.list();
List led = query2.list();
if (lst.size() == 0 && led.size() == 0)
{
flag = true;
}
else
{
flag = false;
}
return flag;
}
/**
* 显示会议室安排情况,根据不同的会议室id号得到所有会议室的某一天的具体会议安排时间
* @param form
* @return
* @throws Exception
*/
public static List ShowRoom(ActionForm form) throws Exception
{
Session session = SessionDAO.createSession();
MeetingcontentForm meeting = (MeetingcontentForm) form;
String date = meeting.getMeetingDate();
String hql = " from ZboaMeetingroom";
Query query1 = session.createQuery(hql);
List st = query1.list();
List lsn = new ArrayList();
if (st != null && st.size() > 0)
{
for (int i = 0; i < st.size(); i++)
{
ZboaMeetingroom room = (ZboaMeetingroom) st.get(i);
MeetingcontentForm meet = new MeetingcontentForm();
int roomid = room.getRoomid().intValue();
meet.setRoomid(Integer.toString(roomid));
meet.setRoomname(room.getRoomname());
String stime = getStartTime(roomid, date, session);
String etime = getEndTime(roomid, date, session);
meet.setStarttime(stime);
meet.setEndtime(etime);
lsn.add(meet);
}
}
return lsn;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -