Browse Source

先提交一下啊,正在改。。。

lgy 6 years ago
parent
commit
b674779838

+ 60 - 4
src/main/java/com/persagy/controller/OrdinaryController.java

@@ -7,6 +7,7 @@ import com.persagy.domain.ReservationVo;
 import com.persagy.domain.Room;
 import com.persagy.domain.Room;
 import com.persagy.service.ReservationService;
 import com.persagy.service.ReservationService;
 import com.persagy.service.RoomService;
 import com.persagy.service.RoomService;
+import com.persagy.service.UserService;
 import com.persagy.util.PinyinUtils;
 import com.persagy.util.PinyinUtils;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPost;
@@ -36,7 +37,8 @@ public class OrdinaryController {
 
 
     @Resource(name = "roomServiceImpl")
     @Resource(name = "roomServiceImpl")
     private RoomService roomService;
     private RoomService roomService;
-
+    @Resource(name = "userServiceImpl")
+    private UserService userService;
     @Resource(name = "reservationServiceImpl")
     @Resource(name = "reservationServiceImpl")
     private ReservationService reservationService;
     private ReservationService reservationService;
     //获取CorpAccessToken URL
     //获取CorpAccessToken URL
@@ -86,6 +88,7 @@ public class OrdinaryController {
     private Room queryRoomById(@RequestBody String roomID) throws Exception {
     private Room queryRoomById(@RequestBody String roomID) throws Exception {
         JSONObject jsonObject = JSONObject.parseObject(roomID);
         JSONObject jsonObject = JSONObject.parseObject(roomID);
         Integer id = jsonObject.getInteger("roomID");
         Integer id = jsonObject.getInteger("roomID");
+        String date = jsonObject.getString("date");
         Room room = roomService.findById(id);
         Room room = roomService.findById(id);
         return room;
         return room;
     }
     }
@@ -154,7 +157,6 @@ public class OrdinaryController {
         JSONObject jsonObject = JSONObject.parseObject(reservation);
         JSONObject jsonObject = JSONObject.parseObject(reservation);
         String roomName = jsonObject.getString("roomName");
         String roomName = jsonObject.getString("roomName");
         int roomId = jsonObject.getIntValue("roomId");
         int roomId = jsonObject.getIntValue("roomId");
-        int userID = jsonObject.getIntValue("userID");
         int alarmminute = jsonObject.getIntValue("alarmminute");
         int alarmminute = jsonObject.getIntValue("alarmminute");
         String userName = jsonObject.getString("userName");
         String userName = jsonObject.getString("userName");
         String department = jsonObject.getString("department");
         String department = jsonObject.getString("department");
@@ -167,6 +169,7 @@ public class OrdinaryController {
             String date = json.getString("date");
             String date = json.getString("date");
             String beginTime = json.getString("beginTime");
             String beginTime = json.getString("beginTime");
             String endTime = json.getString("endTime");
             String endTime = json.getString("endTime");
+//            String a = date+""+
             ReservationCustom reservationCustom = new ReservationCustom();
             ReservationCustom reservationCustom = new ReservationCustom();
             reservationCustom.setDate(date);
             reservationCustom.setDate(date);
             reservationCustom.setBeginTime(beginTime);
             reservationCustom.setBeginTime(beginTime);
@@ -183,7 +186,35 @@ public class OrdinaryController {
             reservationCustom.setAlarmminute(alarmminute);
             reservationCustom.setAlarmminute(alarmminute);
             reservationService.addReservation(reservationCustom);
             reservationService.addReservation(reservationCustom);
         }
         }
+        //发送消息
+        //0. 获取所有人员
+        JSONObject result = new JSONObject();
+        JSONArray users = new JSONArray();
+        users.add(userService.findUserById(userName).getFsuid());
+        if(enterUsers !=null){
+            for (int i = 0; i < enterUsers.size(); i++) {
+                JSONObject object = enterUsers.getJSONObject(i);
+                String id = object.getString("id");
+                users.add(id);
+            }
+        }
+        result.put("users",users);
+       JSONObject message = new JSONObject();
+        JSONObject head = new JSONObject();
+        head.put("title","会议参加提醒");
+        JSONObject first = new JSONObject();
+        head.put("first","欢迎参加“"+userName+"”组织的【"+theme+"】会议,会议将于");
+//        message.put("head,new )
+//        {
+//            "head":{
+//            "title":"会议室提醒"
+//        },
+//            "first":{
+//            "content":"2019-08-24"
+//        }
 
 
+        result.put("text","theme");
+//        sendMessage(result.toString());
 
 
         return "success";
         return "success";
     }
     }
@@ -199,11 +230,34 @@ public class OrdinaryController {
 
 
     //取消预约申请业务实现
     //取消预约申请业务实现
     @RequestMapping(value = "/cancelApply", method = RequestMethod.POST)
     @RequestMapping(value = "/cancelApply", method = RequestMethod.POST)
-    public String cancelApplication(@RequestBody String id) throws Exception{
+    public ReservationVo cancelApplication(@RequestBody String id) throws Exception{
         JSONObject jsonObject = JSONObject.parseObject(id);
         JSONObject jsonObject = JSONObject.parseObject(id);
         Integer cancelID = jsonObject.getInteger("id");
         Integer cancelID = jsonObject.getInteger("id");
         reservationService.cancelApplication(cancelID);
         reservationService.cancelApplication(cancelID);
-        return "success";
+
+        ReservationVo reservationVo =reservationService.findByReservationId(cancelID);
+        String user = reservationVo.getUser();
+        String theme =reservationVo.getTheme();
+
+        String StringEnterUsers = reservationVo.getEnterUsers();
+        JSONArray enterUsers = JSONArray.parseArray(StringEnterUsers);
+        //发送消息
+        //0. 获取所有人员
+        JSONObject result = new JSONObject();
+        JSONArray users = new JSONArray();
+        users.add(user);
+        if(enterUsers!=null){
+            for (int i = 0; i < enterUsers.size(); i++) {
+                JSONObject object = enterUsers.getJSONObject(i);
+                String uid= object.getString("id");
+                users.add(uid);
+            }
+        }
+        result.put("users",users);
+        result.put("text","取消会议:"+theme);
+        sendMessage(result.toString());
+
+        return reservationVo;
     }
     }
     //获取数字签名
     //获取数字签名
     public void getSignature() throws Exception{
     public void getSignature() throws Exception{
@@ -368,6 +422,8 @@ public class OrdinaryController {
         String text = jsonObject.getString("text");
         String text = jsonObject.getString("text");
         //发送人
         //发送人
         JSONArray users = jsonObject.getJSONArray("users");
         JSONArray users = jsonObject.getJSONArray("users");
+
+
 //        JSONArray users = new JSONArray();
 //        JSONArray users = new JSONArray();
 //        users.add("FSUID_782A9585B3CEB91B9DC0C709FA4D3119");
 //        users.add("FSUID_782A9585B3CEB91B9DC0C709FA4D3119");
 
 

+ 2 - 0
src/main/java/com/persagy/dao/ReservationMapper.java

@@ -19,6 +19,8 @@ public interface ReservationMapper {
 
 
     public List<ReservationVo> findByRoomId(Integer id);
     public List<ReservationVo> findByRoomId(Integer id);
 
 
+    public ReservationVo findByReservationId(Integer id);
+
     public Integer reservationPassCount();
     public Integer reservationPassCount();
 
 
     public List<ReservationVo> findRecord(PagingVO pagingVO);
     public List<ReservationVo> findRecord(PagingVO pagingVO);

+ 10 - 2
src/main/java/com/persagy/dao/ReservationMapper.xml

@@ -36,6 +36,11 @@
         WHERE date>DATE_SUB(curdate(),INTERVAL 1 DAY) AND mark!='取消申请' AND a.room_id=#{id} ORDER BY id
         WHERE date>DATE_SUB(curdate(),INTERVAL 1 DAY) AND mark!='取消申请' AND a.room_id=#{id} ORDER BY id
     </select>
     </select>
 
 
+    <select id="findByReservationId" parameterType="int" resultType="com.persagy.domain.ReservationVo">
+        SELECT a.id ,a.date,a.begintime,a.endtime,a.`user`,a.mobile,a.mark,a.enterUsers,a.department,a.theme,a.alarmminute FROM reservation a
+        WHERE a.id=#{id} ORDER BY id
+    </select>
+
     <select id="reservationPassCount" resultType="int">
     <select id="reservationPassCount" resultType="int">
         SELECT count(*) FROM reservation a WHERE date BETWEEN CURDATE()-30 AND CURDATE() AND a.mark='审核通过' ORDER BY date DESC
         SELECT count(*) FROM reservation a WHERE date BETWEEN CURDATE()-30 AND CURDATE() AND a.mark='审核通过' ORDER BY date DESC
     </select>
     </select>
@@ -43,7 +48,7 @@
     <select id="findRecord" parameterType="com.persagy.domain.PagingVO" resultType="com.persagy.domain.ReservationVo">
     <select id="findRecord" parameterType="com.persagy.domain.PagingVO" resultType="com.persagy.domain.ReservationVo">
         SELECT a.id,b.`name` ,a.date,a.begintime,a.endtime,a.`user`,a.mobile,a.mark,a.enterUsers,a.department,a.theme,a.alarmminute FROM reservation a
         SELECT a.id,b.`name` ,a.date,a.begintime,a.endtime,a.`user`,a.mobile,a.mark,a.enterUsers,a.department,a.theme,a.alarmminute FROM reservation a
         LEFT JOIN room b on a.room_id=b.id
         LEFT JOIN room b on a.room_id=b.id
-        WHERE date BETWEEN CURDATE()-30 AND CURDATE() AND a.mark='审核通过' ORDER BY id
+        WHERE date BETWEEN CURDATE()-30 AND CURDATE() AND a.mark!='取消申请' ORDER BY id
         limit #{toPageNo}, #{pageSize}
         limit #{toPageNo}, #{pageSize}
     </select>
     </select>
 
 
@@ -59,7 +64,10 @@
 
 
     <insert id="addReservation" parameterType="com.persagy.domain.ReservationCustom">
     <insert id="addReservation" parameterType="com.persagy.domain.ReservationCustom">
         INSERT INTO reservation(user,mobile,date,begintime,endtime,mark,room_id,enterUsers,department,theme,alarmminute)
         INSERT INTO reservation(user,mobile,date,begintime,endtime,mark,room_id,enterUsers,department,theme,alarmminute)
-        SELECT #{user},#{mobile},#{date},#{beginTime},#{endTime},'待审核',id,#{enterUsers},#{department},#{theme},#{alarmminute} FROM room WHERE name=#{name}
+        SELECT #{user},u.phone,#{date},#{beginTime},#{endTime},'待审核',r.id,#{enterUsers},#{department},#{theme},#{alarmminute}
+        FROM room r
+        LEFT JOIN user u on u.id=#{user}
+        WHERE name=#{name}
     </insert>
     </insert>
 
 
     <select id="findByUser" parameterType="string" resultType="com.persagy.domain.ReservationCustom">
     <select id="findByUser" parameterType="string" resultType="com.persagy.domain.ReservationCustom">

+ 50 - 0
src/main/java/com/persagy/domain/Room.java

@@ -10,6 +10,56 @@ public class Room {
 
 
     private String message;
     private String message;
 
 
+    private String position;
+
+    private String image;
+
+    private String capacity;
+
+    private String region;
+
+    private String code;
+
+    public String getPosition() {
+        return position;
+    }
+
+    public void setPosition(String position) {
+        this.position = position;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getCapacity() {
+        return capacity;
+    }
+
+    public void setCapacity(String capacity) {
+        this.capacity = capacity;
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
     public int getId() {
     public int getId() {
         return id;
         return id;
     }
     }

+ 18 - 0
src/main/java/com/persagy/domain/User.java

@@ -9,6 +9,24 @@ public class User {
     private String password;
     private String password;
 
 
     private int role;
     private int role;
+    private String phone;
+    private String fsuid;
+
+    public String getPhone() {
+        return phone;
+    }
+
+    public void setPhone(String phone) {
+        this.phone = phone;
+    }
+
+    public String getFsuid() {
+        return fsuid;
+    }
+
+    public void setFsuid(String fsuid) {
+        this.fsuid = fsuid;
+    }
 
 
     public String getId() {
     public String getId() {
         return id;
         return id;

+ 6 - 0
src/main/java/com/persagy/service/ReservationService.java

@@ -95,4 +95,10 @@ public interface ReservationService {
      * @throws Exception
      * @throws Exception
      */
      */
     public void cancelApplication(Integer id) throws Exception;
     public void cancelApplication(Integer id) throws Exception;
+    /**
+     * 根据id查询预约记录
+     * @param id
+     * @throws Exception
+     */
+    public ReservationVo findByReservationId(Integer id);
 }
 }

+ 1 - 1
src/main/java/com/persagy/service/RoomService.java

@@ -35,7 +35,7 @@ public interface RoomService {
      * @return
      * @return
      * @throws Exception
      * @throws Exception
      */
      */
-    public Room findById(Integer id) throws Exception;
+    public Room findById(Integer id,String date) throws Exception;
 
 
     /**
     /**
      * 根据id更新会议室信息
      * 根据id更新会议室信息

+ 5 - 0
src/main/java/com/persagy/service/impl/ReservationServiceImpl.java

@@ -94,4 +94,9 @@ public class ReservationServiceImpl implements ReservationService {
     public void cancelApplication(Integer id) throws Exception {
     public void cancelApplication(Integer id) throws Exception {
         reservationMapper.cancelApplication(id);
         reservationMapper.cancelApplication(id);
     }
     }
+
+    @Override
+    public ReservationVo findByReservationId(Integer id) {
+        return reservationMapper.findByReservationId(id);
+    }
 }
 }

+ 1 - 1
src/main/java/com/persagy/service/impl/RoomServiceImpl.java

@@ -37,7 +37,7 @@ public class RoomServiceImpl implements RoomService {
     }
     }
 
 
     @Override
     @Override
-    public Room findById(Integer id) throws Exception {
+    public Room findById(Integer id,String date) throws Exception {
         return roomMapper.findById(id);
         return roomMapper.findById(id);
     }
     }