package com.slcf.service.impl; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.slcf.bean.MeetingCondition; import com.slcf.dao.MeetingDao; import com.slcf.pojo.ConsumerBean; import com.slcf.pojo.GroupBean; import com.slcf.pojo.MeetingBean; import com.slcf.pojo.MeetingConsumerBean; import com.slcf.service.MeetingService; import com.slcf.util.Trees; import com.slcf.util.ViewTree; @Service public class MeetingServiceImpl implements MeetingService { @Autowired MeetingDao meetingDao; public boolean checkMeetingNo(String no, String id) { boolean flag=false; MeetingBean meeting=meetingDao.getMeetingByNo(no); if(!id.equals("")){//修改 if(meeting==null||(meeting!=null&&no.equals(id))){ flag=true; } }else{//添加 if(meeting==null){ flag=true; } } return flag; } public MeetingBean quertMeetingByNo(String meetingNo) { return meetingDao.quertMeetingByNo(meetingNo); } public int delMeetingByNo(String meetingNo) { return meetingDao.delMeetingByNo(meetingNo); } public boolean upMeeting(MeetingBean meetingBean) { boolean flag=false; int i=meetingDao.upMeeting(meetingBean); if(i>0){ flag=true; } return flag; } public boolean saveMeeting(MeetingBean meetingBean) { boolean flag=true; int i=meetingDao.saveMeeting(meetingBean); if(i>0){ flag=true; } return flag; } // public Map getMeetingList(int pageNumber, int pageSize) { // Mapmap=new HashMap(); // Listlist=meetingDao.getMeetingList((pageNumber-1)*pageSize,pageSize); //// Listlist=menuDao.getMenuList((pageNumber-1)*pageSize,pageNumber*pageSize); // int count =meetingDao.getCount(); // map.put("rows", list); // map.put("total", count); // return map; // } public Map getMeetingList(MeetingCondition meetingCon) { Mapmap=new HashMap(); Listlist=meetingDao.getMeetingList(meetingCon); // Listlist=menuDao.getMenuList((pageNumber-1)*pageSize,pageNumber*pageSize); int count =meetingDao.getCount(meetingCon); map.put("rows", list); map.put("total", count); return map; } /* * true表示没有查找到时间重复数据 */ public boolean checkMeetingDate(MeetingBean meetingBean) { boolean flag=false; int i=meetingDao.checkMeetingDate(meetingBean); if(i<=0){ flag=true; } return flag; } /** * 参会人员 * @param rid 会议编号 * @return */ public List getConsumerTree(String rid) { List tree=new ArrayList(); List list=meetingDao.queryConsumerByNo(rid); List glist=meetingDao.getGroupList();//部门 for(GroupBean g:glist){ ViewTree parent=new ViewTree(); parent.setId(g.getF_GroupID().intValue()); parent.setPid(0); parent.setText(g.getF_GroupName()); parent.setIcon("fa fa-home"); List clist= meetingDao.queryConsumerByGid(g.getF_GroupID());//子菜单 List childList= new ArrayList(); for(ConsumerBean c:clist){ ViewTree child=new ViewTree(); child.setId(c.getF_ConsumerID().intValue()); child.setPid(g.getF_GroupID().intValue()); child.setText(c.getF_ConsumerName()); child.setIcon("fa fa-home"); Integer k = c.getF_ConsumerID().intValue(); if(list.contains(k)) { Trees tt=new Trees(); tt.setChecked(true); child.setState(tt); } // for(Integer k:list){ // if(c.getF_ConsumerID().equals(k)){ // Trees tt=new Trees(); // tt.setChecked(true); // child.setState(tt); // } // } childList.add(child); } if(childList.size()>=1){ parent.setNodes(childList); } tree.add(parent); } return tree; } /** * 保存参会人员信息 * @param meetingNo * @param mid * @return */ public boolean saveMeetingConsumer(String meetingNo, int[] mid) { boolean flag=false; int sum=0; List mcList=meetingDao.queryMeetingConsumer(meetingNo); if(mcList!=null&&mcList.size()>0){ int x=meetingDao.delMeetingConsumer(meetingNo); if(x>0){ for(Integer i:mid){ int j=meetingDao.saveMeetingConsumer(meetingNo, i); sum+=j; } if(sum==mid.length){ flag=true; } } }else{ for(Integer i:mid){ int j=meetingDao.saveMeetingConsumer(meetingNo, i); sum+=j; } if(sum==mid.length){ flag=true; } } return flag; } }