|
@@ -44,7 +44,6 @@ import org.codehaus.jackson.JsonNode;
|
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -65,8 +64,7 @@ import static com.github.zuihou.exception.code.ExceptionCode.SYSTEM_BUSY;
|
|
|
/**
|
|
|
* @author User
|
|
|
*/
|
|
|
-@RestController
|
|
|
-@RequestMapping("externalApi")
|
|
|
+@RestController @RequestMapping("externalApi")
|
|
|
public class AndroidApi
|
|
|
{
|
|
|
@Resource
|
|
@@ -310,8 +308,6 @@ public class AndroidApi
|
|
|
/**
|
|
|
* 微信支付通知
|
|
|
* (通知频率为15s/15s/30s/3m/10m/20m/30m/30m/30m/60m/3h/3h/3h/6h/6h - 总计 24h4m)
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/paymentNotify")
|
|
|
public Map<String, Object> paymentNotify(HttpServletRequest request) throws Exception {
|
|
@@ -464,8 +460,6 @@ public class AndroidApi
|
|
|
|
|
|
/**
|
|
|
* 获取未绑定的设备列表
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
@GetMapping("/getUnboundEquList")
|
|
|
public R<List<ProductionResource>> getUnboundEquList() {
|
|
@@ -482,8 +476,6 @@ public class AndroidApi
|
|
|
|
|
|
/**
|
|
|
* 绑定,解绑,设备
|
|
|
- *
|
|
|
- * @return
|
|
|
*/
|
|
|
@PostMapping("/boundEqu")
|
|
|
public R<Boolean> boundEqu(@RequestBody Map<String, String> map) {
|
|
@@ -504,21 +496,28 @@ public class AndroidApi
|
|
|
/**
|
|
|
* 同步设备状态接口
|
|
|
*
|
|
|
- * @param status 状态信息(status:0 - 离线,1 - 在线,2 - 异常,3 - 缺料)
|
|
|
+ * @param equInfo 状态信息(status:0 - 离线,1 - 在线,2 - 异常,3 - 缺料)
|
|
|
*/
|
|
|
@PostMapping("/timelyEquStatus")
|
|
|
- public R<Boolean> timelyEquStatus(@RequestBody @Validated EquStatus status)
|
|
|
+ public R<Boolean> timelyEquStatus(@RequestBody Map<String, String> equInfo)
|
|
|
{
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
|
|
|
- // 1 更新Redis缓存
|
|
|
+ // 1 接收原上报信息
|
|
|
+ EquStatus status = EquStatus.builder()
|
|
|
+ .equId(Long.valueOf(equInfo.get("equId")))
|
|
|
+ .status(Integer.valueOf(equInfo.get("equStatus")))
|
|
|
+ .message(equInfo.get("errMsg"))
|
|
|
+ .build();
|
|
|
+
|
|
|
+ // 2 更新Redis缓存
|
|
|
HashMap<String, String> saveMap = new HashMap<>();
|
|
|
saveMap.put("status", status.getStatus().toString());
|
|
|
saveMap.put("errMsg", status.getMessage());
|
|
|
redisTemplate.opsForHash().putAll("equStatus" + status.getEquId(), saveMap);
|
|
|
redisTemplate.expire("equStatus" + status.getEquId(), 4, TimeUnit.SECONDS);
|
|
|
|
|
|
- // 2 持久化至DB
|
|
|
+ // 3 持久化至DB
|
|
|
status.setCreateUser(-1L);
|
|
|
equStatusMapper.insert(status);
|
|
|
|
|
@@ -526,7 +525,8 @@ public class AndroidApi
|
|
|
}
|
|
|
|
|
|
@GetMapping("/testhash")
|
|
|
- public R<Boolean> testhash() {
|
|
|
+ public R<Boolean> testhash()
|
|
|
+ {
|
|
|
BaseContextHandler.setTenant("0000");
|
|
|
|
|
|
HashMap<String, String> saveMap = new HashMap<>();
|