完成展示,更新soc,version,phone接口
This commit is contained in:
parent
1c4b640d85
commit
622874a72c
@ -0,0 +1,33 @@
|
|||||||
|
package com.xhpc.general.controller;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.general.service.IXhpcServiceDataUpdateService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import static com.xhpc.general.service.XhpcSmsServiceImpl.REDIS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-12 13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/SDataUpdate")
|
||||||
|
public class XhpcServiceDataUpdateController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
IXhpcServiceDataUpdateService xhpcServiceDataUpdateService;
|
||||||
|
|
||||||
|
@GetMapping("/show")
|
||||||
|
public AjaxResult showList(){
|
||||||
|
|
||||||
|
return AjaxResult.success(xhpcServiceDataUpdateService.getServiceData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/update")
|
||||||
|
public AjaxResult updateDate(@RequestParam(required = false) String SOC, @RequestParam(required = false) String version, @RequestParam(required = false) String phone){
|
||||||
|
|
||||||
|
return xhpcServiceDataUpdateService.updateServiceData(SOC, version, phone);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,19 @@
|
|||||||
|
package com.xhpc.general.service;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-12 13
|
||||||
|
*/
|
||||||
|
public interface IXhpcServiceDataUpdateService {
|
||||||
|
|
||||||
|
Map<String,Object> getServiceData();
|
||||||
|
|
||||||
|
AjaxResult updateServiceData(String SOC, String version, String phone);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.xhpc.general.service;
|
||||||
|
|
||||||
|
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||||
|
import com.xhpc.common.redis.service.RedisService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* program: ruoyi
|
||||||
|
* User: HongYun
|
||||||
|
* Date:2021-08-12 14
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class XhpcServiceDataUpdateServiceImpl implements IXhpcServiceDataUpdateService{
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getServiceData() {
|
||||||
|
|
||||||
|
Map<String,Object> list=new HashMap<>();
|
||||||
|
String cacheSOC = redisService.getCacheObject("global:SOC");
|
||||||
|
String cacheVersion = redisService.getCacheObject("global:version");
|
||||||
|
String cachePhone = redisService.getCacheObject("global:phone");
|
||||||
|
list.put("SOC",cacheSOC);
|
||||||
|
list.put("version",cacheVersion);
|
||||||
|
list.put("phone",cachePhone);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult updateServiceData(String SOC, String version, String phone) {
|
||||||
|
|
||||||
|
if(SOC!=null) {
|
||||||
|
int soc = Integer.parseInt(SOC);
|
||||||
|
if (!(soc >= 1 && soc <= 100)) {
|
||||||
|
return AjaxResult.error("范围应为[1-100]");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(phone!=null) {
|
||||||
|
if (phone.length() > 20) {
|
||||||
|
return AjaxResult.error("号码格式错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
redisService.setCacheObject("global:SOC",SOC);
|
||||||
|
redisService.setCacheObject("global:version",version);
|
||||||
|
redisService.setCacheObject("global:phone",phone);
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -69,6 +69,11 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
}
|
}
|
||||||
Integer balance = (Integer) cacheOrder.get("balance");
|
Integer balance = (Integer) cacheOrder.get("balance");
|
||||||
CacheRealtimeData cacheRealtimeData = translate(realtimeData);
|
CacheRealtimeData cacheRealtimeData = translate(realtimeData);
|
||||||
|
realtimeDataList.add(cacheRealtimeData);
|
||||||
|
cacheOrder.put("soc", realtimeData.getSoc());
|
||||||
|
cacheOrder.put("status", statusplain);
|
||||||
|
cacheOrder.put("realtimeDataList", realtimeDataList);
|
||||||
|
REDIS.setCacheMap(orderkey, cacheOrder);
|
||||||
if ((balance - cacheRealtimeData.getAmountCharged()) < 500) {
|
if ((balance - cacheRealtimeData.getAmountCharged()) < 500) {
|
||||||
String alerted = (String) cacheOrder.get("alerted");
|
String alerted = (String) cacheOrder.get("alerted");
|
||||||
String tel = (String) cacheOrder.get("tel");
|
String tel = (String) cacheOrder.get("tel");
|
||||||
@ -77,11 +82,6 @@ public class RealtimeDataLogic implements ServiceLogic {
|
|||||||
cacheOrder.put("alerted", "true");
|
cacheOrder.put("alerted", "true");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realtimeDataList.add(cacheRealtimeData);
|
|
||||||
cacheOrder.put("soc", realtimeData.getSoc());
|
|
||||||
cacheOrder.put("status", statusplain);
|
|
||||||
cacheOrder.put("realtimeDataList", realtimeDataList);
|
|
||||||
REDIS.setCacheMap(orderkey, cacheOrder);
|
|
||||||
}
|
}
|
||||||
return new ServiceResult(false);
|
return new ServiceResult(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ public class ServiceResult {
|
|||||||
|
|
||||||
public ServiceResult(String code, String body) {
|
public ServiceResult(String code, String body) {
|
||||||
|
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<>();
|
||||||
String messageCode = "0101";
|
String messageCode = "0101";
|
||||||
if (code != null && code.trim().length() > 0) {
|
if (code != null && code.trim().length() > 0) {
|
||||||
messageCode = code;
|
messageCode = code;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user