Commit 437d5634 authored by zhangyingbin's avatar zhangyingbin

工商信息接口开发调试

parent bbfdfba4
......@@ -4,9 +4,8 @@ import com.yeejoin.amos.api.common.restful.utils.ResponseHelper;
import com.yeejoin.amos.api.common.restful.utils.ResponseModel;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaAccessConfig;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseBaseInfo;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseDetailInfo;
import com.yeejoin.amos.api.openapi.face.service.TaAccessConfigServiceImpl;
import com.yeejoin.amos.api.openapi.face.service.TaBusinessServiceImpl;
import com.yeejoin.amos.api.openapi.face.service.TaLicenseBaseInfoServiceImpl;
import com.yeejoin.amos.api.openapi.face.service.TaLicenseDetailInfoServiceImpl;
import io.swagger.annotations.Api;
......@@ -21,6 +20,7 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/business")
......@@ -31,66 +31,78 @@ public class BusinessController {
private TaAccessConfigServiceImpl taAccessConfigService;
@Autowired
private TaBusinessServiceImpl taBusinessService;
@Autowired
private TaLicenseDetailInfoServiceImpl taLicenseDetailInfoService;
@Autowired
private TaLicenseBaseInfoServiceImpl taLicenseBaseInfoService;
// /**
// * 新增许可信息-接入配置表
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @RequestMapping(value = "/saveAccessConfig", method = RequestMethod.POST)
// @ApiOperation(httpMethod = "POST", value = "新增许可信息-接入配置表", notes = "新增许可信息-接入配置表")
// @RestEventTrigger(value = "openapiLogEventHandler")
// public ResponseModel<String> saveTaAccessConfig (@RequestBody List<TaAccessConfig> produceInfo) throws Exception
// {
// return ResponseHelper.buildResponse(taAccessConfigService.saveAccessConfig(produceInfo));
// }
//
// /**
// * 新增许可信息-许可基本信息表
// *
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @RequestMapping(value = "/saveLinceseBaseInfo", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "新增许可信息-许可基本信息表", notes = "新增许可信息-许可基本信息表")
// @RestEventTrigger(value = "openapiLogEventHandler")
// public ResponseModel<String> saveTaLicenseBaseInfo() throws Exception {
// taLicenseBaseInfoService.syncLicenseData();
// return ResponseHelper.buildResponse("");
// }
//
// /**
// * 新增许可信息-许可详细信息表
// *
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @RequestMapping(value = "/saveLinceseDetailInfo", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "新增许可信息-许可详细信息表", notes = "新增许可信息-许可详细信息表")
// @RestEventTrigger(value = "openapiLogEventHandler")
// public ResponseModel<String> saveTaLicenseDetailInfo()
// throws Exception {
// taLicenseDetailInfoService.syncLicenseData();
// return ResponseHelper.buildResponse("");
// }
//
// /**
// * 新增许可信息-许可详细信息表
// *
// * @return
// */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @RequestMapping(value = "/refreshConfig", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "更新配置", notes = "更新配置")
// @RestEventTrigger(value = "openapiLogEventHandler")
// public ResponseModel<String> refreshConfig()
// throws Exception {
// taAccessConfigService.refreshConfig();
// return ResponseHelper.buildResponse("");
// }
/**
* 新增许可信息-接入配置表
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveAccessConfig", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "新增许可信息-接入配置表", notes = "新增许可信息-接入配置表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaAccessConfig (@RequestBody List<TaAccessConfig> produceInfo) throws Exception
{
return ResponseHelper.buildResponse(taAccessConfigService.saveAccessConfig(produceInfo));
}
/**
* 新增许可信息-许可基本信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveLinceseBaseInfo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "新增许可信息-许可基本信息表", notes = "新增许可信息-许可基本信息表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaLicenseBaseInfo() throws Exception {
taLicenseBaseInfoService.syncLicenseData();
return ResponseHelper.buildResponse("");
}
/**
* 新增许可信息-许可详细信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/saveLinceseDetailInfo", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "新增许可信息-许可详细信息表", notes = "新增许可信息-许可详细信息表")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> saveTaLicenseDetailInfo()
throws Exception {
taLicenseDetailInfoService.syncLicenseData();
return ResponseHelper.buildResponse("");
}
/**
* 新增许可信息-许可详细信息表
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/refreshConfig", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "更新配置", notes = "更新配置")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> refreshConfig()
throws Exception {
taAccessConfigService.refreshConfig();
return ResponseHelper.buildResponse("");
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@RequestMapping(value = "/getData", method = RequestMethod.GET)
@ApiOperation(httpMethod = "GET", value = "获取map", notes = "获取map")
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<Map<String, Object>> getData(String code) throws Exception {
return ResponseHelper.buildResponse(taBusinessService.getData(code));
}
}
package com.yeejoin.amos.api.openapi.face.orm.dao;
public interface DataDictionaryMapper {
String getData(String code);
}
package com.yeejoin.amos.api.openapi.face.service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -8,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.support.CronTrigger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
......@@ -15,6 +18,7 @@ import com.yeejoin.amos.api.openapi.face.model.TaAccessConfigModel;
import com.yeejoin.amos.api.openapi.face.orm.dao.TaAccessConfigMapper;
import com.yeejoin.amos.api.openapi.face.orm.entity.TaAccessConfig;
import com.yeejoin.amos.openapi.enums.TaAccessConfigBizeEnum;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
/**
* 附件表 服务实现类
......@@ -40,20 +44,20 @@ public class TaAccessConfigServiceImpl extends BaseService<TaAccessConfigModel,
* @param model 接入配置实体类集合
* @return 成功返回“OK”
*/
// @Transactional(rollbackFor = { Exception.class })
// public String saveAccessConfig(List<TaAccessConfig> model) {
// // TODO Auto-generated method stub
// if (ValidationUtil.isEmpty(model)) {
// throw new BadRequest("接入配置表信息为空.");
// }
// for (TaAccessConfig models : model) {
//// checkModel(models);
// models.setRecDate(new Date());
//// models.setAppId(getAppId());
// }
// this.saveBatch(model);
// return "OK";
// }
@Transactional(rollbackFor = { Exception.class })
public String saveAccessConfig(List<TaAccessConfig> model) {
// TODO Auto-generated method stub
if (ValidationUtil.isEmpty(model)) {
throw new BadRequest("接入配置表信息为空.");
}
for (TaAccessConfig models : model) {
// checkModel(models);
models.setRecDate(new Date());
// models.setAppId(getAppId());
}
this.saveBatch(model);
return "OK";
}
public void refreshConfig() {
licenseConfig.clear();
......
......@@ -6,6 +6,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.csoft.sdk.domain.CsoftDataApiXixianParam;
import com.csoft.sdk.domain.request.CsoftDataApiXixianRequest;
import com.csoft.sdk.domain.response.CsoftDataApiXixianResponse;
import com.yeejoin.amos.api.openapi.face.orm.dao.DataDictionaryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......@@ -29,49 +34,65 @@ import com.yeejoin.amos.api.openapi.face.orm.entity.TaLicenseBaseInfo;
@Service
public class TaBusinessServiceImpl extends BaseService<TaAccessConfigModel, TaAccessConfig, TaAccessConfigMapper> {
// public Map<String, Object> getData(String code) throws Exception {
// Map<String, String> map = TaAccessConfigServiceImpl.licenseConfig;
// String appId = map.get("appId");
// String appKey = map.get("appKey");
// String appSecret = map.get("appSecret");
// String server = map.get("server");
// App app = App.of(appId, appKey, appSecret, server);
// CsoftDefaultSdkClient client = CsoftDefaultSdkClient.of(app);
// // 3.设置参数,发送请求,并处理结果
// CsoftDataApiXixianParam csoftDataApiXixianParam = new CsoftDataApiXixianParam();
// csoftDataApiXixianParam.setUniscid(code);
// CsoftDataApiXixianRequest request = new CsoftDataApiXixianRequest(csoftDataApiXixianParam);
// CsoftDataApiXixianResponse response = client.execute(request);
// Map<String, Object> result = new HashMap<>();
// // 4.返回校验
// if (response.isSuccess()) {
// System.out.println("成功:" + response.getData());
// System.out.println(response.getResult());
// JSONObject jsonObject = JSONObject.parseObject(response.getData());
// JSONObject data = jsonObject.getJSONObject("data");
// JSONArray jsonArray = data.getJSONArray("objList");
// //所属行业
// result.put("industry", value);
// //注册地址 省/市/区
// result.put("area", value);
// //注册地址 街道地址
// result.put("street", value);
// //注册地址 小区地址
// result.put("community", value);
// //注册地址 详细地址
// result.put("address", value);
// //登记机关
// result.put("registration_authority", value);
// //核准时间
// result.put("approval_time", value);
// //经营状态
// result.put("operating_status", value);
// } else {
// System.out.println("失败:" + response.getErrorMsg());
// System.out.println("失败:" + response.getErrorCode());
// throw new Exception(response.getErrorMsg());
// }
// return result;
// }
@Autowired
private DataDictionaryMapper dataDictionaryMapper;
public Map<String, Object> getData(String code) throws Exception {
Map<String, String> map = TaAccessConfigServiceImpl.licenseConfig;
String appId = map.get("appId");
String appKey = map.get("appKey");
String appSecret = map.get("appSecret");
String server = map.get("server");
App app = App.of(appId, appKey, appSecret, server);
CsoftDefaultSdkClient client = CsoftDefaultSdkClient.of(app);
// 3.设置参数,发送请求,并处理结果
CsoftDataApiXixianParam csoftDataApiXixianParam = new CsoftDataApiXixianParam();
csoftDataApiXixianParam.setUniscid(code);
CsoftDataApiXixianRequest request = new CsoftDataApiXixianRequest(csoftDataApiXixianParam);
CsoftDataApiXixianResponse response = client.execute(request);
Map<String, Object> result = new HashMap<>();
// 4.返回校验
if (response.isSuccess()) {
System.out.println("成功:" + response.getData());
System.out.println(response.getResult());
JSONObject jsonObject = JSONObject.parseObject(response.getData());
JSONObject data = jsonObject.getJSONObject("data");
//分割字符串 根据详细地址分割出 省/市/区、街道地址、小区地址
String address = data.getString("dom");
String area = address.substring(0,address.indexOf("区")+1);
String street = address.substring(area.length()).substring(0,address.substring(area.length()).indexOf("号")+1);
String community = address.substring(area.length()+street.length());
String industry = getIndustry(data.getString("hydm"));
//所属行业
result.put("industry", industry);
//注册地址 省/市/区
result.put("area", area);
//注册地址 街道地址
result.put("street", street);
//注册地址 小区地址
result.put("community", community);
//注册地址 详细地址
result.put("address", data.get("dom"));
//登记机关
result.put("registration_authority", data.get("regorg"));
//核准时间
result.put("approval_time", data.get("hzrq"));
//经营状态
result.put("operating_status", data.get("opstate"));
} else {
System.out.println("失败:" + response.getErrorMsg());
System.out.println("失败:" + response.getErrorCode());
throw new Exception(response.getErrorMsg());
}
return result;
}
public String getIndustry(String code){
return dataDictionaryMapper.getData(code.substring(0,2));
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.api.openapi.face.orm.dao.DataDictionaryMapper">
<select id="getData" resultType="java.lang.String">
select `name` FROM cb_data_dictionary WHERE code=#{code} and type="IndustryCode"
</select>
</mapper>
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