|
|
@@ -1,4 +1,4 @@
|
|
|
-package com.ruoyi.info.base.service.impl;
|
|
|
+package com.ruoyi.base.platform.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
@@ -8,19 +8,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.core.domain.PageQuery;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.filepathsplicing.FilePathSplicingUtil;
|
|
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.info.base.domain.PlatformInfo;
|
|
|
-import com.ruoyi.info.base.domain.bo.PlatformInfoBo;
|
|
|
-import com.ruoyi.info.base.domain.vo.PlatformInfoVo;
|
|
|
-import com.ruoyi.info.base.exception.PlatformInfoExceptionEnum;
|
|
|
-import com.ruoyi.info.base.mapper.PlatformInfoMapper;
|
|
|
-import com.ruoyi.info.base.service.IPlatformInfoService;
|
|
|
+import com.ruoyi.base.platform.domain.PlatformInfo;
|
|
|
+import com.ruoyi.base.platform.domain.bo.PlatformInfoBo;
|
|
|
+import com.ruoyi.base.platform.domain.vo.PlatformInfoVo;
|
|
|
+import com.ruoyi.base.platform.exception.PlatformInfoExceptionEnum;
|
|
|
+import com.ruoyi.base.platform.mapper.PlatformInfoMapper;
|
|
|
+import com.ruoyi.base.platform.service.IPlatformInfoService;
|
|
|
import com.ruoyi.tool.service.JzqService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URL;
|
|
|
+import java.nio.channels.Channels;
|
|
|
+import java.nio.channels.ReadableByteChannel;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@@ -36,6 +45,8 @@ public class PlatformInfoServiceImpl implements IPlatformInfoService {
|
|
|
|
|
|
private final PlatformInfoMapper baseMapper;
|
|
|
private final JzqService jzqService;
|
|
|
+ @Resource
|
|
|
+ private FilePathSplicingUtil filePathSplicingUtil;
|
|
|
|
|
|
/**
|
|
|
* 查询平台信息管理分页
|
|
|
@@ -190,7 +201,56 @@ public class PlatformInfoServiceImpl implements IPlatformInfoService {
|
|
|
|
|
|
@Override
|
|
|
public void organizationCreate() {
|
|
|
-
|
|
|
+ PlatformInfoVo info = getInfo();
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("name", info.getEnterpriseFullName()); //企业名称
|
|
|
+ params.put("organizationType", "0"); //企业类型
|
|
|
+ params.put("identificationType", "1"); //证件类型
|
|
|
+ params.put("organizationRegNo", info.getUscCode()); //统一社会信用代码
|
|
|
+ params.put("organizationRegImg",downloadSafely(filePathSplicingUtil.getPrefix() + info.getBusinessLicenseImg()));//营业执照图片
|
|
|
+ params.put("legalName", info.getLegalPersonName());//法人姓名
|
|
|
+ params.put("legalIdentityCard", info.getIdCardNumber());//法人身份证号
|
|
|
+ String email = jzqService.organizationCreate(params);
|
|
|
+ if (StringUtils.isNotEmpty(email)) {
|
|
|
+ PlatformInfo update = new PlatformInfo();
|
|
|
+ update.setId(info.getId());
|
|
|
+ update.setEmail(email);
|
|
|
+ baseMapper.updateById(update);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 安全下载HTTP图片并转换为File对象
|
|
|
+ * @param imageUrl 图片HTTP地址
|
|
|
+ */
|
|
|
+ public static File downloadSafely(String imageUrl) {
|
|
|
+ try {
|
|
|
+ // 使用系统安全加载器获取临时目录
|
|
|
+ File tmpDir = new File(System.getProperty("java.io.tmpdir"));
|
|
|
+ // 创建安全临时文件
|
|
|
+ File tempFile = File.createTempFile("img_", ".tmp", tmpDir);
|
|
|
+ tempFile.deleteOnExit(); // 程序退出时自动删除
|
|
|
+ // 安全下载机制
|
|
|
+ try {
|
|
|
+ URL url = new URL(imageUrl);
|
|
|
+ ReadableByteChannel rbc = Channels.newChannel(url.openStream());
|
|
|
+ try (FileOutputStream fos = new FileOutputStream(tempFile)) {
|
|
|
+ fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ // 安全删除失败文件
|
|
|
+ if (tempFile.exists()) {
|
|
|
+ tempFile.delete();
|
|
|
+ }
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ // 验证文件有效性
|
|
|
+ if (tempFile.length() == 0) {
|
|
|
+ throw new IOException("下载文件为空: " + imageUrl);
|
|
|
+ }
|
|
|
+ return tempFile;
|
|
|
+ } catch (Exception e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|