增加详情序号(0x0C);避免服务自调用

This commit is contained in:
ZZ 2022-03-31 11:01:19 +08:00
parent 6c0bf83002
commit f301a10193
28 changed files with 97 additions and 78 deletions

View File

@ -32,6 +32,8 @@ public class ChargeDetails {
@JsonProperty("DetailSeviceMoney")
private Double detailSeviceMoney = 0.0;
private int idx;
public ChargeDetails(XhpcStatisticsTimeInterval statistics) {
this.detailElecMoney = statistics.getPowerPrice().doubleValue();

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -16,10 +16,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置
@ -35,7 +35,7 @@ spring:
datasource:
ds1:
nacos:
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
dataId: sentinel-ruoyi-gateway
groupId: DEFAULT_GROUP
data-type: json

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,10 +15,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -70,14 +70,21 @@ public class OrderDataLogic implements ServiceLogic {
REDIS.setCacheMap(orderkey, cacheOrder);
}
}
String resultStr =
"6815".concat(req.get("seqhex").toString()).concat("0040").concat(orderNo).concat(ServiceResult.HEX_00);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
final R r = pileOrderService.pileEndOrder(orderNo);
if (orderNo.equals("00000000000000000000000000000000") || (r.getMsg() != null && r.getMsg().contains("无效订单"))) {
if (orderNo.equals("00000000000000000000000000000000") || (r != null && r.getMsg() != null && r.getMsg().contains(
"无效订单"))) {
log.error(">>INVALID order [{}] detected. MUST check the system.<<", orderNo);
}
String resultStr = "6815".concat(req.get("seqhex").toString()).concat("0040").concat(orderNo);
if (r != null && r.getCode() == 200) {
resultStr = resultStr.concat(ServiceResult.HEX_00);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.OK);
} else {
resultStr = resultStr.concat(ServiceResult.HEX_00);
resultStr = resultStr.concat(CRCCalculator.calcCrc(resultStr));
return new ServiceResult(HexUtils.toBytes(resultStr), ServiceResult.FAIL);
}
}
private CacheOrderData translate(OrderData orderData) throws InvocationTargetException, IllegalAccessException, InstantiationException {

View File

@ -274,8 +274,11 @@ public class RealtimeDataLogic implements ServiceLogic {
int sumPeriod = Integer.parseInt(hex.substring(0, 2), 16);
List<ChargeDetails> cds = new ArrayList<>();
int idx = 0;
for (int i = 2; i < 2 + sumPeriod * 16; i = i + 16) { // todo
ChargeDetails cd = new ChargeDetails();
cd.setIdx(idx);
idx++;
cd.setDetailPower(HexUtils.reverseHexInt(hex.substring(i, i + 8)) / 100000.0);
cd.setDetailElecMoney(HexUtils.reverseHexInt(hex.substring(i + 8, i + 16)) / 100000.0);
// cd.setDetailSeviceMoney(HexUtils.reverseHexInt(hex.substring(i + 60, i + 68)) / 10000.0);
@ -288,8 +291,11 @@ public class RealtimeDataLogic implements ServiceLogic {
int sumPeriod = Integer.parseInt(hex.substring(28, 30), 16);
List<ChargeDetails> cds = new ArrayList<>();
int idx = 0;
for (int i = 38; i < 38 + sumPeriod * 16; i = i + 16) { // todo
ChargeDetails cd = new ChargeDetails();
cd.setIdx(idx);
idx++;
cd.setDetailPower(HexUtils.reverseHexInt(hex.substring(i, i + 8)) / 100000.0);
cd.setDetailElecMoney(HexUtils.reverseHexInt(hex.substring(i + 8, i + 16)) / 100000.0);
// cd.setDetailSeviceMoney(HexUtils.reverseHexInt(hex.substring(i + 60, i + 68)) / 10000.0);

View File

@ -129,11 +129,9 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
deviceMessage.setChargeOrderNo((String) req.get("orderNo"));
xhpcDeviceMessageMapper.insertByDomain(deviceMessage);
}
if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
if (SERVICE_HB.equals(serviceName)) {
if (OK.equals(resultCode)) {
pileNo = ChargingPileServer.getPileNo(handler);
if (null == pileNo) {
handler.forceClose();
} else {
Boolean tcfg = (Boolean) cachePile.get("tcfg");
if (tcfg == null || !tcfg) {
String skey = pilekey.concat(".seqhex");
@ -155,7 +153,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
REDIS.setCacheMap(pilekey, cachePile);
}
}
} else {
handler.forceClose();
}
}
}
}

View File

@ -18,10 +18,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,10 +15,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,10 +15,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -1,5 +1,6 @@
package com.xhpc.user.controller;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.util.UserTypeUtil;
@ -26,6 +27,7 @@ public class XhpcCommonController extends BaseController {
/**
* 根据手机号账号用户id和类型 获取用户信息
*
* @param phone
* @param userId
* @param userType
@ -33,23 +35,23 @@ public class XhpcCommonController extends BaseController {
* @return
*/
@GetMapping(value = "/getUser")
public AjaxResult getMechanism(String phone,Long userId,Integer userType,String serialNumber,String tenantId) {
public R getMechanism(String phone, Long userId, Integer userType, String serialNumber, String tenantId) {
if(phone !=null || "".equals(phone)){
if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
if (phone != null || "".equals(phone)) {
if (!UserTypeUtil.COMMUNIT.equals(phone.substring(0, 2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0, 2))) {
//C端用户
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.USER_TYPE,serialNumber,tenantId));
}else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2))){
return R.ok(xhpcCommonService.getLandUser(phone, null, UserTypeUtil.USER_TYPE, serialNumber, tenantId));
} else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0, 2))) {
//社区用户
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.COMMUNIT_TYPE,serialNumber,tenantId));
}else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){
return R.ok(xhpcCommonService.getLandUser(phone, null, UserTypeUtil.COMMUNIT_TYPE, serialNumber, tenantId));
} else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0, 2))) {
//大客户用户
return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,UserTypeUtil.CUSTOMERS_TYPE,serialNumber,tenantId));
return R.ok(xhpcCommonService.getLandUser(phone, null, UserTypeUtil.CUSTOMERS_TYPE, serialNumber, tenantId));
}
}else{
return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType,serialNumber,tenantId));
return R.ok(xhpcCommonService.getLandUser(null, userId, userType, serialNumber, tenantId));
}
return AjaxResult.error();
return R.fail();
}
/**

View File

@ -2,7 +2,6 @@ package com.xhpc.user.service.impl;
import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil;
import com.xhpc.common.api.UserTypeService;
import com.xhpc.common.core.constant.HttpStatus;
import com.xhpc.common.core.constant.StatusConstants;
import com.xhpc.common.core.constant.UserConstants;
@ -18,6 +17,7 @@ import com.xhpc.common.util.LogUserUtils;
import com.xhpc.common.util.UserTypeUtil;
import com.xhpc.system.api.domain.SysUser;
import com.xhpc.system.api.model.LoginUser;
import com.xhpc.user.controller.XhpcCommonController;
import com.xhpc.user.domain.XhpcAppUser;
import com.xhpc.user.mapper.XhpcAppUserMapper;
import com.xhpc.user.service.IXhpcAppUserUserService;
@ -53,7 +53,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
private LogUserUtils logUserUtils;
@Autowired
private UserTypeService userTypeService;
private XhpcCommonController xhpcCommonController;
private static final Logger logger = LoggerFactory.getLogger(XhpcAppUserServiceImpl.class);
@ -223,11 +223,11 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
@Transactional
public R<?> appLogin(String username, String type, String openid, String tenantId) {
//统一沉睡300毫秒防止重复提交
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
}
// try {
// Thread.sleep(300);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username)) {
return R.fail(HttpStatus.NOT_NULL, "用户必须填写");
@ -239,7 +239,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
}
String sub = username.substring(0, 2);
if (UserTypeUtil.COMMUNIT.equals(sub) || UserTypeUtil.CUSTOMERS.equals(sub)){
R lognUser = userTypeService.getUser(username, null, null, null,tenantId);
R lognUser = xhpcCommonController.getMechanism(username, null, null, null, tenantId);
if(lognUser !=null && lognUser.getData() !=null){
Map<String, Object> map = (Map<String, Object>)lognUser.getData();
LoginUser userInfo = new LoginUser();
@ -362,7 +362,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
Long userid = loginUser.getUserid();
String openId = loginUser.getOpenId();
String tenantId = loginUser.getTenantId();
R user = userTypeService.getUser(null, userid, userType, null,tenantId);
R user = xhpcCommonController.getMechanism(null, userid, userType, null, tenantId);
if(user !=null && user.getData() !=null){
if(UserTypeUtil.USER_TYPE==userType){
XhpcAppUser appUser = xhpcAppUserMapper.getAppUserByPhone(username,tenantId);
@ -418,7 +418,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
if(userLoginTime ==null){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
}
logger.info("-------userLoginTime---"+userLoginTime.toString());
logger.info("-------userLoginTime---" + userLoginTime);
if(userLoginTime.get("status") == null){
return R.fail(HttpStatus.USER_LOGIN, "请重新登录");
} else if(UserTypeUtil.NO_LOGIN.equals(userLoginTime.get("status").toString())){
@ -444,7 +444,7 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
Long userid = loginUser.getUserid();
Integer userType = loginUser.getUserType();
R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null,tenantId);
R user = xhpcCommonController.getMechanism(null, loginUser.getUserid(), loginUser.getUserType(), null, tenantId);
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
//发票留言板版本客服电话
@ -561,7 +561,8 @@ public class XhpcAppUserServiceImpl extends BaseService implements IXhpcAppUserU
LoginUser loginUser = logUserUtils.getLogUser(request);
//根据不同的用户类型查询不同的信息
Long userid = loginUser.getUserid();
R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null,loginUser.getTenantId());
R user = xhpcCommonController.getMechanism(null, loginUser.getUserid(), loginUser.getUserType(), null,
loginUser.getTenantId());
if(user !=null && user.getData() !=null){
Map<String, Object> map = (Map<String, Object>)user.getData();
if(UserTypeUtil.USER_TYPE.equals(userType)){

View File

@ -14,10 +14,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,10 +15,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -16,10 +16,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置