Commit 10491c62 by huangjy

Merge remote-tracking branch 'origin/feat_multi_wx_appid' into dev

parents c7e2ae7b 2442c386
ALTER TABLE `plat_device_other`
ALTER TABLE `plat_device_other`
......@@ -33,4 +33,8 @@ ADD COLUMN `license_info` varchar(255) COMMENT '许可证信息' AFTER `license`
ALTER TABLE `plat_device`
ADD COLUMN `expire_time` int8 COMMENT '过期时间' AFTER `license_info`,
ADD COLUMN `activation_time` int8 COMMENT '激活时间' AFTER `expire_time`;
\ No newline at end of file
ADD COLUMN `activation_time` int8 COMMENT '激活时间' AFTER `expire_time`;
ALTER TABLE `plat_tenant`
ADD COLUMN `appid` varchar(64) COMMENT 'appid' AFTER `url`,
ADD COLUMN `secret` varchar(64) COMMENT 'secret' AFTER `appid`;
\ No newline at end of file
......@@ -20,10 +20,8 @@ import com.makeit.vo.platform.device.PlatDeviceListVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -99,4 +97,14 @@ public class SaasDeviceController {
return ApiResponseUtils.success();
}
@ApiOperation("设备日志推送")
@PostMapping("devicePushLog")
@TenantIdIgnore
@AuthIgnore
public ApiResponseEntity devicePushLog(@RequestParam(value = "file", required = false) MultipartFile multipartFile,
@RequestParam(value = "deviceId") String deviceId) {
platDeviceService.devicePushLog(multipartFile);
return ApiResponseUtils.success();
}
}
......@@ -61,4 +61,8 @@ public class PlatTenantDTOVO extends BaseIdDTO {
@ApiModelProperty(value = "租户平台地址")
private String url;
@ApiModelProperty(value = "appid")
private String appid;
@ApiModelProperty(value = "secret")
private String secret;
}
......@@ -4,6 +4,7 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaRedissonConfigImpl;
import lombok.Data;
import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.WxMpConfigStorage;
......@@ -15,6 +16,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@Data
public class WxConfig {
@Value("${wx.miniapp.config.appid}")
......
......@@ -35,6 +35,10 @@ public class WechatLoginPhoneDTO {
@ApiModelProperty(value = "组织路径")
private String orgPath;
@ApiModelProperty(value = "微信appid")
private String appid;
@ApiModelProperty(value = "微信secret")
private String secret;
}
......@@ -3,6 +3,8 @@ package com.makeit.utils.third.wechat;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import cn.binarywang.wx.miniapp.config.WxMaConfig;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import com.makeit.config.WxMaConfiguration;
import com.makeit.enums.CodeMessageEnum;
import com.makeit.exception.BusinessException;
......@@ -21,6 +23,10 @@ public class WechatUtil {
}
WxMaService wxService = WxMaConfiguration.getMaService();
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid(dto.getAppid());
config.setSecret(dto.getSecret());
wxService.setWxMaConfig(config);
try {
WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(code);
......
......@@ -21,4 +21,32 @@ public class PlatDeviceBaseAttrDTO {
@ApiModelProperty(value = "\"最小值\":200,\"最大值\":380,\"步\n" +
"进\":1,\"单位\":\"cm\"")
private Integer radarHight;
@ApiModelProperty(value = "雷达检测距离范围 示例:{\n" +
"\"max\": 1000,\n" +
"\"min\": 0,\n" +
"}",notes = "最大距离:\n" +
"在侧装模式下,表示检测的最远的距\n" +
"离,\n" +
"在顶装区域的模式下,表示检测的最右\n" +
"的距离\n" +
"最小距离:\n" +
"在侧装模式下,表示检测的最近的距\n" +
"离,\n" +
"在顶装区域的模式下,表示检测的最左\n" +
"的距离")
private DeviceAttrRange radarDistance;
@ApiModelProperty(value = "雷达检测角度范围 范围:±60 ,单位°,仅侧装有效 示例:{\n" +
"\"max\": 60,\n" +
"\"min\": -60,\n" +
"}")
private DeviceAttrRange radarAngle;
@ApiModelProperty(value = "雷达检测延迟时间 单位S ,范围:0-32768")
private Integer radarDelay;
@Data
static class DeviceAttrRange {
private Integer max;
private Integer min;
}
}
......@@ -3,6 +3,7 @@ package com.makeit.entity.platform.device;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.dto.platform.device.PlatDeviceBaseAttrDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......
......@@ -63,6 +63,8 @@ public class PlatTenant extends BaseEntity {
* 租户平台地址
*/
private String url;
private String appid;
private String secret;
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import com.makeit.shengwang.agora.vo.PlatAlarmCallDeviceVO;
import com.makeit.vo.platform.device.PlatChildDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceListVO;
import com.makeit.vo.platform.device.PlatDeviceViewVO;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -88,4 +89,6 @@ public interface PlatDeviceService extends IService<PlatDevice> {
PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto);
PlatAlarmCallDeviceVO callingDevice(PlatCallingDeviceDTO dto);
void devicePushLog(MultipartFile multipartFile);
}
......@@ -77,6 +77,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
......@@ -523,6 +524,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (dto.getRadarHight() != null) {
map.put("radarHight", dto.getRadarHight() );
}
if (dto.getRadarDelay() != null) {
map.put("radarDelay", dto.getRadarDelay() );
}
if (dto.getRadarDistance() != null) {
map.put("radarDistance", JSON.toJSONString(dto.getRadarDistance()));
}
if (dto.getRadarAngle() != null) {
map.put("radarAngle", JSON.toJSONString(dto.getRadarAngle()));
}
return map;
}
......@@ -744,6 +754,12 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
@Transactional(rollbackFor = Exception.class)
public void active(BaseIdDTO dto) {
PlatDevice platDevice = getById(dto.getId());
Map<String, Object> resMap = new HashMap<>();
resMap.put("appid",shengwangProperties.getAppId());
String AttrResult = devicePropertiesOperateService.deviceWriteAttr(platDevice.getOriDeviceId(), resMap);
if (StringUtils.isNotEmpty(AttrResult)) {
throw new RuntimeException(AttrResult);
}
String active = shengwangHttpUtil.active(platDevice.getOriDeviceId());
ApiResponseEntity responseEntity = JSON.parseObject(active, ApiResponseEntity.class);
if (responseEntity.getCode() != 200) {
......@@ -761,7 +777,6 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
// 调用设备写入接口
Map<String, Object> map = new HashMap<>();
map.put("license",platDeviceActiveVO.getLicense());
map.put("appid",shengwangProperties.getAppId());
String result = devicePropertiesOperateService.deviceWriteAttr(platDevice.getOriDeviceId(), map);
if (StringUtils.isNotEmpty(result)) {
......@@ -792,4 +807,9 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
public PlatAlarmCallDeviceVO getDeviceRtmToken(PlatCallingDeviceDTO dto) {
return shengwangService.callingDeviceAuthIgnoreRtm(dto);
}
@Override
public void devicePushLog(MultipartFile multipartFile) {
}
}
package com.makeit.service.saas.impl;
import cn.binarywang.wx.miniapp.api.WxMaService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -8,6 +9,7 @@ import com.makeit.common.entity.BaseBusEntity;
import com.makeit.common.entity.BaseEntity;
import com.makeit.common.page.PageReqDTO;
import com.makeit.common.page.PageVO;
import com.makeit.config.WxMaConfiguration;
import com.makeit.dto.platform.sys.PlatLogoConfigDTO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser;
......@@ -38,6 +40,7 @@ import com.makeit.service.saas.SaasUserService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.msg.config.WxConfig;
import com.makeit.utils.redis.RedisCacheUtil;
import com.makeit.utils.user.plat.PlatUserUtil;
import com.makeit.utils.user.plat.PlatUserVO;
......@@ -85,6 +88,8 @@ public class PlatTenantServiceImpl extends ServiceImpl<PlatTenantMapper, PlatTen
private IotOrgService iotOrgService;
@Autowired
private PlatLogoConfigService platLogoConfigService;
@Autowired
private WxConfig wxConfig;
private LambdaQueryWrapper<PlatTenant> listLambdaQueryWrapper(PlatTenantVO dto, boolean userAccountLike) {
......@@ -258,6 +263,13 @@ public class PlatTenantServiceImpl extends ServiceImpl<PlatTenantMapper, PlatTen
checkCode(dto);
PlatTenant tntTenant = BeanDtoVoUtils.convert(dto, PlatTenant.class);
if (StringUtils.isEmpty(tntTenant.getAppid())) {
tntTenant.setAppid(wxConfig.getAppId());
}
if (StringUtils.isEmpty(tntTenant.getSecret())) {
tntTenant.setSecret(wxConfig.getMpSecret());
}
//新租户同步到iot
PlatTenantVO platTenantVO = new PlatTenantVO();
platTenantVO.setName(dto.getName());
......
......@@ -3,14 +3,17 @@ package com.makeit.service.wechat.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.auth.PlatOrgSplitDTO;
import com.makeit.entity.platform.elder.PlatElderChildrenInfo;
import com.makeit.entity.saas.PlatTenant;
import com.makeit.enums.Const;
import com.makeit.enums.HeaderConst;
import com.makeit.global.aspect.misc.nofill.NoFillUtil;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.PlatElderChildrenInfoService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.service.wechat.PlatElderChildrenInfoUserLoginWechatService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.id.IdGen;
import com.makeit.utils.msg.config.WxConfig;
import com.makeit.utils.request.RequestUtil;
import com.makeit.utils.sys.FileUtil;
import com.makeit.utils.third.wechat.WechatLoginPhoneDTO;
......@@ -35,7 +38,9 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
private PlatElderChildrenInfoService platElderChildrenInfoService;
@Autowired
private PlatOrgService platOrgService;
private PlatTenantService platTenantService;
@Autowired
private WxConfig wxConfig;
private static final Logger logger = LoggerFactory.getLogger(PlatElderChildrenInfoUserLoginWechatServiceImpl.class);
......@@ -43,6 +48,16 @@ public class PlatElderChildrenInfoUserLoginWechatServiceImpl implements PlatElde
@Transactional
public WechatUserInfo login(WechatLoginPhoneDTO dto) {
PlatTenant platTenant = platTenantService.getOne(new QueryWrapper<PlatTenant>().lambda()
.eq(PlatTenant::getAppid, dto.getAppid())
.last("limit 1"));
if (platTenant != null) {
dto.setAppid(platTenant.getAppid());
dto.setSecret(platTenant.getSecret());
} else {
dto.setAppid(wxConfig.getAppId());
dto.setSecret(wxConfig.getAppSecret());
}
WxUserInfo userInfo = WechatUtil.login(dto);
logger.info("userinfo:{}", userInfo);
......
......@@ -14,8 +14,8 @@ spring:
idle-timeout: 60000
login-timeout: 5
max-lifetime: 60000
maximum-pool-size: 10
minimum-idle: 5
maximum-pool-size: 50
minimum-idle: 10
read-only: false
#jackson时间格式化
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment