首页>代码>springboot+mybatis+Maven+jsp+Quartz整合实战林业厅项目>/ah_lyt/src/main/java/com/ct/ring/action/MeetingAction.java
package com.ct.ring.action;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.ct.ring.dto.Meeting;
import com.ct.ring.dto.MeetingIssue;
import com.ct.ring.dto.Room;
import com.ct.ring.dto.User;
import com.ct.ring.service.MeetingIssueService;
import com.ct.ring.service.MeetingService;
import com.ct.ring.service.PersonService;
import com.ct.ring.service.RoomService;
import com.ct.ring.util.ExcelUtils;
import com.ct.ring.util.SmApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.nio.charset.MalformedInputException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Controller
@EnableAutoConfiguration
@RequestMapping("/meeting")
public class MeetingAction {
    protected static Logger logger = LoggerFactory.getLogger(Meeting.class);

    @Autowired
    private RoomService roomService;
    @Autowired
    private MeetingService meetingService;

    @Autowired
    private PersonService personService;

    @Autowired
    private MeetingIssueService meetingIssueService;

    @Autowired
    private ExcelUtils excelUtils;
    @Autowired
    private SmApi smApi;

    @RequestMapping("/index")
    public ModelAndView index ( HttpServletRequest request ) {
        List<Room> roomList=roomService.getRoomPageAll("","");
        ModelAndView mv = new ModelAndView( "meeting/index2" );
        mv.addObject("roomList",roomList);
        return mv;
    }

    @RequestMapping("/index2")
    public ModelAndView index2 ( HttpServletRequest request ) {
        List<Room> roomList=roomService.getRoomPageAll("","");
        ModelAndView mv = new ModelAndView( "meeting/index" );
        mv.addObject("roomList",roomList);
        return mv;
    }

    @RequestMapping("/getMeetingPages")
    @ResponseBody
    public Map getMeetingPages ( HttpServletRequest request ) {
        Map<String, Object> map = new HashMap<String, Object>();
        List<Map> meetingListAll =new ArrayList<Map>( );

        String hymc=request.getParameter( "hymc" );
        String hysj=request.getParameter( "hysj" );

        int mRid=Integer.valueOf(request.getParameter( "mRid" ));
        int pageIndex=Integer.valueOf( request.getParameter( "pageindex" ) );
        int pageSize=Integer.valueOf( request.getParameter( "pageSize" ) );
        List<Map> meetingList = meetingService.getMeetingPages(hymc,hysj,mRid,pageIndex,pageSize);

        if(meetingList!=null&&meetingList.size()>0){
            for(Map m :meetingList){
                Map<String,Object> pmap= new HashMap<String, Object>();
                pmap.put( "Id",m.get( "id" ).toString());
                pmap.put( "Name",m.get( "m_name" ).toString() );
                pmap.put( "Startime",m.get( "m_startime" ).toString());
                pmap.put( "Leaders",m.get( "m_host" ).toString() );
                pmap.put( "publicName",m.get( "leaders" ).toString() );
                pmap.put( "ParentId","" );
                pmap.put( "Level",1 );
                pmap.put( "status","");

                meetingListAll.add( pmap );
                //获取议题名称

                 List<MeetingIssue> issueMapList =meetingIssueService.getMeetingIssueGroudByMid(Integer.valueOf( m.get( "id" ).toString() ));
                 if(issueMapList.size()>0&&issueMapList!=null){
                     for (MeetingIssue meetingIssue: issueMapList){
                         Map<String,Object> cmap= new HashMap<String, Object>();
                         cmap.put( "Id",meetingIssue.getId());
                         cmap.put( "Name",meetingIssue.getIssueName() );
                         cmap.put( "Startime","");
                         cmap.put( "Leaders","");
                         cmap.put( "publicName",meetingIssue.getmPublishedName()  );
                         cmap.put( "ParentId",meetingIssue.getmId() );
                         cmap.put( "status",meetingIssue.getStatus() );
                         cmap.put( "Level",2 );

                         meetingListAll.add( cmap );
                     }
                 }
            }
        }


        List<Map> meetingListAll2 = meetingService.getMeetingPageAll(hymc,hysj,mRid);
        map.put( "totalCount",meetingListAll2.size() );
        map.put( "result" ,meetingListAll);
        map.put( "page" ,pageIndex);
        return map;
    }


    @RequestMapping("/addMeeting")
    public ModelAndView addRoom ( HttpServletRequest request ) {
        List<Room> roomList=roomService.getRoomPageAll("","");
        ModelAndView mv = new ModelAndView( "meeting/addMeeting" );
        mv.addObject("roomList",roomList);
        return mv;
    }

    @RequestMapping("/saveMeeting")
    @ResponseBody
    public Map saveMeeting ( HttpServletRequest request, Meeting meeting) {
        Map<String, Object> map = new HashMap<String, Object>();
        //表更新数据
        User user = ( User) request.getSession().getAttribute("currentUser");
        meeting.setmUid(user.getId());

        int i= meetingService.saveMeeting(meeting);
        if (i > 0) {
            int mid=meeting.getId();
            String[] arrayPId =null;
            String[] arrayPName =null;
            String[] arrayVId =null;
            String[] arrayVName =null;

            if(request.getParameter( "arrayPName" )!=null&&request.getParameter( "arrayPName" )!=""){
                arrayPId =request.getParameter( "arrayPId" ).split( "," );
                arrayPName =request.getParameter( "arrayPName" ).split( "," );

            }
            if(request.getParameter( "arrayVName" )!=null&&request.getParameter( "arrayVName" )!=""){
               arrayVId =request.getParameter( "arrayVId" ).split( "," );
               arrayVName =request.getParameter( "arrayVName" ).split( "," );
            }

            String[] arrayTName=request.getParameter( "arrayTyName" ).split( "," );

            for (int k=0;k<arrayTName.length;k++){
                MeetingIssue meetingIssue =new MeetingIssue();
                if( arrayTName[k].equals( "kong" )){
                    meetingIssue.setIssueName( "" );
                }else {
                    meetingIssue.setIssueName( arrayTName[k] );
                }

                //获取人员
                if( arrayPId[k].equals( "kong" )){
                    meetingIssue.setmPublished( "" );
                }else {
                    meetingIssue.setmPublished( arrayPId[k] );
                }

                if( arrayPName[k].equals( "kong" )){
                    meetingIssue.setmPublishedName( "" );
                }else {
                    meetingIssue.setmPublishedName( arrayPName[k] );
                }
                if( arrayVId[k].equals( "kong" )){
                    meetingIssue.setmInvolve( "" );
                }else {
                    meetingIssue.setmInvolve( arrayVId[k] );
                }
                if( arrayVName[k].equals( "kong" )){
                    meetingIssue.setmInvolveName( "" );
                }else {
                    meetingIssue.setmInvolveName( arrayVName[k] );
                }

                meetingIssue.setmId( mid );
                meetingIssue.setStatus( 0 );
                meetingIssue.setSort( k+1 );
                meetingIssueService.saveMeetingIssue(meetingIssue);
            }
            map.put("status", true);
        } else {
            map.put("message", "保存失败!");
            map.put("status", false);
        }
        return map;
    }

    @RequestMapping("/editMeeting/{id}")
    @ResponseBody
    public ModelAndView editMeeting (@PathVariable(value = "id") String meetingId ) {
        List<Meeting> list =meetingService.getMeetingById(meetingId);
        Meeting meeting =list.get( 0 );
        List<MeetingIssue> issueList=meetingIssueService.getMeetingIssueByRid(Integer.valueOf( meetingId ));
        List<Room> roomList=roomService.getRoomPageAll("","");
        ModelAndView mv = new ModelAndView( "meeting/editMeeting" );
        if( meeting.getmRemark()!=null){
            meeting.setmRemark( meeting.getmRemark().replace( "\n","" ) );
        }
        mv.addObject("roomList",roomList);
        mv.addObject("meeting",meeting);
        mv.addObject( "issueList" ,issueList);
        return mv;
    }

    @RequestMapping("/updateMeeting")
    @ResponseBody
    public Map updateMeeting ( HttpServletRequest request, Meeting meeting ) {
        Map<String, Object> map = new HashMap<String, Object>();
        meeting.setmRemark( request.getParameter( "mRemark" ) );

        //表更新数据
        int i= meetingService.updateMeeting(meeting);

        if (i > 0) {
            int mid=meeting.getId();
            //删除子表数据
            meetingIssueService.delIssue(mid);

            String[] arrayPId =null;
            String[] arrayPName =null;
            String[] arrayVId =null;
            String[] arrayVName =null;

            if(request.getParameter( "arrayPName" )!=null&&request.getParameter( "arrayPName" )!=""){
                arrayPId =request.getParameter( "arrayPId" ).split( "," );
                arrayPName =request.getParameter( "arrayPName" ).split( "," );

            }
            if(request.getParameter( "arrayVName" )!=null&&request.getParameter( "arrayVName" )!=""){
                arrayVId =request.getParameter( "arrayVId" ).split( "," );
                arrayVName =request.getParameter( "arrayVName" ).split( "," );
            }

            String[] arrayTName=request.getParameter( "arrayTyName" ).split( "," );

            for (int k=0;k<arrayTName.length;k++){
                MeetingIssue meetingIssue =new MeetingIssue();
                if( arrayTName[k].equals( "kong" )){
                    meetingIssue.setIssueName( "" );
                }else {
                    meetingIssue.setIssueName( arrayTName[k] );
                }

                //获取人员
                if( arrayPId[k].equals( "kong" )){
                    meetingIssue.setmPublished( "" );
                }else {
                    meetingIssue.setmPublished( arrayPId[k] );
                }

                if( arrayPName[k].equals( "kong" )){
                    meetingIssue.setmPublishedName( "" );
                }else {
                    meetingIssue.setmPublishedName( arrayPName[k] );
                }
                if( arrayVId[k].equals( "kong" )){
                    meetingIssue.setmInvolve( "" );
                }else {
                    meetingIssue.setmInvolve( arrayVId[k] );
                }
                if( arrayVName[k].equals( "kong" )){
                    meetingIssue.setmInvolveName( "" );
                }else {
                    meetingIssue.setmInvolveName( arrayVName[k] );
                }

                meetingIssue.setmId( mid );
                meetingIssue.setStatus( 0 );
                meetingIssue.setSort( k+1 );
                System.out.println( "------update------" );
                meetingIssueService.saveMeetingIssue(meetingIssue);
            }
            map.put("status", true);
        } else {
            map.put("message", "修改失败!");
            map.put("status", false);
        }
        return map;
    }


    /*@RequestMapping("/delMeeting")
    @ResponseBody
    public Map delMeeting ( HttpServletRequest request ) {
        Map<String, Object> map = new HashMap<String, Object>();
        int i =meetingService.delMeetingById(request.getParameter( "meetingId" ));
        if (i > 0) {
            map.put("status", true);
        } else {
            map.put("message", "删除失败!");
            map.put("status", false);
        }
        return map;
    }*/

    // 删除用户信息
    @RequestMapping("/delMeetings")
    public @ResponseBody Map dels(@RequestParam("ids") String ids) {
        Map<String, Object> map = new HashMap<String, Object>();
        String[] array =ids.split(",");
        int k=0;
        for(int j=0;j<array.length;j++){
            MeetingIssue  meetingIssue =meetingIssueService.getMeetingIssueById( Integer.valueOf( array[j] ) ).get( 0 );
            List<MeetingIssue> list =meetingIssueService.getMeetingIssueGroudByMid( meetingIssue.getmId() );
            List<MeetingIssue> upList =new ArrayList<MeetingIssue>();//获取目标之后数组   
            int index=0;//数组下标
            for(int i=0;i<list.size();i++){
                if(list.get( i ).getId()==meetingIssue.getId()){
                    index=i;
                }
            }
            meetingIssueService.delIssue( meetingIssue.getId() );//删除当前数据

            upList=list.subList((index+1),list.size() );
            for(MeetingIssue m : upList){
                int sort=m.getSort()-1;
                m.setSort(sort);
                k=meetingIssueService.updateMeetingIssue(m);
            }

        }

        if (k > 0) {
            map.put("status", true);
        } else {
            map.put("message", "删除失败!");
            map.put("status", false);
        }
        return map;
    }

    @RequestMapping("/updateMeetingStatus")
    @ResponseBody
    public Map updateMeetingStatus ( HttpServletRequest request ) {
        Map<String, Object> map2 = new HashMap<String, Object>();
        MeetingIssue m= meetingIssueService.getMeetingIssueById( Integer.valueOf( request.getParameter( "id" ) )).get( 0 );
        m.setStatus( 2 );
        int k=meetingIssueService.updateMeetingIssue( m );
        if (k > 0) {
            /**
             *结束会议同时 发送下下一个会议的议题短信通知
             */
            String dxmeg =request.getParameter( "dxmeg" );//短信内容

            Meeting meeting=meetingService.getMeetingById( String.valueOf( m.getmId() ) ).get( 0 );
            List<Map> nextList=meetingService.getNextMeetingNotice(m.getSort(),Integer.valueOf( meeting.getmRid() ));

            if(nextList.size()>0&&nextList!=null){
                //更新状态
                MeetingIssue meetingIssue =new MeetingIssue();
                meetingIssue.setId( Integer.valueOf( nextList.get( 0 ).get( "id" ).toString()));
                meetingIssue.setStatus( 1 );
                meetingIssueService.updateMeetingIssue( meetingIssue );

                List<Map> nextDoubleList=meetingService.getNextMeetingNotice(Integer.valueOf( nextList.get( 0 ).get( "sort" ).toString()),Integer.valueOf( request.getParameter( "rid" ) ));
                 if(nextDoubleList.size()>0&&nextDoubleList!=null){

                     for (int i=0;i<nextDoubleList.size();i++){
                         String firstNumberP="";
                         String firstNumberV="";

                         String[] array =nextDoubleList.get( i ).get( "m_published" ).toString().split( "," );
                         for (int j=0;j<array.length;j++){
                             List<Map> personList =personService.getPersonById( Integer.valueOf( array[j] ) );
                             if(personList.size()>0&&personList!=null){
                                 System.out.println("参会人员----------------------------");
                                 String phoneNumber= personList.get( 0 ).get( "phoneNumber" ).toString();
                                 firstNumberP+=phoneNumber+",";
                             }
                         }

                         String[] arrayV=nextDoubleList.get( i ).get( "m_involve" ).toString().split( "," );
                         for (int r=0;r<arrayV.length;r++){
                             List<Map> personList =personService.getPersonById( Integer.valueOf( arrayV[r] ) );
                             if(personList.size()>0&&personList!=null){
                                 String phoneNumber= personList.get( 0 ).get( "phoneNumber" ).toString();
                                 System.out.println("涉及人员----------------------------"+phoneNumber);
                                 firstNumberV+=phoneNumber+",";
                             }
                         }

                         if(dxmeg==""&&dxmeg==null){
                             dxmeg="您即将有场会议,请准时参加!";
                         }

                         smApi.sendSM(firstNumberP.substring( 0,firstNumberP.lastIndexOf( "," ) ),dxmeg,excelUtils.random(),excelUtils.random() );
                         smApi.sendSM(firstNumberV.substring( 0,firstNumberV.lastIndexOf( "," ) ),dxmeg,excelUtils.random(),excelUtils.random() );

                     }
                 }
            }

            map2.put("status", true);
        } else {
            map2.put("message", "会议结束失败!");
            map2.put("status", false);
        }
        return map2;
    }

    /*@RequestMapping("/upMeeting")
    @ResponseBody
    public Map upMeeting ( HttpServletRequest request ) {
        Map<String, Object> map = new HashMap<String, Object>();
        Meeting m= meetingService.getMeetingById( request.getParameter( "meetingId" )).get( 0 );
        if(request.getParameter( "key" ).equals( "play" )){
            m.setStatus( 1 );
        }
        if(request.getParameter( "key" ).equals( "pause" )){
            m.setStatus( 2 );
        }

        int i=meetingService.updateMeeting( m );
        if (i > 0) {
            map.put("status", true);
        } else {
            map.put("message", "会议启动失败!");
            map.put("status", false);
        }
        return map;
    }*/


   /* @RequestMapping("getCurrentMeetingNotice")
    @ResponseBody
    public Map getCurrentMeetingNotice ( HttpServletRequest request ) {
        Map<String, Object> map = new HashMap<String, Object>();
        Map<String, Object> m = new HashMap<String, Object>();
        List<Map> list= meetingService.getCurrentMeetingNotice();
        List<Map> listMap= new ArrayList<Map>( );
        for (int i=0;i<list.size();i++){
            System.out.println(list.get( i ).get( "m_endtime" ).toString()+"------------");
            //结束前5分钟通知开会人员
            int min=meetingService.getMin(list.get( i ).get("m_endtime" ).toString());
            if(min<=5&&min>4){
                System.out.println("页面提示----------------------------");
                m.put("id",list.get( i ).get("id" ));
                m.put("mName",list.get( i ).get( "m_name" ));
                m.put("mrName",list.get( i ).get( "mrName" ));
                listMap.add( m );
            }
        }
        if(listMap.size()>0){
            map.put( "status",true );
            map.put( "result",listMap );
        }else{
            map.put( "status",false );
        }
        return map;
    }
*/


    @RequestMapping("/sortMeeting")
    @ResponseBody
    public Map sortMeeting ( String targetId, String sourceId,String point,HttpServletRequest request ) {
        Map<String, Object> map = new HashMap<String, Object>();
        MeetingIssue m1=meetingIssueService.getMeetingIssueById( Integer.valueOf( targetId ) ).get( 0 );
        MeetingIssue m2=meetingIssueService.getMeetingIssueById( Integer.valueOf( sourceId) ).get( 0 );
        List<MeetingIssue> list =meetingIssueService.getMeetingIssueGroudByMid(m1.getmId());
        List<MeetingIssue> upList =new ArrayList<MeetingIssue>();//获取目标之后数组    上移动
        List<MeetingIssue> downList =new ArrayList<MeetingIssue>();//获取目标之后数组    下移动
        int targetCode=0;
        int sourceCode=0;
        int puSort1=m1.getSort();//目标序号
        int status1=m1.getStatus();
        int status2=m2.getStatus();
        if(m1.getmId()==m2.getmId()){
            //已结束的会议 不变更序号
            if(status1==0&&status2==0){
                for(int i=0;i<list.size();i++){
                    if(list.get( i ).getId()==Integer.valueOf( targetId )){
                        targetCode=i;
                    }
                    if(list.get( i ).getId()==Integer.valueOf( sourceId )){
                        sourceCode=i;
                    }
                }
                if(targetCode<sourceCode){//上移动
                    list.remove(sourceCode);
                    upList=list.subList((targetCode+1),list.size() );
                    if(m1!=null&&m2!=null&&point!=null){
                        if(point.equals( "top" )){
                            m1.setSort(puSort1+1);
                            m2.setSort(puSort1);
                            meetingIssueService.updateMeetingIssue( m1 );
                            meetingIssueService.updateMeetingIssue(m2);
                        }
                        int i=2;
                        for(MeetingIssue m : upList){
                            m.setSort(puSort1+i);
                            meetingIssueService.updateMeetingIssue(m);
                            i++;
                        }
                        map.put( "status",true );
                        map.put("message", "操作成功!");
                    }
                }else if(targetCode>sourceCode){	//下移动
                    downList=list.subList((sourceCode+1),targetCode );
                    if(m1!=null&&m2!=null&&point!=null){
                        if(point.equals( "top" )){
                            m1.setSort(puSort1-1);
                            m2.setSort(puSort1);
                            meetingIssueService.updateMeetingIssue( m1 );
                            meetingIssueService.updateMeetingIssue(m2);
                        }
                        for(MeetingIssue m : downList){
                            m.setSort(puSort1-2);
                            meetingIssueService.updateMeetingIssue(m);
                        }
                        map.put( "status",true );
                        map.put("message", "!");
                    }
                }else{
                    map.put( "status",false );
                    map.put("message", "操作失败!");
                }
            }else{
                map.put( "status",false );
                map.put("message", "未开始的议题之间可以相互调整!");
            }
        }else{
            map.put( "status",false );
            map.put("message", "请选择同一个会议中的议题,再拖动!");
        }
        return map;
    }
}
最近下载更多
提灯寻白鹿  LV3 5月29日
skipple3  LV39 2023年10月25日
烟雨晨风  LV1 2022年11月30日
wy4525  LV6 2022年8月12日
tangjj7260  LV18 2022年4月25日
171337601  LV9 2022年4月18日
shuangcen  LV1 2022年1月4日
没朋友的键盘侠  LV8 2022年1月1日
wanjiale  LV3 2021年9月18日
lironggang  LV38 2021年8月16日
最近浏览更多
沈从文  LV3 6月17日
提灯寻白鹿  LV3 5月29日
guaixia163  LV13 4月7日
java小书童  LV18 1月18日
admin_z  LV22 2023年12月22日
XNDIC522 2023年11月6日
暂无贡献等级
skipple3  LV39 2023年10月25日
张朕朕  LV3 2023年9月10日
huangtian  LV3 2023年7月11日
171337601  LV9 2023年6月28日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友