package com.uas.credit.controller; import com.uas.credit.model.*; import com.uas.credit.service.*; import com.uas.credit.util.FlexJsonUtils; import org.apache.commons.text.StringEscapeUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import java.util.Date; /** * UAS查询入口 * created by shicr on 2018/6/6 **/ @RestController @RequestMapping(value = "/erpquery") public class ErpQueryController { @Autowired private EnCreditInfoService creditInfoService; @Autowired private EnexceptionService enexceptionService; @Autowired private EnRiskInfoService enRiskInfoService; @Autowired private EnterpriseDeptService enterpriseDeptService; @Autowired private PersonalService personalService; @Autowired private PersonCorporationService personCorporationService; @Autowired private PersonJsonService personJsonService; @Autowired private EnterpriseJsonService enterpriseJsonService; @Autowired private CreditLogService creditLogService; /** * ERP对企业进行查询 */ @RequestMapping(value = "/queryEn", method = RequestMethod.POST) public EnterpriseJson queryEn(String data) { EnterpriseQuery erpQuery = FlexJsonUtils.fromJson(data, EnterpriseQuery.class); creditLogService.save(new CreditLog("enterprise", new Date())); if ("".equals(erpQuery.getEnname()) || erpQuery.getEnname() == null) { throw new RuntimeException("企业名称为空"); } EnterpriseJson enterpriseJson = enterpriseJsonService.findByEnName(erpQuery.getEnname()); if (enterpriseJson != null && enterpriseJson.getEndept() != null) { return enterpriseJson; } if (erpQuery != null) { // 查询企业债务信息 String endeptinfoRoot = enterpriseDeptService.queryEnterpriseDept(erpQuery); // 查询企业经营异常信息 String abnormalRoot = enexceptionService.queryEnexception(erpQuery); // 查询企业信用信息 String encreditinfoRoot = creditInfoService.queryEnCreditInfo(erpQuery); // 查询企业风险信息 String enRiskInfoRoot = enRiskInfoService.queryEnRiskInfo(erpQuery); enterpriseJson = new EnterpriseJson(endeptinfoRoot, abnormalRoot, encreditinfoRoot, enRiskInfoRoot); enterpriseJson.setEnName(erpQuery.getEnname()); enterpriseJsonService.save(enterpriseJson); } return enterpriseJson; } /** * erp对个人进行查询 */ @RequestMapping(value = "/queryPe", method = RequestMethod.POST) public PersonJson queryPerson(String data) { PersonQuery erpQuery = FlexJsonUtils.fromJson(data, PersonQuery.class); creditLogService.save(new CreditLog("person", new Date())); PersonJson personJson = personJsonService.findByCreateTime(new Date()); if (personJson != null && personJson.getPnidentity() != null) { return personJson; } if (erpQuery != null) { // 查询个人身份信息 String policeCheckRoot = personalService.queryPoliceCheck(erpQuery); // 查询个人股东信息 String personCorporationRoot = personCorporationService.queryPersonCorporation(erpQuery); personJson = new PersonJson(policeCheckRoot, personCorporationRoot); personJsonService.save(personJson); } return personJson; } }