Commit f280109d authored by 李洪明's avatar 李洪明

添加上传企业信息

parent 207e29a4
......@@ -16,11 +16,7 @@ import java.util.Base64;
public class HttpUtils {
private static final String USERACT = "";
private static final String USERPWD = "";
private static final String ACTKEY = "";
public static String uploadData(String method, String version, String cityId, String jsonStr) {
public static String uploadData(String method, String version, String cityId, String jsonStr, String account, String password, String key) {
String businessContent = base64Encode(jsonStr);
String str = "{" +
......@@ -33,14 +29,14 @@ public class HttpUtils {
String dataStr = JSONObject.toJSONString(data, SerializerFeature.WriteMapNullValue);
// 计算签名
// USERACT用户账号、USERPWD密码
String source = USERACT + dataStr + USERPWD;
String source = account + dataStr + password;
String iSign = md5(source); //获取md5并实现二进制小写字符串转换
//将签名添加进上传的JSON串中
data.put("ISIGN", iSign);
//数据上报,在Request Headers添加账户密钥
//ACTKEY账户密钥
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("AccountKey", ACTKEY);
httpHeaders.add("AccountKey", key);
httpHeaders.add("Accept-Charset","UTF-8");
httpHeaders.add("Content-Type", "application/json;charset=UTF-8");
HttpEntity<JSONObject> requestEntity = new HttpEntity<>(data,httpHeaders);
......
package com.bme.access.guangdong.dao;
import com.bme.access.guangdong.model.EnterpriseOriginalInfo;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface EnterpriseInfoMapper {
EnterpriseOriginalInfo getEnterpriseInfo();
}
package com.bme.access.guangdong.job;
import com.bme.access.guangdong.service.EnterpriseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
......@@ -9,4 +12,19 @@ import org.springframework.stereotype.Component;
@Slf4j
public class UploadDataTask {
@Autowired
private EnterpriseService enterpriseService;
/**
* 上传企业信息
*/
@Scheduled(cron = "0 0/1 * * * *")
public void uploadEnterpriseInfo() {
log.info("上传企业信息");
try {
enterpriseService.uploadEnterpriseInfo();
} catch (Exception e) {
log.error("上传企业信息异常", e);
}
}
}
package com.bme.access.guangdong.model;
import lombok.Data;
@Data
public class EnterpriseOriginalInfo {
private String regionalismCode; // 行政区划代码 字符(6)
private String enterpriseId; // 企业编号 字符(22)
private String enterpriseName; // 企业名称 字符(100)
private String unifiedSocialCreditCode; // 统一社会信用代码 字符(18)
private String enterpriseAddress; // 企业地址 字符(255)
private Number longitude; // 经度 数值
private Number latitude; // 纬度 数值
private String legalRepresentative; // 法人代表 字符(20)
private String industryType; // 行业类型 字符(50)
private String industryBranch; // 行业分支 字符(50)
private String performanceGradingControlType; //绩效分级管控类型 字符(50)
private String contacts; // 联系人 字符(20)
private String contactPhone; // 联系人电话 字符(20)
private Number unloadingEntrancesNumber; // 载货出入口数量 数值
private Number barriersNumber; // 道闸数量 数值
private Number transportVehiclesNumber; // 运输车辆数量 数值
private Number inFactoryVehicleNumber; // 厂内运输车辆数量 数值
private Number noRoadVehicleNumber; // 非道路移动机械数量 数值
}
package com.bme.access.guangdong.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.PascalNameFilter;
import com.bme.access.guangdong.common.HttpUtils;
import com.bme.access.guangdong.dao.EnterpriseInfoMapper;
import com.bme.access.guangdong.model.EnterpriseInfo;
import com.bme.access.guangdong.model.EnterpriseOriginalInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Objects;
@Service
@Slf4j
public class EnterpriseService {
@Autowired
private EnterpriseInfoMapper enterpriseInfoMapper;
@Value("${cityId}")
private String cityId;
@Value("${account}")
private String account;
@Value("${password}")
private String password;
@Value("${key}")
private String key;
public void uploadEnterpriseInfo() {
// 查询企业信息
EnterpriseInfo enterpriseInfo;
EnterpriseOriginalInfo originalInfo = enterpriseInfoMapper.getEnterpriseInfo();
if (Objects.nonNull(originalInfo)) {
enterpriseInfo = convertInfo(originalInfo);
String jsonStr = JSON.toJSONString(enterpriseInfo, new PascalNameFilter());
String result = HttpUtils.uploadData("qyjbxx", "1.0", cityId, jsonStr, account, password, key);
log.info("上传企业基本数据结果:{}", result);
}
}
private EnterpriseInfo convertInfo(EnterpriseOriginalInfo originalInfo) {
EnterpriseInfo enterpriseInfo = new EnterpriseInfo();
enterpriseInfo.setJD(originalInfo.getLongitude());
enterpriseInfo.setDZSL(originalInfo.getBarriersNumber());
enterpriseInfo.setHYFZ(originalInfo.getIndustryBranch());
enterpriseInfo.setFRDB(originalInfo.getLegalRepresentative());
enterpriseInfo.setHYLX(originalInfo.getIndustryType());
enterpriseInfo.setCNYSCLSL(originalInfo.getInFactoryVehicleNumber());
enterpriseInfo.setWD(originalInfo.getLatitude());
enterpriseInfo.setLXR(originalInfo.getContacts());
enterpriseInfo.setJXFJGK(originalInfo.getPerformanceGradingControlType());
enterpriseInfo.setLXRDH(originalInfo.getContactPhone());
enterpriseInfo.setQYBH(originalInfo.getEnterpriseId());
enterpriseInfo.setQYDZ(originalInfo.getEnterpriseAddress());
enterpriseInfo.setQYMC(originalInfo.getEnterpriseName());
enterpriseInfo.setZHCRKSL(originalInfo.getUnloadingEntrancesNumber());
enterpriseInfo.setFDLYDJXSL(originalInfo.getNoRoadVehicleNumber());
enterpriseInfo.setYSCLSL(originalInfo.getTransportVehiclesNumber());
enterpriseInfo.setTYSHXYDM(originalInfo.getUnifiedSocialCreditCode());
enterpriseInfo.setXZQHDM(originalInfo.getRegionalismCode());
return enterpriseInfo;
}
}
......@@ -7,4 +7,9 @@ spring:
driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
initialSize: 5
minIdle: 5
maxActive: 20
\ No newline at end of file
maxActive: 20
cityId: 440801
account: aaaa
password: ssss
key: ssss
\ No newline at end of file
<?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.bme.access.guangdong.dao.EnterpriseInfoMapper">
<select id="getEnterpriseInfo" resultType="com.bme.access.guangdong.model.EnterpriseOriginalInfo">
select top 1
regionalism_code as regionalismCode,
enterprise_id as enterpriseId,
enterprise_name as enterpriseName,
unified_social_credit_code as unifiedSocialCreditCode,
enterprise_address as enterpriseAddress,
longitude,
latitude,
legal_representative as legalRepresentative,
industry_type as industryType,
industry_branch as industryBranch,
performance_grading_control_type as performanceGradingControlType,
contacts,
contact_phone as contactPhone,
unloading_entrances_number as unloadingEntrancesNumber,
barriers_number as barriersNumber,
transport_vehicles_number as transportVehiclesNumber,
in_factory_vehicle_number as inFactoryVehicleNumber,
no_road_vehicle_number as noRoadVehicleNumber from enterprise_info
</select>
</mapper>
\ No newline at end of file
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