企查查数据库更新

This commit is contained in:
JIAL 2024-01-12 09:15:48 +08:00
parent db7cdc319b
commit 3820d90eda
11 changed files with 148 additions and 41 deletions

View File

@ -1,14 +1,13 @@
package com.JIAL.demo.bizquery.controller;
import com.JIAL.common.R;
import com.JIAL.demo.bizquery.dto.Biz;
import com.JIAL.demo.bizquery.dto.BizDto;
import com.JIAL.demo.bizquery.service.BizService;
import com.JIAL.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
@ -31,12 +30,12 @@ public class BizController {
BizService bizService;
@PostMapping("list")
public R<List<Biz>> queryBizList(@RequestParam("name") String name) {
public R<List<BizDto>> queryBizList(@RequestParam("name") String name) {
log.info("开始调用sql----------------------");
log.info(name);
log.info(String.valueOf(bizService == null));
List<Biz> resultList = bizService.queryBizListByName(name);
List<BizDto> resultList = bizService.queryBizListByName(name);
log.info(resultList.toString());
return R.success(resultList);

View File

@ -2,6 +2,7 @@ package com.JIAL.demo.bizquery.controller;
import com.JIAL.API.qichacha.QccApiUntils;
import com.JIAL.common.R;
import com.JIAL.utils.HttpHelper;
import com.JIAL.utils.JSONHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.methods.HttpHead;
import org.junit.Test;
@ -43,18 +44,12 @@ public class BizQccController {
@PostMapping
public R<Map<String, String>> queryCompanyInfo(@RequestParam("name") String name) {
log.info("Qcc_Key: {}", Qcc_Key);
log.info("Qcc_SecretKey: {}", Qcc_SecretKey);
log.info("Qcc_Url: {}", Qcc_Url);
log.info("unitName: {}", name);
String paramStr = "searchKey=";
String status = "";
// 判断 name 是否为空避免拼接出现异常,将传入的
if (name != null && !name.isEmpty()) {
// 拼接参数字符串
paramStr += "无锡江南电缆有限公司";
paramStr += name;
}
try{
@ -68,10 +63,10 @@ public class BizQccController {
String tokenJson = HttpHelper.httpGet(reqUri, reqHeader.getAllHeaders());
log.info("tokenJson: {}", tokenJson);
status = FormartJson(tokenJson, "Status");
status = JSONHelper.formartJson(tokenJson, "Status");
log.info("Status:{}", status);
if (!QccApiUntils.HttpCodeRegex.isAbnornalRequest(status)) {
PrettyPrintJson(tokenJson);
JSONHelper.prettyPrintJson(tokenJson);
}
} catch (Exception e1) {
@ -81,13 +76,4 @@ public class BizQccController {
return null;
}
// 获取当前时间的毫秒级Unix时间戳
@Test
public void Test() {
log.info("Qcc_Key: {}", Qcc_Key);
log.info("Qcc_SecretKey: {}", Qcc_SecretKey);
log.info("Qcc_Url: {}", Qcc_Url);
}
}

View File

@ -12,7 +12,7 @@ import java.io.Serializable;
* @Version 1.0
*/
@Data
public class Biz implements Serializable {
public class BizDto implements Serializable {
private static final long serialVersionUID = 1L;
private String kunnr;

View File

@ -0,0 +1,28 @@
package com.JIAL.demo.bizquery.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @ClassName QccInfo
* @Description qcc_info表对应的实体类
* @Author JIAL
* @Date 2024/1/12 8:59
* @Version 1.0
*/
@Data
public class QccInfo {
String name;
String qccJson;
@TableField(fill = FieldFill.INSERT) //插入时填充字段
private LocalDateTime createTime;
@TableField(fill = FieldFill.INSERT_UPDATE) //插入和更新时填充字段
private LocalDateTime updateTime;
}

View File

@ -1,16 +1,9 @@
package com.JIAL.demo.bizquery.mapper;
import com.JIAL.demo.bizquery.dto.Biz;
import com.alibaba.druid.support.logging.LogFactory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.JIAL.demo.bizquery.dto.BizDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;
import sun.rmi.runtime.Log;
import java.util.List;
@ -25,7 +18,7 @@ import java.util.List;
@Repository
public interface BizMapper {
@Select("select kunnr,name1 from openquery(hana2,'select top 10 * from SAPHANADB.kna1 where name1 like ''%${name}%'' and name1 not like ''冻结''')")
List<Biz> queryBizListByName(String name);
List<BizDto> queryBizListByName(String name);
@Select("select * from openquery(hana2,'select max(erdat) from SAPHANADB.likp where kunnr = ''${kunnr}'' and erdat >= ''${time}''')")
String queryLatestShippingDate(String kunnr, String time);

View File

@ -0,0 +1,17 @@
package com.JIAL.demo.bizquery.mapper;
import com.JIAL.demo.bizquery.entity.QccInfo;
import com.github.yulichang.base.MPJBaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* @ClassName QccInfoMapper
* @Description TODO
* @Author JIAL
* @Date 2024/1/12 9:06
* @Version 1.0
*/
@Mapper
public interface QccInfoMapper extends MPJBaseMapper<QccInfo> {
}

View File

@ -1,9 +1,6 @@
package com.JIAL.demo.bizquery.service;
import com.JIAL.demo.bizquery.dto.Biz;
import com.github.yulichang.base.MPJBaseService;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import com.JIAL.demo.bizquery.dto.BizDto;
import java.util.List;
@ -16,7 +13,7 @@ import java.util.List;
*/
public interface BizService {
List<Biz> queryBizListByName(String name);
List<BizDto> queryBizListByName(String name);
String queryLatestShippingDate(String kunnr, String time);

View File

@ -0,0 +1,16 @@
package com.JIAL.demo.bizquery.service;
import com.JIAL.demo.bizquery.entity.QccInfo;
import com.github.yulichang.base.MPJBaseService;
/**
* @ClassName QccInfoService
* @Description TODO
* @Author JIAL
* @Date 2024/1/12 9:05
* @Version 1.0
*/
public interface QccInfoService extends MPJBaseService<QccInfo> {
}

View File

@ -1,9 +1,8 @@
package com.JIAL.demo.bizquery.service.impl;
import com.JIAL.demo.bizquery.dto.Biz;
import com.JIAL.demo.bizquery.dto.BizDto;
import com.JIAL.demo.bizquery.mapper.BizMapper;
import com.JIAL.demo.bizquery.service.BizService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -30,7 +29,7 @@ public class BizServiceImpl implements BizService {
* @return: java.util.List<com.JIAL.demo.bizquery.dto.Biz>
*/
@Override
public List<Biz> queryBizListByName(String name) {
public List<BizDto> queryBizListByName(String name) {
return bizMapper.queryBizListByName(name);
}

View File

@ -0,0 +1,19 @@
package com.JIAL.demo.bizquery.service.impl;
import com.JIAL.demo.bizquery.entity.QccInfo;
import com.JIAL.demo.bizquery.mapper.QccInfoMapper;
import com.JIAL.demo.bizquery.service.QccInfoService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
/**
* @ClassName QccInfoServiceImpl
* @Description TODO
* @Author JIAL
* @Date 2024/1/12 9:05
* @Version 1.0
*/
@Service
public class QccInfoServiceImpl extends MPJBaseServiceImpl<QccInfoMapper, QccInfo> implements QccInfoService {
}

View File

@ -0,0 +1,53 @@
package com.JIAL.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONException;
import org.json.JSONObject;
import static java.lang.System.out;
/**
* @ClassName JSONHelper
* @Description JSON字符串工具类
* @Author JIAL
* @Date 2024/1/12 8:07
* @Version 1.0
*/
@Slf4j
public class JSONHelper {
/**
* @title FormartJson
* @description 获取JSON中对应key的Value值
* @author JIAL
* @param: jsonString
* @param: key
* @updateTime 2024/1/12 8:08
* @return: java.lang.String
*/
public static String formartJson(String jsonString, String key) throws JSONException {
JSONObject jObject = new JSONObject(jsonString);
return (String) jObject.get(key);
}
/**
* @title PrettyPrintJson
* @description 控制台和日志打印格式化的JSON字符串
* @author JIAL
* @param: jsonString
* @updateTime 2024/1/12 8:08
*/
public static void prettyPrintJson(String jsonString) throws JSONException {
try {
ObjectMapper mapper = new ObjectMapper();
Object obj = mapper.readValue(jsonString, Object.class);
String indented = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(obj);
out.println(indented);
log.info("Qcc result tokenJson: {}", indented);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}