浏览代码

硬件管理消息发送;

zlq 1 年之前
父节点
当前提交
cc769c9bf7

+ 1 - 2
src/main/java/com/unissoft/mqConsumer/TeDataConsumer.java

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
12 12
 /**
13 13
  * ClassName: ConService
14 14
  * Package: com.unissoft.mqConsumer
15
- * Description:
15
+ * Description:新增,修改,删除
16 16
  *
17 17
  * @Author zlq
18 18
  * @Create 2023/3/2 10:36
@@ -31,7 +31,6 @@ public class TeDataConsumer{
31 31
          */
32 32
         @Override
33 33
         public void onMessage(TeData teData) {
34
-            
35 34
             System.out.println("接收到的消息"+teData.toString());
36 35
         }
37 36
     }

+ 3 - 3
src/main/java/com/unissoft/mqProducer/Producer.java

@@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
22 22
 @Component("producer")
23 23
 public class Producer {
24 24
     //topic名称
25
-    private static final String topic="TOPIC_LOCAL";
25
+    private final String topic="TOPIC_LOCAL:";
26 26
 
27 27
     @Autowired
28 28
     private RocketMQTemplate rocketMQTemplate;
@@ -33,7 +33,7 @@ public class Producer {
33 33
      * @param tag  消息类型
34 34
      */
35 35
     public void send(Object msgBody, String tag){
36
-        rocketMQTemplate.convertAndSend(topic+":"+tag,msgBody);
36
+        rocketMQTemplate.convertAndSend(topic+tag,msgBody);
37 37
     }
38 38
 
39 39
     /**
@@ -43,7 +43,7 @@ public class Producer {
43 43
      * @return
44 44
      */
45 45
     public SendResult sendMsg(String msgBody,String tag) {
46
-        SendResult sendResult = rocketMQTemplate.syncSend(topic+":"+tag, MessageBuilder.withPayload(msgBody).build());
46
+        SendResult sendResult = rocketMQTemplate.syncSend(topic+tag, MessageBuilder.withPayload(msgBody).build());
47 47
         return sendResult;
48 48
     }
49 49
 

+ 21 - 7
src/main/java/com/unissoft/parameter/controller/HardwareParameterController.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5
 import com.unissoft.common.PageParam;
6 6
 import com.unissoft.common.ResultView;
7 7
 import com.unissoft.common.SystemLog;
8
+import com.unissoft.mqProducer.Producer;
8 9
 import com.unissoft.parameter.model.HardwareParameter;
9 10
 import com.unissoft.parameter.service.HardwareParameterService;
10 11
 
@@ -33,6 +34,9 @@ public class HardwareParameterController {
33 34
     private HardwareParameterService hdService;
34 35
 
35 36
     @Autowired
37
+    private Producer producer;
38
+
39
+    @Autowired
36 40
     public void setHardwareParameterController(HardwareParameterService hdService) {
37 41
         this.hdService = hdService;
38 42
     }
@@ -61,9 +65,10 @@ public class HardwareParameterController {
61 65
     public ResultView saveUser(@RequestBody HardwareParameter hdParameter) {
62 66
     	hdParameter.setCreateTime(new Date());
63 67
         boolean save = hdService.save(hdParameter);
64
-        if (save)
68
+        if (save) {
69
+            producer.send(hdParameter, "HP_SAVE");
65 70
             return ResultView.success();
66
-        else
71
+        }else
67 72
             return ResultView.error();
68 73
     }
69 74
 
@@ -76,9 +81,10 @@ public class HardwareParameterController {
76 81
     @PostMapping("/update")
77 82
     public ResultView updateUser(@RequestBody HardwareParameter hdParameter) {
78 83
         boolean b = hdService.updateById(hdParameter);
79
-        if (b)
84
+        if (b) {
85
+            producer.send(hdParameter, "HP_UPDATE");
80 86
             return ResultView.success();
81
-        else
87
+        }else
82 88
             return ResultView.error();
83 89
     }
84 90
     
@@ -91,12 +97,20 @@ public class HardwareParameterController {
91 97
     @SystemLog(operModul = "参数设置", operType = "硬件参数", operDesc = "硬件参数删除")
92 98
     @ApiOperation(value = "根据id删除", notes = "")
93 99
     @DeleteMapping("/deleteById/{id}")
94
-    public ResultView deleteById(@PathVariable Integer id) {
100
+    public ResultView deleteById(@PathVariable String id) {
95 101
     	boolean b = hdService.removeById(id);
96
-    	if (b)
102
+        int i = hdService.deleteHarParamer(id);
103
+        if(i>0){
104
+            producer.send(id, "HP_DELETE");
97 105
             return ResultView.success();
98
-        else
106
+        }else {
99 107
             return ResultView.error();
108
+        }
109
+//        if (b) {
110
+//            producer.send(id, "HP_DELETE");
111
+//            return ResultView.success();
112
+//        }else
113
+//            return ResultView.error();
100 114
     }
101 115
     
102 116
 }

+ 4 - 4
src/main/java/com/unissoft/parameter/model/HardwareParameter.java

@@ -28,8 +28,8 @@ public class HardwareParameter implements Serializable {
28 28
     private static final long serialVersionUID = 1L;
29 29
 
30 30
     @ApiModelProperty(value = "硬件参数表")
31
-    @TableId(value = "id", type = IdType.AUTO)
32
-    private Integer id;
31
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
32
+    private String id;
33 33
 
34 34
     @ApiModelProperty(value = "仓房id")
35 35
     @TableField("house_id")
@@ -55,11 +55,11 @@ public class HardwareParameter implements Serializable {
55 55
     @TableField("create_time")
56 56
     private Date createTime;
57 57
 
58
-	public Integer getId() {
58
+	public String getId() {
59 59
 		return id;
60 60
 	}
61 61
 
62
-	public void setId(Integer id) {
62
+	public void setId(String id) {
63 63
 		this.id = id;
64 64
 	}
65 65
 

+ 2 - 0
src/main/java/com/unissoft/parameter/service/HardwareParameterService.java

@@ -18,5 +18,7 @@ public interface HardwareParameterService extends IService<HardwareParameter> {
18 18
 
19 19
 	IPage<HardwareParameter> getPage(PageParam pageParam);
20 20
 
21
+	int deleteHarParamer(String id);
22
+
21 23
 
22 24
 }

+ 8 - 2
src/main/java/com/unissoft/parameter/service/impl/HardwareParameterServiceImpl.java

@@ -56,7 +56,13 @@ public class HardwareParameterServiceImpl extends ServiceImpl<HardwareParameterM
56 56
         }
57 57
         return hdMapper.selectPage(page, ew);
58 58
 	}
59
-	
60
-	
59
+
60
+	@Override
61
+	public int deleteHarParamer(String id) {
62
+		int i = hdMapper.deleteById(id);
63
+
64
+		return i;
65
+	}
66
+
61 67
 
62 68
 }