xiao547607 5 роки тому
батько
коміт
a23e8c85a6

+ 54 - 12
src/main/java/com/jpsoft/smart/modules/base/controller/AlarmInfoController.java

@@ -26,9 +26,33 @@ public class AlarmInfoController {
     @PostMapping("alarmNotify")
     public MessageResult<String> alarmNotify(String message){
         MessageResult<String> msgResult = new MessageResult<>();
-
         logger.info(message);
+        try {
+            AlarmInfo alarmInfo = new AlarmInfo();
+            alarmInfo.setId(UUID.randomUUID().toString());
+            alarmInfo.setDelFlag(false);
+            //alarmInfo.setCreateBy(subject);
+            alarmInfo.setIsRead(false);
+            alarmInfo.setMessage(message);
+            alarmInfo.setType("2");
+            alarmInfo.setCreateTime(new Date());
+
+            int affectCount = alarmInfoService.insert(alarmInfo);
+
+            if (affectCount > 0) {
+                msgResult.setResult(true);
+                msgResult.setData("成功");
+            } else {
+                msgResult.setResult(false);
+                msgResult.setMessage("添加失败");
+            }
+        }
+        catch(Exception ex){
+            logger.error(ex.getMessage(),ex);
 
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
         return msgResult;
     }
 
@@ -203,9 +227,8 @@ public class AlarmInfoController {
     public MessageResult<Map> pageList(
             String id,
             @RequestParam(value="type",defaultValue="") String type,
-            @RequestParam(value="draw",defaultValue="1") int draw,
-            @RequestParam(value="start",defaultValue="1") int start,
-            @RequestParam(value="length",defaultValue="20") int length,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
 
         //当前用户ID
@@ -226,19 +249,38 @@ public class AlarmInfoController {
             searchParams.put("type",type);
         }
 
-        int pageNum = start / length;
+        Page<AlarmInfo> page = alarmInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
 
-        if (start % length != 0) {
-            pageNum++;
-        }
+        msgResult.setResult(true);
+        msgResult.setData(PojoUtils.pageWrapper(page));
 
-        int pageSize = length;
+        return msgResult;
+    }
 
-        Page<AlarmInfo> page = alarmInfoService.pageSearch(searchParams,pageNum,pageSize,sortList);
+    @ApiOperation(value="查询报警信息")
+    @RequestMapping(value = "queryNotify",method = RequestMethod.POST)
+    public MessageResult<String> queryNotify(
+            String type,
+            @RequestAttribute String subject){
 
-        msgResult.setResult(true);
-        msgResult.setData(PojoUtils.pageWrapper(page));
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<String> msgResult = new MessageResult<>();
+
+        AlarmInfo alarmInfo = alarmInfoService.queryLatestAlarm(type);
 
+        if(alarmInfo == null){
+            msgResult.setResult(false);
+        }else {
+            msgResult.setResult(true);
+            msgResult.setData(alarmInfo.getMessage());
+
+            //修改阅读状态
+            alarmInfo.setIsRead(true);
+            alarmInfoService.update(alarmInfo);
+        }
         return msgResult;
     }
+
 }

+ 3 - 12
src/main/java/com/jpsoft/smart/modules/base/controller/InformationInfoController.java

@@ -197,9 +197,8 @@ public class InformationInfoController {
     public MessageResult<Map> pageList(
             String id,
             @RequestParam(value="type",defaultValue="") String type,
-            @RequestParam(value="draw",defaultValue="1") int draw,
-            @RequestParam(value="start",defaultValue="1") int start,
-            @RequestParam(value="length",defaultValue="20") int length,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
 
         //当前用户ID
@@ -220,15 +219,7 @@ public class InformationInfoController {
             searchParams.put("type",type);
         }
 
-        int pageNum = start / length;
-
-        if (start % length != 0) {
-            pageNum++;
-        }
-
-        int pageSize = length;
-
-        Page<InformationInfo> page = informationInfoService.pageSearch(searchParams,pageNum,pageSize,sortList);
+        Page<InformationInfo> page = informationInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));

+ 4 - 14
src/main/java/com/jpsoft/smart/modules/base/controller/ParkingApplyController.java

@@ -193,9 +193,8 @@ public class ParkingApplyController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
-            @RequestParam(value="draw",defaultValue="1") int draw,
-            @RequestParam(value="start",defaultValue="1") int start,
-            @RequestParam(value="length",defaultValue="20") int length,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
 
         //当前用户ID
@@ -209,18 +208,9 @@ public class ParkingApplyController {
         sortList.add(new Sort("id_","asc"));
 
         if (StringUtils.isNotEmpty(id)) {
-            searchParams.put("id","%" + id + "%");
+            searchParams.put("id", "%" + id + "%");
         }
-
-        int pageNum = start / length;
-
-        if (start % length != 0) {
-            pageNum++;
-        }
-
-        int pageSize = length;
-
-        Page<ParkingApply> page = parkingApplyService.pageSearch(searchParams,pageNum,pageSize,sortList);
+        Page<ParkingApply> page = parkingApplyService.pageSearch(searchParams,pageIndex,pageSize,sortList);
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));

+ 3 - 12
src/main/java/com/jpsoft/smart/modules/base/controller/ParkingInfoController.java

@@ -193,9 +193,8 @@ public class ParkingInfoController {
     @RequestMapping(value = "pageList",method = RequestMethod.POST)
     public MessageResult<Map> pageList(
             String id,
-            @RequestParam(value="draw",defaultValue="1") int draw,
-            @RequestParam(value="start",defaultValue="1") int start,
-            @RequestParam(value="length",defaultValue="20") int length,
+            @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
+            @RequestParam(value="pageSize",defaultValue="20") int pageSize,
             @RequestAttribute String subject){
 
         //当前用户ID
@@ -212,15 +211,7 @@ public class ParkingInfoController {
             searchParams.put("id","%" + id + "%");
         }
 
-        int pageNum = start / length;
-
-        if (start % length != 0) {
-            pageNum++;
-        }
-
-        int pageSize = length;
-
-        Page<ParkingInfo> page = parkingInfoService.pageSearch(searchParams,pageNum,pageSize,sortList);
+        Page<ParkingInfo> page = parkingInfoService.pageSearch(searchParams,pageIndex,pageSize,sortList);
 
         msgResult.setResult(true);
         msgResult.setData(PojoUtils.pageWrapper(page));

+ 1 - 0
src/main/java/com/jpsoft/smart/modules/base/dao/AlarmInfoDAO.java

@@ -14,6 +14,7 @@ public interface AlarmInfoDAO {
 	int exist(String id);
 	AlarmInfo get(String id);
 	int delete(String id);
+	AlarmInfo queryLatestAlarm(String type);
 	List<AlarmInfo> list();
 	List<AlarmInfo> search(Map<String, Object> searchParams, List<Sort> sortList);
 }

+ 28 - 0
src/main/java/com/jpsoft/smart/modules/base/entity/AlarmInfo.java

@@ -20,6 +20,8 @@ public class AlarmInfo {
 	private String alertType;
 	private String type;
 	private String videoUrl;
+	private Boolean isRead;
+	private String message;
 	
 		/**
 	 *获取
@@ -169,5 +171,31 @@ public class AlarmInfo {
 		this.videoUrl = videoUrl;
 	}
 
+	/**
+	 *获取是否已读
+	 */
+	public Boolean getIsRead(){
+		return isRead;
+	}
+
+	/**
+	 *设置是否已读
+	 */
+	public void setIsRead(Boolean isRead){
+		this.isRead = isRead;
+	}
 
+	/**
+	 *获取报警内容
+	 */
+	public String getMessage(){
+		return message;
+	}
+
+	/**
+	 *设置报警内容
+	 */
+	public void setMessage(String message){
+		this.message = message;
+	}
 }

+ 15 - 0
src/main/java/com/jpsoft/smart/modules/base/entity/OwnerInfo.java

@@ -28,6 +28,7 @@ public class OwnerInfo {
 	private String carNo;
 	private Boolean isAccessControl;
 	private Boolean isThePublic;
+	private String roomId;
 	
 		/**
 	 *获取
@@ -269,4 +270,18 @@ public class OwnerInfo {
 	public void setIsThePublic(Boolean isThePublic){
 		this.isThePublic = isThePublic;
 	}
+
+	/**
+	 *获取房间号
+	 */
+	public String getRoomId(){
+		return roomId;
+	}
+
+	/**
+	 *设置房间号
+	 */
+	public void setRoomId(String roomId){
+		this.roomId = roomId;
+	}
 }

+ 1 - 0
src/main/java/com/jpsoft/smart/modules/base/service/AlarmInfoService.java

@@ -13,6 +13,7 @@ public interface AlarmInfoService {
 	int insert(AlarmInfo model);
 	int update(AlarmInfo model);
 	int delete(String id);
+	AlarmInfo queryLatestAlarm(String type);
 	List<AlarmInfo> list();
 	Page<AlarmInfo> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, List<Sort> sortList);
 }

+ 7 - 1
src/main/java/com/jpsoft/smart/modules/base/service/impl/AlarmInfoServiceImpl.java

@@ -45,6 +45,12 @@ public class AlarmInfoServiceImpl implements AlarmInfoService {
 		return alarmInfoDAO.delete(id);
 	}
 
+	@Override
+	public AlarmInfo queryLatestAlarm(String type) {
+		// TODO Auto-generated method stub
+		return alarmInfoDAO.queryLatestAlarm(type);
+	}
+
 	@Override
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
@@ -61,7 +67,7 @@ public class AlarmInfoServiceImpl implements AlarmInfoService {
 		
 	@Override
 	public Page<AlarmInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<AlarmInfo> page = PageHelper.startPage(1,10).doSelectPage(()->{
+        Page<AlarmInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
             alarmInfoDAO.search(searchParams,sortList);
         });
         

+ 1 - 1
src/main/java/com/jpsoft/smart/modules/base/service/impl/InformationInfoServiceImpl.java

@@ -61,7 +61,7 @@ public class InformationInfoServiceImpl implements InformationInfoService {
 		
 	@Override
 	public Page<InformationInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<InformationInfo> page = PageHelper.startPage(1,10).doSelectPage(()->{
+        Page<InformationInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
             informationInfoDAO.search(searchParams,sortList);
         });
         

+ 1 - 1
src/main/java/com/jpsoft/smart/modules/base/service/impl/OwnerInfoServiceImpl.java

@@ -66,7 +66,7 @@ public class OwnerInfoServiceImpl implements OwnerInfoService {
 
     @Override
     public Page<OwnerInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, List<Sort> sortList) {
-        Page<OwnerInfo> page = PageHelper.startPage(1, 10).doSelectPage(() -> {
+        Page<OwnerInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(() -> {
             ownerInfoDAO.search(searchParams, sortList);
         });
 

+ 1 - 1
src/main/java/com/jpsoft/smart/modules/base/service/impl/ParkingApplyServiceImpl.java

@@ -61,7 +61,7 @@ public class ParkingApplyServiceImpl implements ParkingApplyService {
 		
 	@Override
 	public Page<ParkingApply> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<ParkingApply> page = PageHelper.startPage(1,10).doSelectPage(()->{
+        Page<ParkingApply> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
             parkingApplyDAO.search(searchParams,sortList);
         });
         

+ 1 - 1
src/main/java/com/jpsoft/smart/modules/base/service/impl/ParkingInfoServiceImpl.java

@@ -61,7 +61,7 @@ public class ParkingInfoServiceImpl implements ParkingInfoService {
 		
 	@Override
 	public Page<ParkingInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
-        Page<ParkingInfo> page = PageHelper.startPage(1,10).doSelectPage(()->{
+        Page<ParkingInfo> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
             parkingInfoDAO.search(searchParams,sortList);
         });
         

+ 0 - 45
src/main/java/com/jpsoft/smart/modules/business/controller/MobileApiController.java

@@ -3,7 +3,6 @@ package com.jpsoft.smart.modules.business.controller;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.github.pagehelper.Page;
 import com.jpsoft.smart.config.RedisConfig;
-import com.jpsoft.smart.modules.base.entity.InformationInfo;
 import com.jpsoft.smart.modules.base.entity.RechargeRecord;
 import com.jpsoft.smart.modules.base.entity.RoomInfo;
 import com.jpsoft.smart.modules.base.service.InformationInfoService;
@@ -439,48 +438,4 @@ public class MobileApiController {
 
         return msgResult;
     }
-
-
-    @PostMapping(value="addMobile")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name="ownerId",value="户主ID",dataType="string",paramType = "query"),
-            @ApiImplicitParam(name="content",value="内容",dataType="string",paramType = "query"),
-            @ApiImplicitParam(name="type",value="类型/1投诉/2报修",dataType="string",paramType = "query")
-    })
-    public MessageResult<InformationInfo> addMobile(
-            String ownerId,
-            String content,
-            String type){
-        MessageResult<InformationInfo> msgResult = new MessageResult<>();
-        InformationInfo informationInfo = new InformationInfo();
-        try {
-            informationInfo.setId(UUID.randomUUID().toString());
-            informationInfo.setDelFlag(false);
-            informationInfo.setCreateBy(ownerId);
-            informationInfo.setCreateTime(new Date());
-            informationInfo.setStatus("0");
-            informationInfo.setContent(content);
-            informationInfo.setOwnerId(ownerId);
-            informationInfo.setType(type);
-            informationInfo.setOwnerId("1-2-1601");
-
-            int affectCount = informationInfoService.insert(informationInfo);
-
-            if (affectCount > 0) {
-                msgResult.setResult(true);
-                msgResult.setData(informationInfo);
-            } else {
-                msgResult.setResult(false);
-                msgResult.setMessage("数据库添加失败");
-            }
-        }
-        catch(Exception ex){
-            log.error(ex.getMessage(),ex);
-
-            msgResult.setResult(false);
-            msgResult.setMessage(ex.getMessage());
-        }
-
-        return msgResult;
-    }
 }

+ 14 - 2
src/main/resources/mapper/base/AlarmInfo.xml

@@ -15,7 +15,8 @@
 			<result property="alertType" column="alert_type" />
 			<result property="type" column="type_" />
 			<result property="videoUrl" column="video_url" />
-
+			<result property="isRead" column="is_read" />
+			<result property="message" column="message_" />
 			</resultMap>
 	<insert id="insert" parameterType="AlarmInfo">
 	<!--
@@ -25,7 +26,7 @@
 	-->
 	<![CDATA[
 		insert into base_alarm_info
-	    (id_,create_by,create_time,update_by,update_time,del_flag,device_no,channel_name,alert_type,type_,video_url)
+	    (id_,create_by,create_time,update_by,update_time,del_flag,device_no,channel_name,alert_type,type_,video_url,is_read,message_)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -39,6 +40,8 @@
 ,#{alertType,jdbcType=VARCHAR}
 ,#{type,jdbcType=VARCHAR}
 ,#{videoUrl,jdbcType=VARCHAR}
+,#{isRead,jdbcType= NUMERIC }
+,#{message,jdbcType=VARCHAR}
 		)
 	]]>
 	</insert>
@@ -78,6 +81,12 @@
 			<if test="videoUrl!=null">
 				video_url=#{videoUrl,jdbcType=VARCHAR},
 			</if>
+			<if test="isRead!=null">
+				is_read=#{isRead,jdbcType=NUMERIC},
+			</if>
+			<if test="message!=null">
+				message_=#{message,jdbcType=VARCHAR},
+			</if>
 		</set>
 	where id_=#{id}
 	</update>
@@ -107,4 +116,7 @@ id_,create_by,create_time,update_by,update_time,del_flag,device_no,channel_name,
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+	<select id="queryLatestAlarm" parameterType="string" resultMap="AlarmInfoMap">
+		select * from base_alarm_info where del_flag=0 and type_=#{0} and is_read = 0 order by create_time desc limit 1
+	</select>
 </mapper>

+ 7 - 3
src/main/resources/mapper/base/OwnerInfo.xml

@@ -22,6 +22,7 @@
 			<result property="carNo" column="car_no" />
 			<result property="isAccessControl" column="is_access_control" />
 			<result property="isThePublic" column="is_the_public" />
+			<result property="roomId" column="room_id" />
 			</resultMap>
 	<insert id="insert" parameterType="OwnerInfo">
 	<!--
@@ -31,7 +32,7 @@
 	-->
 	<![CDATA[
 		insert into base_owner_info
-	    (id_,create_by,create_time,update_by,update_time,del_flag,name_,tel_,park_,building,area_,checkin_time,property_costs,card_no,authority_,car_no,is_access_control,is_the_public)
+	    (id_,create_by,create_time,update_by,update_time,del_flag,name_,tel_,park_,building,area_,checkin_time,property_costs,card_no,authority_,car_no,is_access_control,is_the_public,room_id)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -52,6 +53,7 @@
 ,#{carNo,jdbcType=VARCHAR}
 ,#{isAccessControl,jdbcType= NUMERIC }
 ,#{isThePublic,jdbcType= NUMERIC }
+,#{roomId,jdbcType= VARCHAR }
 		)
 	]]>
 	</insert>
@@ -111,13 +113,15 @@
 		</if>
 				<if test="isThePublic!=null">
 		is_the_public=#{isThePublic,jdbcType= NUMERIC },
+		</if>
+			<if test="roomId!=null">
+				room_id=#{roomId,jdbcType= VARCHAR },
 		</if>
 		</set>
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="OwnerInfoMap">
-		select 
-id_,create_by,create_time,update_by,update_time,del_flag,name_,tel_,park_,building,area_,checkin_time,property_costs,card_no,authority_,car_no,is_access_control,is_the_public		from base_owner_info where id_=#{0}
+		select * from base_owner_info where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
 		select count(*) from base_owner_info where id_=#{0}