Browse Source

设置新增或者修改

yq 3 years ago
parent
commit
102a7ec310

+ 3 - 2
mhfire-controller/src/main/java/com/bizmatics/mhfire/controller/web/TestController.java

@@ -67,8 +67,9 @@ public class TestController {
     }
 
     @GetMapping("waterAjTest")
-    public void waterAjTest(){
+    public void waterAjTest(@RequestParam Long id){
         WaterAj waterAj = new WaterAj();
+        waterAj.setId(id);
         waterAj.setCreateTime(new Date());
         waterAj.setAjType("消防案件");
         waterAj.setStreet("闵行街道");
@@ -80,7 +81,7 @@ public class TestController {
         waterAj.setEndTime(new Date());
         waterAj.setEnclosure("meid");
         waterAj.setImage("图片");
-        waterAjService.save(waterAj);
+        waterAjService.saveOrUpdate(waterAj);
     }
 
 }

+ 3 - 0
mhfire-model/src/main/java/com/bizmatics/mhfire/model/WaterAj.java

@@ -4,6 +4,8 @@ import java.time.LocalDateTime;
 import java.io.Serializable;
 import java.util.Date;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -26,6 +28,7 @@ public class WaterAj implements Serializable {
     /**
      * 案件编号
      */
+    @TableId(value = "id",type = IdType.INPUT)
     private Long id;
 
     /**

+ 1 - 1
mhfire-service/src/main/java/com/bizmatics/mhfire/service/listener/MqttListener.java

@@ -51,7 +51,7 @@ public class MqttListener {
                     oneCardApi.callAlarmApi(map);
                 }else if (topic.equals("mh/water/statistics")){
                     WaterAj waterAj = JsonUtils.fromJson(payload, WaterAj.class);
-                    waterAjService.save(waterAj);
+                    waterAjService.saveOrUpdate(waterAj);
                 }
             }
         };