ErpQueryController.java 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package com.uas.credit.controller;
  2. import com.uas.credit.model.*;
  3. import com.uas.credit.service.*;
  4. import com.uas.credit.util.FlexJsonUtils;
  5. import org.apache.commons.text.StringEscapeUtils;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.web.bind.annotation.RequestMapping;
  8. import org.springframework.web.bind.annotation.RequestMethod;
  9. import org.springframework.web.bind.annotation.RestController;
  10. import java.util.Date;
  11. /**
  12. * UAS查询入口
  13. * created by shicr on 2018/6/6
  14. **/
  15. @RestController
  16. @RequestMapping(value = "/erpquery")
  17. public class ErpQueryController {
  18. @Autowired
  19. private EnCreditInfoService creditInfoService;
  20. @Autowired
  21. private EnexceptionService enexceptionService;
  22. @Autowired
  23. private EnRiskInfoService enRiskInfoService;
  24. @Autowired
  25. private EnterpriseDeptService enterpriseDeptService;
  26. @Autowired
  27. private PersonalService personalService;
  28. @Autowired
  29. private PersonCorporationService personCorporationService;
  30. @Autowired
  31. private PersonJsonService personJsonService;
  32. @Autowired
  33. private EnterpriseJsonService enterpriseJsonService;
  34. @Autowired
  35. private CreditLogService creditLogService;
  36. /**
  37. * ERP对企业进行查询
  38. */
  39. @RequestMapping(value = "/queryEn", method = RequestMethod.POST)
  40. public EnterpriseJson queryEn(String data) {
  41. EnterpriseQuery erpQuery = FlexJsonUtils.fromJson(data, EnterpriseQuery.class);
  42. creditLogService.save(new CreditLog("enterprise", new Date()));
  43. if ("".equals(erpQuery.getEnname()) || erpQuery.getEnname() == null) {
  44. throw new RuntimeException("企业名称为空");
  45. }
  46. EnterpriseJson enterpriseJson = enterpriseJsonService.findByEnName(erpQuery.getEnname());
  47. if (enterpriseJson != null && enterpriseJson.getEndept() != null) {
  48. return enterpriseJson;
  49. }
  50. if (erpQuery != null) {
  51. // 查询企业债务信息
  52. String endeptinfoRoot = enterpriseDeptService.queryEnterpriseDept(erpQuery);
  53. // 查询企业经营异常信息
  54. String abnormalRoot = enexceptionService.queryEnexception(erpQuery);
  55. // 查询企业信用信息
  56. String encreditinfoRoot = creditInfoService.queryEnCreditInfo(erpQuery);
  57. // 查询企业风险信息
  58. String enRiskInfoRoot = enRiskInfoService.queryEnRiskInfo(erpQuery);
  59. enterpriseJson = new EnterpriseJson(endeptinfoRoot, abnormalRoot, encreditinfoRoot, enRiskInfoRoot);
  60. enterpriseJson.setEnName(erpQuery.getEnname());
  61. enterpriseJsonService.save(enterpriseJson);
  62. }
  63. return enterpriseJson;
  64. }
  65. /**
  66. * erp对个人进行查询
  67. */
  68. @RequestMapping(value = "/queryPe", method = RequestMethod.POST)
  69. public PersonJson queryPerson(String data) {
  70. PersonQuery erpQuery = FlexJsonUtils.fromJson(data, PersonQuery.class);
  71. creditLogService.save(new CreditLog("person", new Date()));
  72. PersonJson personJson = personJsonService.findByCreateTime(new Date());
  73. if (personJson != null && personJson.getPnidentity() != null) {
  74. return personJson;
  75. }
  76. if (erpQuery != null) {
  77. // 查询个人身份信息
  78. String policeCheckRoot = personalService.queryPoliceCheck(erpQuery);
  79. // 查询个人股东信息
  80. String personCorporationRoot = personCorporationService.queryPersonCorporation(erpQuery);
  81. personJson = new PersonJson(policeCheckRoot, personCorporationRoot);
  82. personJsonService.save(personJson);
  83. }
  84. return personJson;
  85. }
  86. }