Commit acf6df7d authored by 吴琼's avatar 吴琼

动态读取appllop配置

parent 902e9b8b
package cn.quantgroup.customer; package cn.quantgroup.customer;
import com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig;
import com.github.tobato.fastdfs.FdfsClientConfig; import com.github.tobato.fastdfs.FdfsClientConfig;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
...@@ -15,6 +16,7 @@ import org.springframework.jmx.support.RegistrationPolicy; ...@@ -15,6 +16,7 @@ import org.springframework.jmx.support.RegistrationPolicy;
@Configuration @Configuration
@ServletComponentScan @ServletComponentScan
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableApolloConfig
@SpringBootApplication(scanBasePackages = {"cn.quantgroup.customer"}) @SpringBootApplication(scanBasePackages = {"cn.quantgroup.customer"})
public class Bootstrap { public class Bootstrap {
......
package cn.quantgroup.customer.config.container;
import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.context.scope.refresh.RefreshScope;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
* 在此填写类的用途,注意事项
*
* @author xiaoshuai.ma
* @date 2022-02-18 2:29 下午
*/
@Component
@Slf4j
public class ApolloConfigListener implements ApplicationContextAware {
private ApplicationContext applicationContext;
@Autowired
RefreshScope refreshScope;
@ApolloConfigChangeListener(value = {"application"})
public void configChange(ConfigChangeEvent event) {
Set<String> changedKeys = event.changedKeys();
for (String changedKey : changedKeys) {
log.info("changed key = {}",changedKey);
log.info("oldValue={},newValue= {}",event.getChange(changedKey).getOldValue(),event.getChange(changedKey).getNewValue());
this.applicationContext.publishEvent(new EnvironmentChangeEvent(event.changedKeys()));
refreshScope.refreshAll();
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
...@@ -27,22 +27,22 @@ public class TransactionReceiptRecord { ...@@ -27,22 +27,22 @@ public class TransactionReceiptRecord {
private String serialNo; private String serialNo;
@Column(name = "import_status") @Column(name = "import_status")
private Integer importStatus; private Integer importStatus = 0;
@Column(name = "export_status") @Column(name = "export_status")
private Integer exportStatus; private Integer exportStatus = 0;
@Column(name = "order_no") @Column(name = "order_no")
private String orderNo; private String orderNo;
@Column(name = "batch_no") @Column(name = "batch_no")
private Integer batchNo; private Integer batchNo =0;
@Column(name = "sign_status") @Column(name = "sign_status")
private Integer signStatus; private Integer signStatus = 0;
@Column(name = "export_batch_no") @Column(name = "export_batch_no")
private Integer exportBatchNo; private Integer exportBatchNo = 0;
public TransactionReceiptRecord() { public TransactionReceiptRecord() {
......
...@@ -38,7 +38,7 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR ...@@ -38,7 +38,7 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR
@Modifying @Modifying
@Transactional @Transactional
@Query(value = "update transaction_receipt_record set sign_status = ?1 where order_no =?2 ", nativeQuery = true) @Query(value = "update transaction_receipt_record set sign_status = ?1,export_status = ?2 where order_no =?3 and import_status = 1 and export_status = 0 ", nativeQuery = true)
int updatePDFStatusByOrderNo(Integer status,String orderNo); int updatePDFStatusByOrderNo(Integer status,Integer exportStatus,String orderNo);
} }
...@@ -72,65 +72,6 @@ public class TransactionReceiptRecordRest { ...@@ -72,65 +72,6 @@ public class TransactionReceiptRecordRest {
return transactionReceiptRecordService.checkCanExport(); return transactionReceiptRecordService.checkCanExport();
} }
@RequestMapping("/test")
public JsonResult test() {
String userIds="70356056,70356055";
String url ="http://passportapi-qa2.liangkebang.net/api/sync/listByUserIds";
Map param = Maps.newHashMap();
param.put("userIds",userIds);
String userResult = httpService.get(url,param);
JSONObject jsonObject = JSONObject.parseObject(userResult);
String dataStr = jsonObject.getString("data");
JSONArray userArray = JSONArray.parseArray(dataStr);
for(int i=0;i<userArray.size();i++){
JSONObject object= (JSONObject) userArray.get(i);
}
return JsonResult.buildSuccessResult("success", userArray);
}
@RequestMapping("/testKdsp")
public JsonResult testKdsp() {
String url = "http://kdsp-operation-qa2.liangkebang.net/api/kdsp/op/fa-cui/transaction-proof/query";
try {
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/json");
header.put("qg-tenant-id", "560761");
Map param = Maps.newHashMap();
List<Map> paramList =new ArrayList<>();
//param.put("userId", 70356062);
//param.put("orderNo", "1495958974917529600");
param.put("userId", 70356067);
param.put("orderNo", "1496312159003762688");
paramList.add(param);
//得到json字符串
String result = httpService.post(url, header, paramList);
//转换成json 对象
JSONObject json =JSONObject.parseObject(result);
String jsonResult = json.getString("data");
String businessCode = json.getString("businessCode");
if(!"0000".equals(businessCode)){
return JsonResult.buildErrorStateResult("订单信息查询报错");
}
if(jsonResult != null){
JSONObject jsonObject = JSONObject.parseObject(jsonResult);
JSONArray jsonArray = jsonObject.getJSONArray("dataList");
if(jsonArray.isEmpty()){
return JsonResult.buildErrorStateResult("未查询到对应的订单信息");
}
List<TransactionReceiptVO> transactionReceiptVOList = jsonArray.toJavaList(TransactionReceiptVO.class);
//生成pdf
String basicPath="D:\\交易凭证0222";
String filePath =basicPath +"\\"+"wuq";
FileToZip.mkdir(filePath);
filePath = filePath +"\\"+"1493905629528739840"+".pdf";
transactionReceiptRecordService.generatePDF(transactionReceiptVOList.get(0),filePath);
}
return JsonResult.buildSuccessResult("success",null);
} catch (Exception e) {
log.error("[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}", e.getMessage());
return JsonResult.buildErrorStateResult(e.getMessage());
}
}
/** /**
* 后台更新交易凭证状态 * 后台更新交易凭证状态
* @return * @return
......
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