Commit 204f80b8 authored by 刘林's avatar 刘林

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents b67f861b 2ad763e7
...@@ -68,12 +68,15 @@ public class OpenApiControllerAop { ...@@ -68,12 +68,15 @@ public class OpenApiControllerAop {
private void fillRequestContext(String token) { private void fillRequestContext(String token) {
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX,token); String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token);
if (ValidationUtil.isEmpty(redisTemplate.opsForValue().get(tokenKey))) {
throw new AuthException("错误的token.");
}
BizTokenModel bizTokenModel = (BizTokenModel) redisTemplate.opsForValue().get(tokenKey); BizTokenModel bizTokenModel = (BizTokenModel) redisTemplate.opsForValue().get(tokenKey);
if(null == bizTokenModel) { if(null == bizTokenModel) {
throw new AuthException("请求未包含认证信息."); throw new AuthException("请求未包含认证信息.");
} }
String product = bizTokenModel.getProduct(); String product = bizTokenModel.getAppId(); // 使用appId作为每个对接单位的product
String appKey = bizTokenModel.getAppKey(); String appKey = bizTokenModel.getAppKey();
RequestContext.setToken(token); RequestContext.setToken(token);
RequestContext.setProduct(product); RequestContext.setProduct(product);
......
package com.yeejoin.amos.api.openapi.face.orm.dao; package com.yeejoin.amos.api.openapi.face.orm.dao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken; import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
...@@ -31,4 +31,7 @@ public interface OpenapiBizTokenMapper extends BaseMapper<OpenapiBizToken> { ...@@ -31,4 +31,7 @@ public interface OpenapiBizTokenMapper extends BaseMapper<OpenapiBizToken> {
@Select("select DEVELOPER_AGENCY from iot_openapi_biz_token where DEVELOPER_AGENCY is not null AND DATA_TYPE = 'cyl' group by DEVELOPER_AGENCY") @Select("select DEVELOPER_AGENCY from iot_openapi_biz_token where DEVELOPER_AGENCY is not null AND DATA_TYPE = 'cyl' group by DEVELOPER_AGENCY")
public List<String> getServiceList(); public List<String> getServiceList();
@Select("select use_unit_code, use_unit from amos_tzs_biz.tz_base_enterprise_info where app_id = '${appId}'")
Map<String, String> queryUnitInfoByAppId(@Param("appId") String appId);
} }
\ No newline at end of file
...@@ -8,8 +8,6 @@ import com.yeejoin.amos.api.openapi.face.model.*; ...@@ -8,8 +8,6 @@ import com.yeejoin.amos.api.openapi.face.model.*;
import com.yeejoin.amos.api.openapi.face.orm.dao.ESCylinderFillingInfoRepository; import com.yeejoin.amos.api.openapi.face.orm.dao.ESCylinderFillingInfoRepository;
import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity; import com.yeejoin.amos.boot.module.cylinder.api.entity.CylinderFillingMessageEntity;
import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingInfoDto; import com.yeejoin.amos.boot.module.cylinder.api.entity.ESCylinderFillingInfoDto;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -72,16 +70,17 @@ public class CylinderService { ...@@ -72,16 +70,17 @@ public class CylinderService {
@DSTransactional @DSTransactional
public void cylinderFillingHandler(String fillingData) throws MqttException { public void cylinderFillingHandler(String fillingData) throws MqttException {
String token = RequestContext.getToken(); String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, RequestContext.getToken());
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult(); if (ValidationUtil.isEmpty(this.redisTemplate.opsForValue().get(tokenKey))) {
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token); return;
}
BizTokenModel bizTokenModel = (BizTokenModel) this.redisTemplate.opsForValue().get(tokenKey); BizTokenModel bizTokenModel = (BizTokenModel) this.redisTemplate.opsForValue().get(tokenKey);
JSONObject jsonobject = JSONObject.fromObject(fillingData); JSONObject jsonobject = JSONObject.fromObject(fillingData);
CylinderFillingMessageEntity cylinderFillingMessageEntity = new CylinderFillingMessageEntity(); CylinderFillingMessageEntity cylinderFillingMessageEntity = new CylinderFillingMessageEntity();
cylinderFillingMessageEntity.setTime(simpleDateFormat.format(new Date())); cylinderFillingMessageEntity.setTime(simpleDateFormat.format(new Date()));
cylinderFillingMessageEntity.setFillingCompanyName(me.getCompanys().get(0).getCompanyName()); cylinderFillingMessageEntity.setFillingCompanyName(bizTokenModel.getApiCompanyName());
cylinderFillingMessageEntity.setFillingCompanyCode(me.getCompanys().get(0).getCompanyCode()); cylinderFillingMessageEntity.setFillingCompanyCode(bizTokenModel.getApiCompanyCode());
cylinderFillingMessageEntity.setAppId(cylinderFillingService.getAppId()); cylinderFillingMessageEntity.setAppId(cylinderFillingService.getAppId());
cylinderFillingMessageEntity.setRawData(fillingData); cylinderFillingMessageEntity.setRawData(fillingData);
......
package com.yeejoin.amos.api.openapi.face.service; package com.yeejoin.amos.api.openapi.face.service;
import cn.hutool.core.map.MapUtil;
import com.yeejoin.amos.api.openapi.constant.Constant; import com.yeejoin.amos.api.openapi.constant.Constant;
import com.yeejoin.amos.api.openapi.face.model.BizTokenModel; import com.yeejoin.amos.api.openapi.face.model.BizTokenModel;
import com.yeejoin.amos.api.openapi.face.model.OpenapiBizTokenModel; import com.yeejoin.amos.api.openapi.face.model.OpenapiBizTokenModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.OpenapiBizTokenMapper; import com.yeejoin.amos.api.openapi.face.orm.dao.OpenapiBizTokenMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken; import com.yeejoin.amos.api.openapi.face.orm.entity.OpenapiBizToken;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.component.robot.SystemUserInfo;
import com.yeejoin.amos.feign.privilege.Privilege; import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel; import com.yeejoin.amos.feign.privilege.model.IdPasswordAuthModel;
import com.yeejoin.amos.feign.privilege.util.DesUtil; import com.yeejoin.amos.feign.privilege.util.DesUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -16,10 +18,12 @@ import org.springframework.data.redis.core.RedisTemplate; ...@@ -16,10 +18,12 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.cache.Redis; import org.typroject.tyboot.component.cache.Redis;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
...@@ -36,6 +40,12 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op ...@@ -36,6 +40,12 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op
@Autowired @Autowired
private RedisTemplate redisTemplate; private RedisTemplate redisTemplate;
@Autowired
AmosRequestContext amosRequestContext;
@Autowired
SystemUserInfo systemUserInfo;
public static final String DEFAULT_PASSWORD = "a1234560"; public static final String DEFAULT_PASSWORD = "a1234560";
public List<String> getServiceList() { public List<String> getServiceList() {
...@@ -43,21 +53,32 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op ...@@ -43,21 +53,32 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op
} }
public String getByAppId(String appId) { public String getByAppId(String appId) {
Map<String, String> unitInfo = baseMapper.queryUnitInfoByAppId(appId);
if (ValidationUtil.isEmpty(unitInfo)) {
throw new RuntimeException("未找到对接单位信息");
}
String unitCode = MapUtil.getStr(unitInfo, "use_unit_code");
String unitName = MapUtil.getStr(unitInfo, "use_unit");
IdPasswordAuthModel idPasswordAuthModel = new IdPasswordAuthModel(); IdPasswordAuthModel idPasswordAuthModel = new IdPasswordAuthModel();
idPasswordAuthModel.setLoginId(appId); // 使用机器人登录:采用不同的product获取token
idPasswordAuthModel.setPassword(DesUtil.encode(DEFAULT_PASSWORD, Constant.PASSWORD_ENCODE_KEY)); idPasswordAuthModel.setLoginId(amosRequestContext.getUserName());
idPasswordAuthModel.setPassword(DesUtil.encode(systemUserInfo.getPassword(), Constant.PASSWORD_ENCODE_KEY));
BizTokenModel bizTokenModel = new BizTokenModel(); BizTokenModel bizTokenModel = new BizTokenModel();
bizTokenModel.setAppId(appId); bizTokenModel.setAppId(appId);
RequestContext.setProduct(bizTokenModel.getProduct()); RequestContext.setProduct(appId);
RequestContext.setAppKey(bizTokenModel.getAppKey()); RequestContext.setAppKey(bizTokenModel.getAppKey());
FeignClientResult<HashMap<String, Object>> responseModel = Privilege.authClient.idpassword(idPasswordAuthModel); FeignClientResult<HashMap<String, Object>> responseModel = Privilege.authClient.idpassword(idPasswordAuthModel);
HashMap<String, Object> authModel = responseModel.getResult(); HashMap<String, Object> authModel = responseModel.getResult();
String token = (String) authModel.get("token"); String token = (String) authModel.get("token");
bizTokenModel.setToken(token); bizTokenModel.setToken(token);
RequestContext.setToken(token); RequestContext.setToken(token);
AgencyUserModel user = Privilege.agencyUserClient.getme().getResult(); // AgencyUserModel user = Privilege.agencyUserClient.getme().getResult();
bizTokenModel.setApiCompanyCode(user.getCompanys().get(0).getCompanyCode()); // 当前一个人只能有一个单位 // bizTokenModel.setApiCompanyCode(user.getCompanys().get(0).getCompanyCode()); // 当前一个人只能有一个单位
bizTokenModel.setApiCompanyName(user.getCompanys().get(0).getCompanyName()); // 当前一个人只能有一个单位 // bizTokenModel.setApiCompanyName(user.getCompanys().get(0).getCompanyName()); // 当前一个人只能有一个单位
// 调整为从业务表根据appId查询单位信息
bizTokenModel.setApiCompanyCode(unitCode);
bizTokenModel.setApiCompanyName(unitName);
String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token); String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token);
this.redisTemplate.opsForValue().set(tokenKey, bizTokenModel); this.redisTemplate.opsForValue().set(tokenKey, bizTokenModel);
return token; return token;
......
...@@ -68,3 +68,9 @@ biz.lxyd.lift.url=http://39.106.181.149:8088/elevatorapi ...@@ -68,3 +68,9 @@ biz.lxyd.lift.url=http://39.106.181.149:8088/elevatorapi
elasticsearch.username=elastic elasticsearch.username=elastic
elasticsearch.password=a123456 elasticsearch.password=a123456
spring.elasticsearch.rest.uris=http://172.16.10.243:9200 spring.elasticsearch.rest.uris=http://172.16.10.243:9200
spring.servlet.multipart.max-file-size=100MB
spring.servlet.multipart.max-request-size=100MB
feign.client.config.default.connect-timeout=600000
feign.client.config.default.read-timeout=600000
\ No newline at end of file
...@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation; ...@@ -15,6 +15,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
...@@ -87,6 +88,7 @@ public class BizDataChangeController extends BaseController { ...@@ -87,6 +88,7 @@ public class BizDataChangeController extends BaseController {
secondParamValue = "CQ" secondParamValue = "CQ"
) )
}) })
@RestEventTrigger(value = "operateLogRestEventHandler")
public ResponseModel<String> saveV2(@ApiParam(value = "设备或者装置唯一标识") @RequestParam String bizId, public ResponseModel<String> saveV2(@ApiParam(value = "设备或者装置唯一标识") @RequestParam String bizId,
@ApiParam(required = true, value = "单据编号或者record") @RequestParam String applyNo, @ApiParam(required = true, value = "单据编号或者record") @RequestParam String applyNo,
@ApiParam(required = true, value = "业务类型") @PathVariable String bizType, @ApiParam(required = true, value = "业务类型") @PathVariable String bizType,
......
package com.yeejoin.amos.boot.module.ymt.api.entity; package com.yeejoin.amos.boot.module.ymt.api.entity;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine; import com.yeejoin.amos.boot.biz.common.annotation.FieldDisplayDefine;
...@@ -224,7 +225,7 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData { ...@@ -224,7 +225,7 @@ public class IdxBizJgUseInfo extends TzsBaseEntity implements IBaseChangeData {
/** /**
* 创建时间 * 创建时间
*/ */
@TableField("\"CREATE_DATE\"") @TableField(value = "\"CREATE_DATE\"", fill = FieldFill.INSERT)
private Date createDate; private Date createDate;
/** /**
......
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 to comment