Commit be956de4 authored by tianbo's avatar tianbo

feat(openapi): 添加手动生成AppId功能并优化查询逻辑

- 新增OpenapiBizTokenModel和OpenapiBizTokenService用于手动创建AppId - 修改applyAppId接口名称为genAppId并支持手动为企业生成AppId - 实现AppId查询时优先从iot_openapi_biz_token表查询,未找到则从业务库查询 - 更新AOP配置中的URL映射路径以匹配新的接口名称 - 在计划任务服务中添加日志记录完整的执行时间信息
parent b14e6f95
......@@ -44,7 +44,7 @@ public class OpenApiControllerAop {
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany","/bizToken/applyToken",
"/openapi/bizToken/getAppId","/lift/upload","/lift/status","/lift/run","/lift/fault",
"/lift/video/preview","/cylinderPage/serviceProvider","/cylinderPage/getTableInfo",
"/cylinderPage/initCylinderNum","/openapi/appId/setAppId"};
"/cylinderPage/initCylinderNum","/openapi/appId/genAppId"};
// 获取请求路径
for(String uri : url) {
if(request.getRequestURI().indexOf(uri) != -1) {
......
......@@ -3,11 +3,14 @@ package com.yeejoin.amos.api.openapi.controller;
import com.yeejoin.amos.api.common.restful.utils.ResponseHelper;
import com.yeejoin.amos.api.common.restful.utils.ResponseModel;
import com.yeejoin.amos.api.openapi.constant.Constant;
import com.yeejoin.amos.api.openapi.face.model.OpenapiBizTokenModel;
import com.yeejoin.amos.api.openapi.face.service.OpenapiBizTokenService;
import com.yeejoin.amos.feign.privilege.util.DesUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -26,15 +29,23 @@ public class AppIdMain {
// logger.info("appId信息:", appId);
// System.out.println("appId信息:" + appId);
// }
@Autowired
OpenapiBizTokenService openapiBizTokenService;
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "生成AppId")
@GetMapping(value = "/setAppId")
public ResponseModel<String> applyAppId (
@RequestParam String apiCompanyCode) throws Exception
{
logger.info("appId信息:",apiCompanyCode);
@ApiOperation(value = "手动为对接企业生成AppId")
@GetMapping(value = "/genAppId")
public ResponseModel<String> applyAppId (@RequestParam String apiCompanyCode, @RequestParam String apiCompanyName) {
logger.info("开始为apiCompanyCode生成对应appId信息:{}",apiCompanyCode);
String appId = DesUtil.encode(apiCompanyCode, Constant.SECRETKEY);
logger.info("appToken信息:",appId);
OpenapiBizTokenModel openapiBizTokenModel = new OpenapiBizTokenModel();
openapiBizTokenModel.setAppId(appId);
openapiBizTokenModel.setApiCompanyCode(apiCompanyCode);
openapiBizTokenModel.setApiCompanyName(apiCompanyName);
openapiBizTokenService.createWithModel(openapiBizTokenModel);
logger.info("appToken信息:{}",appId);
return ResponseHelper.buildResponse(appId);
}
}
......@@ -53,7 +53,16 @@ public class OpenapiBizTokenService extends BaseService<OpenapiBizTokenModel, Op
}
public String getByAppId(String appId) {
Map<String, String> unitInfo = baseMapper.queryUnitInfoByAppId(appId);
// 先从iot_openapi_biz_token表中查询(手动创建不需要在平台注册的对接方的appId信息),如果未找到则从业务库企业表查询
OpenapiBizToken openapiBizToken = baseMapper.getByAppId(appId);
Map<String, String> unitInfo = MapUtil.newHashMap();
if (!ValidationUtil.isEmpty(openapiBizToken)) {
unitInfo.put("use_unit_code", openapiBizToken.getApiCompanyCode());
unitInfo.put("use_unit", openapiBizToken.getApiCompanyName());
}
if (ValidationUtil.isEmpty(unitInfo)) {
unitInfo = baseMapper.queryUnitInfoByAppId(appId);
}
if (ValidationUtil.isEmpty(unitInfo)) {
throw new RuntimeException("未找到对接单位信息");
}
......
......@@ -930,6 +930,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
log.error(e.getMessage());
}
System.out.println(userDetailsDtos.size() + "===================");
log.info("生成的完整时间======={}", JSONObject.toJSONString(timeList));
return PlanTaskUtil.genWholeExeData(timeList, plan, userDetailsDtos, route);
}
......@@ -948,6 +949,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
HashMap<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("id", plan.getId());
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
log.info("insertPlanTaskAndDetNew更新下次任务生成日期======={}", JSONObject.toJSONString(paramMap));
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
} else {
try {
......@@ -1079,7 +1081,7 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
paramMap.put("first_flag", XJConstant.PLAN_FIRST_STATUS_NO);
}
if (DateUtil.str2Date(strGenDate, "yyyy-MM-dd").getTime() - now.getTime() < 0 || org.apache.commons.lang.StringUtils.isBlank(strGenDate)) {
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));
paramMap.put("next_gen_date", DateUtil.formatDatrToStr(now, "yyyy-MM-dd"));//TODO 确认这里now对着不
}
planMapper.updPlanStatusOrGenDate(paramMap);// 更新下次任务生成日期
......
package com.yeejoin.amos.patrol.business.util;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.patrol.business.constants.XJConstant;
import com.yeejoin.amos.patrol.business.dto.UserDetailsDto;
import com.yeejoin.amos.patrol.business.vo.CalDateVo;
......@@ -11,7 +12,6 @@ import com.yeejoin.amos.patrol.exception.YeeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -562,6 +562,7 @@ public static List<HashMap<String, Object>> genWholeExeData(List<HashMap<String,
} else {
wholeList = timeList;
}
log.info("genWholeExeData:{}", JSONObject.toJSONString(wholeList));
return wholeList;
}
......
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