王佳豪
2021-06-26 718f604deb342b0bee6c588bb44e22ced3371fb8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
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<String,Object> getMeetingList(int pageNumber, int pageSize) {
//        Map<String,Object>map=new HashMap<String, Object>();
//        List<MeetingBean>list=meetingDao.getMeetingList((pageNumber-1)*pageSize,pageSize);
////        List<MenuBean>list=menuDao.getMenuList((pageNumber-1)*pageSize,pageNumber*pageSize);
//        int count =meetingDao.getCount();
//        map.put("rows", list);
//        map.put("total", count);
//        return map;
//    }    
    public Map<String,Object> getMeetingList(MeetingCondition meetingCon) {
        Map<String,Object>map=new HashMap<String, Object>();
        List<MeetingBean>list=meetingDao.getMeetingList(meetingCon);
//        List<MenuBean>list=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<ViewTree> getConsumerTree(String rid) {
        List<ViewTree> tree=new ArrayList<ViewTree>();
        List<Integer> list=meetingDao.queryConsumerByNo(rid);
        List<GroupBean> 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<ConsumerBean > clist= meetingDao.queryConsumerByGid(g.getF_GroupID());//子菜单
            List<ViewTree> childList= new ArrayList<ViewTree>();
            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<MeetingConsumerBean> 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;
    }
    
}