ConnectToFinanceTest.java 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.uas.erp.test;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.uas.api.crypto.util.FlexJsonUtils;
  4. import com.uas.erp.schedular.UasSchedulingApplication;
  5. import com.uas.erp.schedular.entity.Master;
  6. import com.uas.erp.schedular.finance.domain.*;
  7. import com.uas.erp.schedular.finance.task.AbstractTask;
  8. import com.uas.erp.schedular.util.ContextHolder;
  9. import org.junit.Test;
  10. import org.junit.runner.RunWith;
  11. import org.springframework.boot.test.context.SpringBootTest;
  12. import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
  13. import org.springframework.ui.ModelMap;
  14. import org.springframework.util.CollectionUtils;
  15. import org.springframework.util.StringUtils;
  16. import java.util.List;
  17. /**
  18. * 从金融平台获取数据再连接ERP的测试
  19. * <p>
  20. * Created by hejq on 2017-12-22.
  21. */
  22. @RunWith(SpringJUnit4ClassRunner.class)
  23. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE, classes = UasSchedulingApplication.class)
  24. public class ConnectToFinanceTest extends AbstractTask {
  25. @Test
  26. public void testConnect() {
  27. Master master = new Master();
  28. master.setMa_user("YITOA_BL");
  29. master.setMa_uu(10046945L);
  30. master.setMa_accesssecret("600d3f07955ba67fe050007f01002db2");
  31. master.setMa_env("test");
  32. master.setMa_name("YITOA_BL");
  33. ContextHolder.setMaster(master);
  34. String jsonStr = getForObject("/erp/finance", String.class);
  35. JSONObject jsonObject = JSONObject.parseObject(jsonStr);
  36. String size = jsonObject.getString("size");
  37. String apply = jsonObject.getString("apply");
  38. List<Apply> applies = FlexJsonUtils.fromJsonArray(apply, Apply.class);
  39. System.out.println("applies"+applies);
  40. if (!CollectionUtils.isEmpty(applies)) {
  41. for (Apply apply1 : applies) {
  42. String url = "/openapi/applicant/financingApply.action";
  43. List<AssociateCompanyInfo> companyInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getAssociateCompanies() : null;
  44. List<CustomerExcutiveInfo> customerExcutiveInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getCustomerExcutives() : null;
  45. BusinessConditionInfo conditionInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getBusinessCondition() : null;
  46. FinanceConditionInfo conditionInfo = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getFinanceConditions() : null;
  47. List<ProductMixInfo> productMixInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getProductMixes() : null;
  48. List<PurcCustInfo> purcCustInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getMfCustInfos() : null;
  49. List<UpdowncastInfo> updowncastInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getUpdowncasts() : null;
  50. List<ShareholdersInfo> shareholdersInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getShareholders() : null;
  51. List<ChangesInstructionInfo> changesInstructionInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getChangesInstructions() : null;
  52. List<AccountInfo> accountInfos = apply1.getCustomerInfo() != null ? apply1.getCustomerInfo().getAccountInfoList() : null;
  53. postForEntity(url, new ModelMap("customer", FlexJsonUtils.toJsonDeep(new CustomerInfo(apply1.getCustomerInfo())))
  54. .addAttribute("apply", FlexJsonUtils.toJsonDeep(new ApplyInfo(apply1)))
  55. .addAttribute("associateCompany", FlexJsonUtils.toJsonDeep(companyInfos))
  56. .addAttribute("businessCondition", FlexJsonUtils.toJsonDeep(conditionInfos))
  57. .addAttribute("customerExcutive", FlexJsonUtils.toJsonDeep(customerExcutiveInfos))
  58. .addAttribute("financeCondition", FlexJsonUtils.toJsonDeep(conditionInfo))
  59. .addAttribute("mfCust", FlexJsonUtils.toJsonDeep(purcCustInfos))
  60. .addAttribute("attaches", FlexJsonUtils.toJsonDeep(apply1.getAttachList()))
  61. .addAttribute("prouductMixe", FlexJsonUtils.toJsonDeep(productMixInfos))
  62. .addAttribute("updowncast", FlexJsonUtils.toJsonDeep(updowncastInfos))
  63. .addAttribute("shareholders", FlexJsonUtils.toJsonDeep(shareholdersInfos))
  64. .addAttribute("changeInstruction", FlexJsonUtils.toJsonDeep(changesInstructionInfos))
  65. .addAttribute("accountList", FlexJsonUtils.toJsonDeep(accountInfos))
  66. );
  67. }
  68. }
  69. String idStr = jsonObject.getString("idStr");
  70. if (!StringUtils.isEmpty(idStr)) {
  71. post("/erp/finance/back", dataWrap(idStr));
  72. }
  73. }
  74. }