home 2 éve
szülő
commit
e312442ab5

+ 25 - 0
hx-common/code-generator/src/main/java/com/fjhx/modular/SyringeProduction.java

@@ -0,0 +1,25 @@
+package com.fjhx.modular;
+
+import com.fjhx.generator.CodeGenerator;
+
+public class SyringeProduction {
+
+    public static void main(String[] args) {
+        // 数据库名
+        CodeGenerator.DATABASE_NAME = "syringe_production";
+
+        // 模块名称
+        CodeGenerator.MODULAR_NAME = "syringe-production";
+
+        // 需要生成的表名称,多表用,隔开
+        CodeGenerator.INCLUDE = "data_autoclaves";
+
+        // mysql连接
+        CodeGenerator.MYSQL_URL = "36.134.91.96:17330";
+        CodeGenerator.USER_NAME = "fjhx2012mysql";
+        CodeGenerator.PASSWORD = "3PN-Mzn#vnP&q6d";
+
+        CodeGenerator.execute();
+    }
+
+}

+ 9 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/constants/RedisConstant.java

@@ -0,0 +1,9 @@
+package com.fjhx.constants;
+
+public interface RedisConstant {
+
+    String PREFIX = "syringe-production:";
+
+    String DATA_AUTOCLAVES = PREFIX + "dataAutoclaves:";
+
+}

+ 44 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/entity/data/DataAutoclaves.java

@@ -0,0 +1,44 @@
+package com.fjhx.entity.data;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 灭菌柜数据
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+@Data
+public class DataAutoclaves implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键id
+     */
+    @TableId(value = "id", type = IdType.ASSIGN_ID)
+    private Long id;
+
+    /**
+     * 设备id
+     */
+    private String machineId;
+
+    /**
+     * 灭菌柜数据
+     */
+    private String jsonData;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+}

+ 17 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/params/data/DataAutoclavesEx.java

@@ -0,0 +1,17 @@
+package com.fjhx.params.data;
+
+import com.fjhx.entity.data.DataAutoclaves;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 灭菌柜数据
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DataAutoclavesEx extends DataAutoclaves {
+
+}

+ 17 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/params/data/DataAutoclavesVo.java

@@ -0,0 +1,17 @@
+package com.fjhx.params.data;
+
+import com.fjhx.entity.data.DataAutoclaves;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 灭菌柜数据
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class DataAutoclavesVo extends DataAutoclaves {
+
+}

+ 2 - 1
hx-service/syringe-production/src/main/java/com/fjhx/config/MybatisConfig.java

@@ -22,7 +22,8 @@ public class MybatisConfig {
      * 排除表集合
      */
     private static final List<String> excludeTableName = Arrays.asList(
-            "amqp_data"
+            "amqp_data",
+            "data_autoclaves"
     );
 
     /**

+ 41 - 0
hx-service/syringe-production/src/main/java/com/fjhx/controller/data/DataAutoclavesController.java

@@ -0,0 +1,41 @@
+package com.fjhx.controller.data;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fjhx.base.Condition;
+import com.fjhx.service.data.DataAutoclavesService;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 灭菌柜数据 前端控制器
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+@RestController
+@RequestMapping("/dataAutoclaves")
+public class DataAutoclavesController {
+
+    @Autowired
+    private DataAutoclavesService dataAutoclavesService;
+
+    @PostMapping("/add")
+    public R add(@RequestBody JSONObject json) {
+        boolean flag = dataAutoclavesService.add(json);
+        return R.success(flag);
+    }
+
+    @PostMapping("/getData")
+    public R getData(@RequestBody Condition condition) {
+        JSONObject result = dataAutoclavesService.getData(condition);
+        return R.success(result);
+    }
+
+}
+

+ 16 - 0
hx-service/syringe-production/src/main/java/com/fjhx/mapper/data/DataAutoclavesMapper.java

@@ -0,0 +1,16 @@
+package com.fjhx.mapper.data;
+
+import com.fjhx.entity.data.DataAutoclaves;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 灭菌柜数据 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+public interface DataAutoclavesMapper extends BaseMapper<DataAutoclaves> {
+
+}

+ 5 - 0
hx-service/syringe-production/src/main/java/com/fjhx/mapper/data/DataAutoclavesMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.fjhx.mapper.data.DataAutoclavesMapper">
+
+</mapper>

+ 22 - 0
hx-service/syringe-production/src/main/java/com/fjhx/service/data/DataAutoclavesService.java

@@ -0,0 +1,22 @@
+package com.fjhx.service.data;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fjhx.base.BaseService;
+import com.fjhx.base.Condition;
+import com.fjhx.entity.data.DataAutoclaves;
+
+/**
+ * <p>
+ * 灭菌柜数据 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+public interface DataAutoclavesService extends BaseService<DataAutoclaves> {
+
+    boolean add(JSONObject json);
+
+    JSONObject getData(Condition condition);
+
+}

+ 73 - 0
hx-service/syringe-production/src/main/java/com/fjhx/service/data/impl/DataAutoclavesServiceImpl.java

@@ -0,0 +1,73 @@
+package com.fjhx.service.data.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.base.Condition;
+import com.fjhx.constants.RedisConstant;
+import com.fjhx.entity.data.DataAutoclaves;
+import com.fjhx.mapper.data.DataAutoclavesMapper;
+import com.fjhx.service.data.DataAutoclavesService;
+import com.fjhx.utils.Assert;
+import org.springblade.core.redis.cache.BladeRedis;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+
+/**
+ * <p>
+ * 灭菌柜数据 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-11-22
+ */
+@Service
+public class DataAutoclavesServiceImpl extends ServiceImpl<DataAutoclavesMapper, DataAutoclaves> implements DataAutoclavesService {
+
+    @Resource
+    private BladeRedis bladeRedis;
+
+
+    @Override
+    public boolean add(JSONObject json) {
+
+        bladeRedis.set(RedisConstant.DATA_AUTOCLAVES, json);
+
+        JSONObject module = json.getJSONObject("Module");
+        String machineId = module.getString("MachineId");
+
+        DataAutoclaves dataAutoclaves = new DataAutoclaves();
+        dataAutoclaves.setJsonData(json.toJSONString());
+        dataAutoclaves.setMachineId(machineId);
+        dataAutoclaves.setCreateTime(new Date());
+
+        return save(dataAutoclaves);
+    }
+
+    @Override
+    public JSONObject getData(Condition condition) {
+        String nodeId = condition.getStr("nodeId");
+        Assert.notEmpty(nodeId, "设备标识不能够为空");
+
+        JSONObject json = bladeRedis.get(RedisConstant.DATA_AUTOCLAVES + nodeId);
+
+        if (json == null) {
+            DataAutoclaves dataAutoclaves = getOne(Wrappers.<DataAutoclaves>lambdaQuery()
+                    .eq(DataAutoclaves::getMachineId, nodeId)
+                    .orderByDesc(DataAutoclaves::getId)
+                    .last("limit 1"));
+
+            if (dataAutoclaves == null) {
+                return new JSONObject();
+            }
+
+            json = JSONObject.parseObject(dataAutoclaves.getJsonData());
+            bladeRedis.set(RedisConstant.DATA_AUTOCLAVES + nodeId, json);
+        }
+
+        return json;
+    }
+
+}

+ 2 - 0
hx-service/syringe-production/src/main/java/com/fjhx/service/tda/impl/TdaApplicationServiceImpl.java

@@ -16,6 +16,7 @@ import com.fjhx.utils.IoTDAUtil;
 import com.fjhx.utils.UserClientUtil;
 import com.fjhx.utils.WrapperUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -32,6 +33,7 @@ import java.util.Map;
 @Service
 public class TdaApplicationServiceImpl extends ServiceImpl<TdaApplicationMapper, TdaApplication> implements TdaApplicationService {
 
+    @Lazy
     @Autowired
     private TdaProductService tdaProductService;
 

+ 2 - 0
hx-service/syringe-production/src/main/java/com/fjhx/service/tda/impl/TdaDeviceServiceImpl.java

@@ -17,6 +17,7 @@ import com.fjhx.utils.Assert;
 import com.fjhx.utils.IoTDAUtil;
 import com.fjhx.utils.WrapperUtil;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -33,6 +34,7 @@ import java.util.Map;
 @Service
 public class TdaDeviceServiceImpl extends ServiceImpl<TdaDeviceMapper, TdaDevice> implements TdaDeviceService {
 
+    @Lazy
     @Autowired
     private TdaProductService tdaProductService;
 

+ 5 - 3
hx-service/weixin/src/main/java/com/fjhx/controller/TestController.java

@@ -37,7 +37,7 @@ public class TestController {
     private BladeRedis bladeRedis;
 
 
-    @GetMapping(value = "/test")
+    @RequestMapping(value = "/test")
     public String test() {
         return "hello";
     }
@@ -67,6 +67,8 @@ public class TestController {
             WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(WeChatConstants.TOKEN, WeChatConstants.ENCODING_AES_KEY, WeChatConstants.CORP_ID);
             String echostr = wxBizMsgCrypt.VerifyURL(msgSignature, timestamp, nonce, echoStr);
 
+            log.error("dataEchostr:  " + echostr);
+
             // 验证URL成功,将sEchoStr返回
             response.getWriter().print(echostr);
 
@@ -81,8 +83,8 @@ public class TestController {
      *
      * @link { https://developer.work.weixin.qq.com/tutorial/detail/38 }
      */
-    @PostMapping(value = "/command")
-    public String command(HttpServletRequest request) {
+    @PostMapping(value = "/data")
+    public String data(HttpServletRequest request) {
         // 微信加密签名
         String sReqMsgSig = request.getParameter("msg_signature");
         // 时间戳