From 61a8006c1054308d8352ddbe7ab85b72a4c6677e Mon Sep 17 00:00:00 2001 From: anthonywj Date: Thu, 17 Aug 2023 15:58:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A9=E7=9C=BC=E6=9F=A5=E8=AF=A2=EF=BC=8C?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E4=B8=8E=E4=BC=81=E4=B8=9A=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=AF=A6=E6=83=85=E7=AD=89=E6=8E=A5=E5=8F=A3=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tyapi/TyDownloadController.java | 153 ++++++++++++++++++ .../controller/tyapi/TySearchController.java | 64 +++----- .../dao/tyapi/TyCompanyDetailMapper.java | 6 + .../admin/dao/tyapi/TySupplierMapper.java | 6 + .../admin/entity/tyapi/TySupplierEntity.java | 5 + .../admin/req/tyapi/TyBaseInfoRequest.java | 11 +- .../admin/req/tyapi/TyImportSupRequest.java | 38 +++++ .../service/tyapi/TyCompanyDetailService.java | 47 +++++- .../admin/service/tyapi/TyDlHttpClient.java | 6 +- .../service/tyapi/TySupplierService.java | 54 ++++++- .../glxp/udidl/admin/util/ResultVOUtils.java | 10 ++ .../mapper/tyapi/TyCompanyDetailMapper.xml | 149 ++++++++++------- .../mybatis/mapper/tyapi/TySupplierMapper.xml | 78 ++++++--- src/main/resources/schemas/schema_v2.1.sql | 5 +- 14 files changed, 496 insertions(+), 136 deletions(-) create mode 100644 src/main/java/com/glxp/udidl/admin/controller/tyapi/TyDownloadController.java create mode 100644 src/main/java/com/glxp/udidl/admin/req/tyapi/TyImportSupRequest.java diff --git a/src/main/java/com/glxp/udidl/admin/controller/tyapi/TyDownloadController.java b/src/main/java/com/glxp/udidl/admin/controller/tyapi/TyDownloadController.java new file mode 100644 index 0000000..97a9a59 --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/controller/tyapi/TyDownloadController.java @@ -0,0 +1,153 @@ +package com.glxp.udidl.admin.controller.tyapi; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.glxp.udidl.admin.entity.tyapi.TyCompanyDetailEntity; +import com.glxp.udidl.admin.entity.tyapi.TyCompanySearchEntity; +import com.glxp.udidl.admin.entity.tyapi.TySupplierEntity; +import com.glxp.udidl.admin.req.tyapi.TyBaseInfoRequest; +import com.glxp.udidl.admin.req.tyapi.TyImportSupRequest; +import com.glxp.udidl.admin.res.BaseResponse; +import com.glxp.udidl.admin.res.tyapi.TyBatchDlResponse; +import com.glxp.udidl.admin.res.tyapi.TyContactResponse; +import com.glxp.udidl.admin.service.tyapi.TyCompanyDetailService; +import com.glxp.udidl.admin.service.tyapi.TyCompanySearchService; +import com.glxp.udidl.admin.service.tyapi.TyContactInfoService; +import com.glxp.udidl.admin.service.tyapi.TySupplierService; +import com.glxp.udidl.admin.util.ResultVOUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +@Api(tags = "天眼查API下载接口") +@RestController +public class TyDownloadController { + + + @Resource + TyCompanySearchService tyCompanySearchService; + @Resource + TySupplierService tySupplierService; + @Resource + TyCompanyDetailService tyCompanyDetailService; + @Resource + TyContactInfoService tyContactInfoService; + + + @ApiOperation(value = "天眼查批量下载供应商列表接口") + @PostMapping("/udidl/ty/company/batch/dl/supplier") + public BaseResponse imports(@RequestBody TyImportSupRequest tyImportSupRequest) { + + List hospList = new ArrayList<>(); + if (StrUtil.isNotEmpty(tyImportSupRequest.getHospitals())) { + String[] hospAarray = tyImportSupRequest.getHospitals().split(","); + CollUtil.toList(hospAarray); + } else if (CollUtil.isNotEmpty(tyImportSupRequest.getHospNames())) { + hospList.addAll(tyImportSupRequest.getHospNames()); + } else if (CollUtil.isNotEmpty(tyImportSupRequest.getHospCertCodes())) { + hospList.addAll(tyImportSupRequest.getHospCertCodes()); + } + TyBatchDlResponse tyBatchDlResponse = new TyBatchDlResponse(); + List mTySupplierEntities = new ArrayList<>(); + for (int i = 0; i < hospList.size(); i++) { + List tySupplierEntities = null; + if (CollUtil.isNotEmpty(tyImportSupRequest.getHospCertCodes())) { + tySupplierService.downloadByCode(hospList.get(i), null); + tySupplierEntities = tySupplierService.list(new QueryWrapper().eq("creditCodeFk", hospList.get(i))); + } else { + tySupplierService.downloadByName(hospList.get(i), null); + tySupplierEntities = tySupplierService.list(new QueryWrapper().eq("hospName", hospList.get(i))); + } + if (CollUtil.isNotEmpty(tySupplierEntities)) { + mTySupplierEntities.addAll(tySupplierEntities); + } + } + tyBatchDlResponse.setTySupplierEntities(mTySupplierEntities); + return ResultVOUtils.success(tyBatchDlResponse); + } + + @ApiOperation(value = "天眼查批量下载供应商列表接口") + @PostMapping("/udidl/ty/company/batch/dl/rel/supplier") + public BaseResponse importRels(@RequestBody TyImportSupRequest tyImportSupRequest) { + if (StrUtil.isEmpty(tyImportSupRequest.getHospitals())) { + return ResultVOUtils.error(500, "医院名称列表不能为空"); + } + List hospList = new ArrayList<>(); + String[] hospAarray = tyImportSupRequest.getHospitals().split(","); + if (hospAarray != null) + hospList = CollUtil.toList(hospAarray); + TyBatchDlResponse tyBatchDlResponse = new TyBatchDlResponse(); + List mTyCompanyDetailEntities = new ArrayList<>(); + List mTyContactResponses = new ArrayList<>(); + List mTySupplierEntities = new ArrayList<>(); + for (int i = 0; i < hospList.size(); i++) { + tySupplierService.downloadByName(hospList.get(i), null); + List tySupplierEntities = tySupplierService.list(new QueryWrapper().eq("hospName", hospAarray[i])); + if (CollUtil.isNotEmpty(tySupplierEntities)) { + mTySupplierEntities.addAll(tySupplierEntities); + for (TySupplierEntity tySupplierEntity : tySupplierEntities) { + TyCompanyDetailEntity tyCompanyDetailEntity = tyCompanyDetailService.downloadByName(tySupplierEntity.getSupplier_name()); + if (tyCompanyDetailEntity != null) + mTyCompanyDetailEntities.add(tyCompanyDetailEntity); + List tyContactResponses = tyContactInfoService.download(tySupplierEntity.getSupplier_name()); + if (CollUtil.isNotEmpty(tyContactResponses)) { + mTyContactResponses.addAll(tyContactResponses); + } + } + } + } + tyBatchDlResponse.setTyContactResponses(mTyContactResponses); + tyBatchDlResponse.setTyCompanyDetailEntities(mTyCompanyDetailEntities); + tyBatchDlResponse.setTySupplierEntities(mTySupplierEntities); + return ResultVOUtils.success(tyBatchDlResponse); + } + + + @ApiOperation(value = "天眼查下载企业详细信息接口") + @GetMapping("/udidl/ty/company/dl/getBaseInfo") + public BaseResponse getCompanyInfo(TyBaseInfoRequest tyBaseInfoRequest) { + if (StrUtil.isEmpty(tyBaseInfoRequest.getName()) && StrUtil.isEmpty(tyBaseInfoRequest.getCreditCode())) { + return ResultVOUtils.error(500, "请输入企业名称或统一社会信用代码"); + } + String keyWord = ""; + TyCompanyDetailEntity tyCompanyDetailEntity; + if (StrUtil.isNotEmpty(tyBaseInfoRequest.getCreditCode())) { + tyCompanyDetailEntity = tyCompanyDetailService.downloadByCode(tyBaseInfoRequest.getCreditCode()); + } else + tyCompanyDetailEntity = tyCompanyDetailService.downloadByCode(tyBaseInfoRequest.getName()); + + return ResultVOUtils.success(tyCompanyDetailEntity); + } + + + @ApiOperation(value = "天眼查批量下载企业详细信息接口") + @GetMapping("/udidl/ty/company/batch/dl/getBaseInfo") + public BaseResponse batchGetCompanyInfo(TyBaseInfoRequest tyBaseInfoRequest) { + if (StrUtil.isEmpty(tyBaseInfoRequest.getName()) && StrUtil.isEmpty(tyBaseInfoRequest.getCreditCode())) { + return ResultVOUtils.error(500, "请输入企业名称或统一社会信用代码"); + } + List tyCompanyDetailEntities = new ArrayList<>(); + + if (CollUtil.isNotEmpty(tyBaseInfoRequest.getSupCodes())) { + for (String supCode : tyBaseInfoRequest.getSupCodes()) { + TyCompanyDetailEntity tyCompanyDetailEntity = tyCompanyDetailService.downloadByCode(supCode); + tyCompanyDetailEntities.add(tyCompanyDetailEntity); + } + } else { + for (String supName : tyBaseInfoRequest.getSupNames()) { + TyCompanyDetailEntity tyCompanyDetailEntity = tyCompanyDetailService.downloadByName(supName); + tyCompanyDetailEntities.add(tyCompanyDetailEntity); + } + } + return ResultVOUtils.success(tyCompanyDetailEntities); + } + +} diff --git a/src/main/java/com/glxp/udidl/admin/controller/tyapi/TySearchController.java b/src/main/java/com/glxp/udidl/admin/controller/tyapi/TySearchController.java index d18cc4c..0f6a4d4 100644 --- a/src/main/java/com/glxp/udidl/admin/controller/tyapi/TySearchController.java +++ b/src/main/java/com/glxp/udidl/admin/controller/tyapi/TySearchController.java @@ -3,12 +3,14 @@ package com.glxp.udidl.admin.controller.tyapi; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageInfo; import com.glxp.udidl.admin.annotation.AuthRuleAnnotation; import com.glxp.udidl.admin.dto.udplat.UdplatManufactureModel; import com.glxp.udidl.admin.entity.tyapi.TyCompanyDetailEntity; import com.glxp.udidl.admin.entity.tyapi.TyCompanySearchEntity; import com.glxp.udidl.admin.entity.tyapi.TySupplierEntity; import com.glxp.udidl.admin.req.tyapi.TyBaseInfoRequest; +import com.glxp.udidl.admin.req.tyapi.TyImportSupRequest; import com.glxp.udidl.admin.res.BaseResponse; import com.glxp.udidl.admin.res.tyapi.TyBatchDlResponse; import com.glxp.udidl.admin.res.tyapi.TyContactResponse; @@ -28,7 +30,7 @@ import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; -@Api(tags = "天眼查API接口") +@Api(tags = "天眼查API查询接口") @RestController public class TySearchController { @@ -38,13 +40,10 @@ public class TySearchController { TySupplierService tySupplierService; @Resource TyCompanyDetailService tyCompanyDetailService; - @Resource - TyContactInfoService tyContactInfoService; - @ApiOperation(value = "天眼查企业信息查询", response = TyCompanySearchEntity.class) + @ApiOperation(value = "天眼查企业信息查询(搜索查询)", response = TyCompanySearchEntity.class) @GetMapping("udidl/ty/company/findBycCeditCode") public BaseResponse findBycCeditCode(String creditCode) { - if (StrUtil.isEmpty(creditCode)) { return ResultVOUtils.error(500, "统一社会信用代码不能为空!"); } @@ -56,52 +55,29 @@ public class TySearchController { } } - @ApiOperation(value = "天眼查批量下载供应商列表接口") + @ApiOperation(value = "天眼查批量查询供应商列表接口") @PostMapping("/udidl/ty/company/batch/supplier") - public BaseResponse imports(@RequestBody String hospitals) { - if (StrUtil.isEmpty(hospitals)) { - return ResultVOUtils.error(500, "医院名称列表不能为空"); - } - String[] hospAarray = hospitals.split(","); - TyBatchDlResponse tyBatchDlResponse = new TyBatchDlResponse(); - List mTyCompanyDetailEntities = new ArrayList<>(); - List mTyContactResponses = new ArrayList<>(); - List mTySupplierEntities = new ArrayList<>(); - for (int i = 0; i < hospAarray.length; i++) { - tySupplierService.download(hospAarray[i]); - List tySupplierEntities = tySupplierService.list(new QueryWrapper().eq("hospName", hospAarray[i])); - if (CollUtil.isNotEmpty(tySupplierEntities)) { - mTySupplierEntities.addAll(tySupplierEntities); - for (TySupplierEntity tySupplierEntity : tySupplierEntities) { - TyCompanyDetailEntity tyCompanyDetailEntity = tyCompanyDetailService.download(tySupplierEntity.getSupplier_name()); - if (tyCompanyDetailEntity != null) - mTyCompanyDetailEntities.add(tyCompanyDetailEntity); - List tyContactResponses = tyContactInfoService.download(tySupplierEntity.getSupplier_name()); - if (CollUtil.isNotEmpty(tyContactResponses)) { - mTyContactResponses.addAll(tyContactResponses); - } - } - } - } - tyBatchDlResponse.setTyContactResponses(mTyContactResponses); - tyBatchDlResponse.setTyCompanyDetailEntities(mTyCompanyDetailEntities); - tyBatchDlResponse.setTySupplierEntities(mTySupplierEntities); - return ResultVOUtils.success(tyBatchDlResponse); + public BaseResponse supplierSearch(@RequestBody TyImportSupRequest tyImportSupRequest) { + List tySupplierEntities = tySupplierService.filterList(tyImportSupRequest); + PageInfo pageInfo = new PageInfo<>(tySupplierEntities); + return ResultVOUtils.page(pageInfo); } - @ApiOperation(value = "天眼查批量下载企业详细信息接口") + + @ApiOperation(value = "天眼查批量查询企业详细信息接口") @GetMapping("/udidl/ty/company/getBaseInfo") public BaseResponse getCompanyInfo(TyBaseInfoRequest tyBaseInfoRequest) { - if (StrUtil.isEmpty(tyBaseInfoRequest.getName()) && StrUtil.isEmpty(tyBaseInfoRequest.getCreditCode())) { + if (StrUtil.isEmpty(tyBaseInfoRequest.getName()) + && StrUtil.isEmpty(tyBaseInfoRequest.getCreditCode()) + && CollUtil.isNotEmpty(tyBaseInfoRequest.getSupCodes()) + && CollUtil.isNotEmpty(tyBaseInfoRequest.getSupNames()) + ) { return ResultVOUtils.error(500, "请输入企业名称或统一社会信用代码"); } - String keyWord = ""; - if (StrUtil.isNotEmpty(tyBaseInfoRequest.getCreditCode())) { - keyWord = tyBaseInfoRequest.getCreditCode(); - } else - keyWord = tyBaseInfoRequest.getName(); - TyCompanyDetailEntity tyCompanyDetailEntity = tyCompanyDetailService.download(keyWord); - return ResultVOUtils.success(tyCompanyDetailEntity); + List tyCompanyDetailEntities = tyCompanyDetailService.filterList(tyBaseInfoRequest); + PageInfo pageInfo = new PageInfo<>(tyCompanyDetailEntities); + return ResultVOUtils.page(pageInfo); + } diff --git a/src/main/java/com/glxp/udidl/admin/dao/tyapi/TyCompanyDetailMapper.java b/src/main/java/com/glxp/udidl/admin/dao/tyapi/TyCompanyDetailMapper.java index de61376..17c86a9 100644 --- a/src/main/java/com/glxp/udidl/admin/dao/tyapi/TyCompanyDetailMapper.java +++ b/src/main/java/com/glxp/udidl/admin/dao/tyapi/TyCompanyDetailMapper.java @@ -3,8 +3,14 @@ package com.glxp.udidl.admin.dao.tyapi; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udidl.admin.dao.BaseMapperPlus; import com.glxp.udidl.admin.entity.tyapi.TyCompanyDetailEntity; +import com.glxp.udidl.admin.req.tyapi.TyBaseInfoRequest; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface TyCompanyDetailMapper extends BaseMapperPlus { + + + List filterList(TyBaseInfoRequest tyBaseInfoRequest); } diff --git a/src/main/java/com/glxp/udidl/admin/dao/tyapi/TySupplierMapper.java b/src/main/java/com/glxp/udidl/admin/dao/tyapi/TySupplierMapper.java index 1927a25..2f455c1 100644 --- a/src/main/java/com/glxp/udidl/admin/dao/tyapi/TySupplierMapper.java +++ b/src/main/java/com/glxp/udidl/admin/dao/tyapi/TySupplierMapper.java @@ -3,8 +3,14 @@ package com.glxp.udidl.admin.dao.tyapi; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.glxp.udidl.admin.dao.BaseMapperPlus; import com.glxp.udidl.admin.entity.tyapi.TySupplierEntity; +import com.glxp.udidl.admin.req.tyapi.TyImportSupRequest; import org.apache.ibatis.annotations.Mapper; +import java.util.List; + @Mapper public interface TySupplierMapper extends BaseMapperPlus { + + List filterList(TyImportSupRequest tyImportSupRequest); + } diff --git a/src/main/java/com/glxp/udidl/admin/entity/tyapi/TySupplierEntity.java b/src/main/java/com/glxp/udidl/admin/entity/tyapi/TySupplierEntity.java index 7734fdd..8b36b9f 100644 --- a/src/main/java/com/glxp/udidl/admin/entity/tyapi/TySupplierEntity.java +++ b/src/main/java/com/glxp/udidl/admin/entity/tyapi/TySupplierEntity.java @@ -37,6 +37,11 @@ public class TySupplierEntity implements Serializable { @ApiModelProperty(value = "报告期") private String announcement_date; + + @TableField(value = "year") + @ApiModelProperty(value = "年份") + private String year; + /** * 采购金额(万元) */ diff --git a/src/main/java/com/glxp/udidl/admin/req/tyapi/TyBaseInfoRequest.java b/src/main/java/com/glxp/udidl/admin/req/tyapi/TyBaseInfoRequest.java index 3901836..b1eeb59 100644 --- a/src/main/java/com/glxp/udidl/admin/req/tyapi/TyBaseInfoRequest.java +++ b/src/main/java/com/glxp/udidl/admin/req/tyapi/TyBaseInfoRequest.java @@ -1,12 +1,21 @@ package com.glxp.udidl.admin.req.tyapi; +import com.glxp.udidl.admin.req.ListPageRequest; import lombok.Data; +import java.util.List; + @Data -public class TyBaseInfoRequest { +public class TyBaseInfoRequest extends ListPageRequest { //企业名称 private String name; //统一社会信用代码 private String creditCode; + + + private List supNames; + private List supCodes; + + } diff --git a/src/main/java/com/glxp/udidl/admin/req/tyapi/TyImportSupRequest.java b/src/main/java/com/glxp/udidl/admin/req/tyapi/TyImportSupRequest.java new file mode 100644 index 0000000..69d5fcb --- /dev/null +++ b/src/main/java/com/glxp/udidl/admin/req/tyapi/TyImportSupRequest.java @@ -0,0 +1,38 @@ +package com.glxp.udidl.admin.req.tyapi; + +import com.glxp.udidl.admin.req.ListPageRequest; +import lombok.Data; + +import java.util.List; + +@Data +public class TyImportSupRequest extends ListPageRequest { + /** + * 批量下载医院列表,医院名称逗号隔开 + */ + private String hospitals; + + private String hospName; + + private String creditCodeFk; + + /** + * 批量下载医院名称列表 + */ + private List hospNames; + + /** + * 批量下载医院统一社会信用列表 + */ + private List hospCertCodes; + + /** + * 查询年份 + */ + private String year; + + /** + * 查询年份列表 + */ + private List years; +} diff --git a/src/main/java/com/glxp/udidl/admin/service/tyapi/TyCompanyDetailService.java b/src/main/java/com/glxp/udidl/admin/service/tyapi/TyCompanyDetailService.java index 033eee0..11e368d 100644 --- a/src/main/java/com/glxp/udidl/admin/service/tyapi/TyCompanyDetailService.java +++ b/src/main/java/com/glxp/udidl/admin/service/tyapi/TyCompanyDetailService.java @@ -4,8 +4,12 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; import com.glxp.udidl.admin.entity.tyapi.TyContactCallEntity; import com.glxp.udidl.admin.entity.tyapi.TyContactInfoEntity; +import com.glxp.udidl.admin.entity.tyapi.TySupplierEntity; +import com.glxp.udidl.admin.req.tyapi.TyBaseInfoRequest; +import com.glxp.udidl.admin.req.tyapi.TyImportSupRequest; import com.glxp.udidl.admin.res.tyapi.CompanyBaseResponse; import com.glxp.udidl.admin.res.tyapi.ContactResponse; import com.glxp.udidl.admin.util.BeanCopyUtils; @@ -16,6 +20,7 @@ import com.glxp.udidl.admin.dao.tyapi.TyCompanyDetailMapper; import com.glxp.udidl.admin.entity.tyapi.TyCompanyDetailEntity; import javax.annotation.Resource; +import java.util.Collections; import java.util.List; @Service @@ -27,7 +32,7 @@ public class TyCompanyDetailService extends ServiceImpl().eq("name", company))) { log.error(company + "企业详细信息已存在!"); } else { @@ -54,4 +59,44 @@ public class TyCompanyDetailService extends ServiceImpl().eq("creditCode", creditCode))) { + log.error(creditCode + "企业详细信息已存在!"); + } else { + CompanyBaseResponse companyBaseResponse = tyDlHttpClient.getBaseInfo(creditCode); + if (companyBaseResponse.getErrorCode() == 0) { + CompanyBaseResponse.ResultDTO resultDTO = companyBaseResponse.getResult(); + TyCompanyDetailEntity tyCompanyDetailEntity = new TyCompanyDetailEntity(); + BeanUtil.copyProperties(resultDTO, tyCompanyDetailEntity); + if (CollUtil.isNotEmpty(resultDTO.getHistoryNameList())) { + tyCompanyDetailEntity.setHistoryNameList(StringUtils.join(resultDTO.getHistoryNameList(), ",")); + } + CompanyBaseResponse.ResultDTO.IndustryAllDTO industryAllDTO = resultDTO.getIndustryAll(); + if (industryAllDTO != null) { + tyCompanyDetailEntity.setIndustryAll(JSON.toJSONString(industryAllDTO)); + } + tyCompanyDetailMapper.insert(tyCompanyDetailEntity); + } else { + log.error(creditCode + "下载企业信息失败!"); + } + } + List tyCompanyDetailEntities = tyCompanyDetailMapper.selectList(new QueryWrapper().eq("creditCode", creditCode)); + if (CollUtil.isNotEmpty(tyCompanyDetailEntities)) + return tyCompanyDetailEntities.get(0); + else + return null; + } + + + public List filterList(TyBaseInfoRequest tyBaseInfoRequest) { + if (null == tyBaseInfoRequest) { + return Collections.emptyList(); + } + if (null != tyBaseInfoRequest.getPage() && null != tyBaseInfoRequest.getLimit()) { + PageHelper.offsetPage((tyBaseInfoRequest.getPage() - 1) * tyBaseInfoRequest.getLimit(), tyBaseInfoRequest.getLimit()); + } + return tyCompanyDetailMapper.filterList(tyBaseInfoRequest); + } + } diff --git a/src/main/java/com/glxp/udidl/admin/service/tyapi/TyDlHttpClient.java b/src/main/java/com/glxp/udidl/admin/service/tyapi/TyDlHttpClient.java index f87d5de..3c3676f 100644 --- a/src/main/java/com/glxp/udidl/admin/service/tyapi/TyDlHttpClient.java +++ b/src/main/java/com/glxp/udidl/admin/service/tyapi/TyDlHttpClient.java @@ -1,5 +1,6 @@ package com.glxp.udidl.admin.service.tyapi; +import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.glxp.udidl.admin.res.tyapi.CompanyBaseResponse; @@ -32,11 +33,14 @@ public class TyDlHttpClient { String[] headers = {"Authorization", suthorization}; //获取供应商列表 - public SupplierResponse getSupplier(String hospital, Integer pageNum, Integer pageSize) { + public SupplierResponse getSupplier(String hospital, String year, Integer pageNum, Integer pageSize) { Map params = new HashMap<>(); params.put("keyword", hospital); params.put("pageNum", pageNum + ""); params.put("pageSize", pageSize + ""); + if (StrUtil.isNotEmpty(year)) { + params.put("year", year); + } String response = okHttpCli.doGet(supplyUrl, params, headers); log.info(response); SupplierResponse baseResponse = JSONObject.parseObject(response, new TypeReference() { diff --git a/src/main/java/com/glxp/udidl/admin/service/tyapi/TySupplierService.java b/src/main/java/com/glxp/udidl/admin/service/tyapi/TySupplierService.java index 79efb8c..ec0f970 100644 --- a/src/main/java/com/glxp/udidl/admin/service/tyapi/TySupplierService.java +++ b/src/main/java/com/glxp/udidl/admin/service/tyapi/TySupplierService.java @@ -3,14 +3,19 @@ package com.glxp.udidl.admin.service.tyapi; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.github.pagehelper.PageHelper; import com.glxp.udidl.admin.entity.tyapi.TyContactInfoEntity; +import com.glxp.udidl.admin.req.tyapi.TyImportSupRequest; import com.glxp.udidl.admin.res.tyapi.SupplierResponse; +import com.glxp.udidl.admin.util.DateUtil; +import com.glxp.udidl.admin.util.IntUtil; import org.springframework.stereotype.Service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.glxp.udidl.admin.entity.tyapi.TySupplierEntity; import com.glxp.udidl.admin.dao.tyapi.TySupplierMapper; import javax.annotation.Resource; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -21,21 +26,22 @@ public class TySupplierService extends ServiceImpl download(String hospital) { + public List downloadByName(String hospital, String year) { Integer pageNum = 1; Integer pageSize = 20; if (tySupplierMapper.exists(new QueryWrapper().eq("hospName", hospital))) { log.error(hospital + "供应商列表已存在重复下载!"); } else { while (true) { - SupplierResponse supplierResponse = tyDlHttpClient.getSupplier(hospital, pageNum, pageSize); + SupplierResponse supplierResponse = tyDlHttpClient.getSupplier(hospital, year, pageNum, pageSize); if (supplierResponse.getErrorCode() == 0) { List supplierDTOS = supplierResponse.getResult().getPageBean().getResult(); List tySupplierEntities = BeanUtil.copyToList(supplierDTOS, TySupplierEntity.class); if (CollUtil.isNotEmpty(supplierDTOS)) { for (TySupplierEntity tySupplierEntity : tySupplierEntities) { - tySupplierEntity.setHospName(hospital); + tySupplierEntity.setHospName(tySupplierEntity.getSupplier_name()); tySupplierEntity.setUpdateTime(new Date()); + tySupplierEntity.setYear(DateUtil.formatDate(IntUtil.value(tySupplierEntity.getAnnouncement_date()), "yyyy")); } } tySupplierMapper.insertBatch(tySupplierEntities); @@ -51,5 +57,47 @@ public class TySupplierService extends ServiceImpl downloadByCode(String code, String year) { + Integer pageNum = 1; + Integer pageSize = 20; + if (tySupplierMapper.exists(new QueryWrapper().eq("creditCodeFk", code))) { + log.error(code + "供应商列表已存在重复下载!"); + } else { + while (true) { + SupplierResponse supplierResponse = tyDlHttpClient.getSupplier(code, year, pageNum, pageSize); + if (supplierResponse.getErrorCode() == 0) { + List supplierDTOS = supplierResponse.getResult().getPageBean().getResult(); + List tySupplierEntities = BeanUtil.copyToList(supplierDTOS, TySupplierEntity.class); + if (CollUtil.isNotEmpty(supplierDTOS)) { + for (TySupplierEntity tySupplierEntity : tySupplierEntities) { + tySupplierEntity.setHospName(tySupplierEntity.getSupplier_name()); + tySupplierEntity.setCreditCodeFk(code); + tySupplierEntity.setUpdateTime(new Date()); + tySupplierEntity.setYear(DateUtil.formatDate(IntUtil.value(tySupplierEntity.getAnnouncement_date()), "yyyy")); + } + } + tySupplierMapper.insertBatch(tySupplierEntities); + if (CollUtil.isNotEmpty(supplierDTOS) && supplierDTOS.size() == 20) { + pageNum = pageNum + 1; + } else { + break; + } + } + } + } + List tySupplierEntities = tySupplierMapper.selectList(new QueryWrapper().eq("creditCodeFk", code)); + return tySupplierEntities; + } + + + public List filterList(TyImportSupRequest tyImportSupRequest) { + if (null == tyImportSupRequest) { + return Collections.emptyList(); + } + if (null != tyImportSupRequest.getPage() && null != tyImportSupRequest.getLimit()) { + PageHelper.offsetPage((tyImportSupRequest.getPage() - 1) * tyImportSupRequest.getLimit(), tyImportSupRequest.getLimit()); + } + return tySupplierMapper.filterList(tyImportSupRequest); + } } diff --git a/src/main/java/com/glxp/udidl/admin/util/ResultVOUtils.java b/src/main/java/com/glxp/udidl/admin/util/ResultVOUtils.java index f53e1fe..f94ed56 100644 --- a/src/main/java/com/glxp/udidl/admin/util/ResultVOUtils.java +++ b/src/main/java/com/glxp/udidl/admin/util/ResultVOUtils.java @@ -1,8 +1,10 @@ package com.glxp.udidl.admin.util; +import com.github.pagehelper.PageInfo; import com.glxp.udidl.admin.enums.ResultEnum; import com.glxp.udidl.admin.res.BaseResponse; +import com.glxp.udidl.admin.res.PageSimpleResponse; import java.util.HashMap; import java.util.Map; @@ -73,4 +75,12 @@ public class ResultVOUtils { return error(resultEnum.getCode(), message); } + + public static BaseResponse page(PageInfo pageInfo) { + PageSimpleResponse pageSimpleResponse = new PageSimpleResponse(); + pageSimpleResponse.setList(pageInfo.getList()); + pageSimpleResponse.setTotal(pageInfo.getTotal()); + return success(pageSimpleResponse); + } + } diff --git a/src/main/resources/mybatis/mapper/tyapi/TyCompanyDetailMapper.xml b/src/main/resources/mybatis/mapper/tyapi/TyCompanyDetailMapper.xml index ff11a1e..21842a6 100644 --- a/src/main/resources/mybatis/mapper/tyapi/TyCompanyDetailMapper.xml +++ b/src/main/resources/mybatis/mapper/tyapi/TyCompanyDetailMapper.xml @@ -1,65 +1,92 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id, historyNames, cancelDate, regStatus, regCapital, city, staffNumRange, bondNum, - historyNameList, industry, bondName, revokeDate, `type`, updateTimes, legalPersonName, - revokeReason, regNumber, creditCode, property3, usedBondName, approvedTime, fromTime, - socialStaffNum, actualCapitalCurrency, `alias`, companyOrgType, cancelReason, orgNumber, - email, toTime, actualCapital, estiblishTime, regInstitute, businessScope, taxNumber, - regLocation, regCapitalCurrency, tags, websiteList, phoneNumber, district, bondType, - `name`, percentileScore, industryAll, isMicroEnt, base - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id, historyNames, cancelDate, regStatus, regCapital, city, staffNumRange, bondNum, + historyNameList, industry, bondName, revokeDate, `type`, updateTimes, legalPersonName, + revokeReason, regNumber, creditCode, property3, usedBondName, approvedTime, fromTime, + socialStaffNum, actualCapitalCurrency, `alias`, companyOrgType, cancelReason, orgNumber, + email, toTime, actualCapital, estiblishTime, regInstitute, businessScope, taxNumber, + regLocation, regCapitalCurrency, tags, websiteList, phoneNumber, district, bondType, + `name`, percentileScore, industryAll, isMicroEnt, base + + + + diff --git a/src/main/resources/mybatis/mapper/tyapi/TySupplierMapper.xml b/src/main/resources/mybatis/mapper/tyapi/TySupplierMapper.xml index 165e243..5a1fbe9 100644 --- a/src/main/resources/mybatis/mapper/tyapi/TySupplierMapper.xml +++ b/src/main/resources/mybatis/mapper/tyapi/TySupplierMapper.xml @@ -1,25 +1,61 @@ - - - - - - - - - - - - - - - - - - - id, supplier_graphId, announcement_date, amt, logo, `alias`, supplier_name, relationship, - dataSource, ratio, creditCodeFk, hospName - + + + + + + + + + + + + + + + + + + + id, supplier_graphId, announcement_date, amt, logo, `alias`, supplier_name, relationship, + dataSource, ratio, creditCodeFk, hospName + + + + diff --git a/src/main/resources/schemas/schema_v2.1.sql b/src/main/resources/schemas/schema_v2.1.sql index d852ee6..10eaa4b 100644 --- a/src/main/resources/schemas/schema_v2.1.sql +++ b/src/main/resources/schemas/schema_v2.1.sql @@ -1,9 +1,6 @@ # 字段新增 (表名,字段名,字段类型,修改方式(1:新增,2:修改,3:删除) -CALL Pro_Temp_ColumnWork('ty_supplier', 'updateTime', 'date', 1); -CALL Pro_Temp_ColumnWork('ty_supplier', 'updateTime', 'date', 1); -CALL Pro_Temp_ColumnWork('ty_supplier', 'updateTime', 'date', 1); -CALL Pro_Temp_ColumnWork('ty_supplier', 'updateTime', 'date', 1); +CALL Pro_Temp_ColumnWork('ty_supplier', 'year', 'varchar(60)', 1);