|
|
|
@ -3,6 +3,8 @@ package com.ruoyi.gysl.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
|
|
import cn.hutool.crypto.SmUtil;
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
@ -17,6 +19,9 @@ import com.ruoyi.gysl.entity.request.AuditRequest;
|
|
|
|
|
import com.ruoyi.gysl.entity.request.BasicInformationPageReq;
|
|
|
|
|
import com.ruoyi.gysl.entity.response.BasicInformationResponse;
|
|
|
|
|
import com.ruoyi.gysl.entity.response.ProjectExcelInfo;
|
|
|
|
|
import com.ruoyi.gysl.login.util.SM2Demo;
|
|
|
|
|
import com.ruoyi.gysl.login.util.SM4Demo;
|
|
|
|
|
import com.ruoyi.gysl.login.util.StringUtil;
|
|
|
|
|
import com.ruoyi.gysl.service.*;
|
|
|
|
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
@ -29,16 +34,15 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.BufferedOutputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.net.HttpURLConnection;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.nio.file.Path;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.nio.file.StandardOpenOption;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -99,6 +103,176 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
@Resource
|
|
|
|
|
private ProjectOtherInfoService projectOtherInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${isZs}")
|
|
|
|
|
private Boolean isZs;
|
|
|
|
|
private static final String BOUNDARY = "----WebKitFormBoundary7MA4YWxkTrZu0gW"; // 边界字符串(需唯一)
|
|
|
|
|
|
|
|
|
|
@Value("${sm2}")
|
|
|
|
|
private String sm2;
|
|
|
|
|
|
|
|
|
|
@Value("${sm4}")
|
|
|
|
|
private String sm4;
|
|
|
|
|
|
|
|
|
|
@Value("${accessId}")
|
|
|
|
|
private String accessId;
|
|
|
|
|
|
|
|
|
|
@Value("${sceneId}")
|
|
|
|
|
private String sceneId;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 建筑工程施工许可
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("建筑工程施工许可")
|
|
|
|
|
@GetMapping("/getJzgcsgxk")
|
|
|
|
|
public AjaxResult getJzgcsgxk() throws Exception {
|
|
|
|
|
if (isZs) {
|
|
|
|
|
String czztdm = "91320594608197761G";
|
|
|
|
|
String contacts = "http://172.21.10.46/api/invoke/323018/jzgcsgxk";
|
|
|
|
|
String a1 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(accessId.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
String a2 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(czztdm.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
String a4 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(sceneId.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
//生成sm3签名
|
|
|
|
|
String input = "accessId=" + accessId + "&czztdm=" + czztdm + "&sceneId=" + sceneId;
|
|
|
|
|
try {
|
|
|
|
|
// 1. 构建 URL(含签名参数,处理特殊符号)
|
|
|
|
|
String encodedSignature = URLEncoder.encode(SmUtil.sm3(input), "UTF-8")
|
|
|
|
|
.replace("+", "%20"); // 确保 + 不被编码为空格
|
|
|
|
|
String fullUrl = contacts + "?signature=" + encodedSignature;
|
|
|
|
|
// 2. 创建连接
|
|
|
|
|
URL url = new URL(fullUrl);
|
|
|
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
|
|
conn.setRequestMethod("POST");
|
|
|
|
|
conn.setDoOutput(true);
|
|
|
|
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
|
|
|
|
|
|
|
|
|
// 3. 构建请求体(严格对齐 curl -F 格式)
|
|
|
|
|
try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
|
|
|
|
|
writeFormField(out, "accessId", a1);
|
|
|
|
|
writeFormField(out, "czztdm", a2);
|
|
|
|
|
writeFormField(out, "sceneId", a4);
|
|
|
|
|
// 结束标记
|
|
|
|
|
out.writeBytes("--" + BOUNDARY + "--\r\n");
|
|
|
|
|
}
|
|
|
|
|
// 4. 处理响应
|
|
|
|
|
int statusCode = conn.getResponseCode();
|
|
|
|
|
StringBuilder response = getResponse(statusCode, conn);
|
|
|
|
|
if (statusCode == 200) {
|
|
|
|
|
JSONObject jsonObj = JSONObject.parseObject(String.valueOf(response));
|
|
|
|
|
// if ("200".equals(jsonObj.getString("code"))) { // 使用 getString 避免类型问题
|
|
|
|
|
// 直接获取 data 字段为 JSONObject(无需转换 String)
|
|
|
|
|
JSONObject reqData = jsonObj.getJSONObject("data");
|
|
|
|
|
String responseParams = reqData.getString("responseParams");
|
|
|
|
|
String s = new String((byte[]) SM2Demo.dexec(
|
|
|
|
|
Base64.getDecoder().decode(responseParams), "C1C2C3",
|
|
|
|
|
Base64.getDecoder().decode(sm2)),
|
|
|
|
|
StandardCharsets.UTF_8);
|
|
|
|
|
return AjaxResult.success(StringUtil.getFinalData(s));
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
} catch (Exception y) {
|
|
|
|
|
y.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 建筑工程竣工验收备案表
|
|
|
|
|
*/
|
|
|
|
|
@ApiOperation("建筑工程竣工验收备案表")
|
|
|
|
|
@GetMapping("/getJgysbab")
|
|
|
|
|
public AjaxResult getJgysbab() throws Exception {
|
|
|
|
|
if (isZs) {
|
|
|
|
|
String czztdm = "9132059456176406XP";
|
|
|
|
|
String czztmc = "苏州纳米科技发展有限公司";
|
|
|
|
|
System.out.println(czztdm);
|
|
|
|
|
System.out.println(czztmc);
|
|
|
|
|
String contacts = "http://172.21.10.46/api/invoke/323018/jzgcjgysbab";
|
|
|
|
|
String a1 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(accessId.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
String a2 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(czztdm.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
String a3 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(czztmc.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
String a4 = Base64.getEncoder().encodeToString((byte[])
|
|
|
|
|
SM4Demo.exec(sceneId.getBytes(),
|
|
|
|
|
"ECB", "PKCS5Padding", "random", sm4.getBytes(), null));
|
|
|
|
|
//生成sm3签名
|
|
|
|
|
String input = "accessId=" + accessId + "&czztdm=" + czztdm + "&czztmc=" + czztmc + "&sceneId=" + sceneId;
|
|
|
|
|
try {
|
|
|
|
|
// 1. 构建 URL(含签名参数,处理特殊符号)
|
|
|
|
|
String encodedSignature = URLEncoder.encode(SmUtil.sm3(input), "UTF-8")
|
|
|
|
|
.replace("+", "%20"); // 确保 + 不被编码为空格
|
|
|
|
|
String fullUrl = contacts + "?signature=" + encodedSignature;
|
|
|
|
|
// 2. 创建连接
|
|
|
|
|
URL url = new URL(fullUrl);
|
|
|
|
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
|
|
|
conn.setRequestMethod("POST");
|
|
|
|
|
conn.setDoOutput(true);
|
|
|
|
|
conn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
|
|
|
|
|
|
|
|
|
|
// 3. 构建请求体(严格对齐 curl -F 格式)
|
|
|
|
|
try (DataOutputStream out = new DataOutputStream(conn.getOutputStream())) {
|
|
|
|
|
writeFormField(out, "accessId", a1);
|
|
|
|
|
writeFormField(out, "czztdm", a2);
|
|
|
|
|
writeFormField(out, "czztmc", a3);
|
|
|
|
|
writeFormField(out, "sceneId", a4);
|
|
|
|
|
// 结束标记
|
|
|
|
|
out.writeBytes("--" + BOUNDARY + "--\r\n");
|
|
|
|
|
}
|
|
|
|
|
// 4. 处理响应
|
|
|
|
|
int statusCode = conn.getResponseCode();
|
|
|
|
|
StringBuilder response = getResponse(statusCode, conn);
|
|
|
|
|
if (statusCode == 200) {
|
|
|
|
|
JSONObject jsonObj = JSONObject.parseObject(String.valueOf(response));
|
|
|
|
|
// if ("200".equals(jsonObj.getString("code"))) { // 使用 getString 避免类型问题
|
|
|
|
|
// 直接获取 data 字段为 JSONObject(无需转换 String)
|
|
|
|
|
JSONObject reqData = jsonObj.getJSONObject("data");
|
|
|
|
|
String responseParams = reqData.getString("responseParams");
|
|
|
|
|
String s = new String((byte[]) SM2Demo.dexec(
|
|
|
|
|
Base64.getDecoder().decode(responseParams), "C1C2C3",
|
|
|
|
|
Base64.getDecoder().decode(sm2)),
|
|
|
|
|
StandardCharsets.UTF_8);
|
|
|
|
|
System.out.println(s);
|
|
|
|
|
return AjaxResult.success(StringUtil.getFinalData(s));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception y) {
|
|
|
|
|
y.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static StringBuilder getResponse(int statusCode, HttpURLConnection conn) throws IOException {
|
|
|
|
|
StringBuilder response = new StringBuilder();
|
|
|
|
|
try (BufferedReader in = new BufferedReader(new InputStreamReader(
|
|
|
|
|
(statusCode >= 200 && statusCode < 300) ? conn.getInputStream() : conn.getErrorStream(),
|
|
|
|
|
StandardCharsets.UTF_8))) {
|
|
|
|
|
String line;
|
|
|
|
|
while ((line = in.readLine()) != null) {
|
|
|
|
|
response.append(line);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void writeFormField(DataOutputStream out, String name, String value) throws Exception {
|
|
|
|
|
out.writeBytes("--" + BOUNDARY + "\r\n");
|
|
|
|
|
out.writeBytes("Content-Disposition: form-data; name=\"" + name + "\"\r\n");
|
|
|
|
|
out.writeBytes("Content-Type: text/plain; charset=UTF-8\r\n\r\n");
|
|
|
|
|
out.writeBytes(value + "\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询所有数据
|
|
|
|
|
*
|
|
|
|
@ -272,7 +446,6 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 模板信息
|
|
|
|
|
*/
|
|
|
|
@ -373,12 +546,12 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
map.put("issuingTime", a1.getBasicInformation().getIssuingTime() != null ? a1.getBasicInformation().getIssuingTime() : "/");
|
|
|
|
|
map.put("jsjd", a1.getBasicInformation().getJsjd() != null ? a1.getBasicInformation().getJsjd() : "/");
|
|
|
|
|
map.put("xzfl", a1.getBasicInformation().getXzfl() != null ?
|
|
|
|
|
basicInformationService.getDictLabel("xzfl", String.valueOf(a1.getBasicInformation().getXzfl()),sysDictData) : "/");
|
|
|
|
|
basicInformationService.getDictLabel("xzfl", String.valueOf(a1.getBasicInformation().getXzfl()), sysDictData) : "/");
|
|
|
|
|
map.put("nature", a1.getBasicInformation().getNature() != null ?
|
|
|
|
|
basicInformationService.getDictLabel("xmfrdwxz", String.valueOf(a1.getBasicInformation().getNature()),sysDictData) : "/");
|
|
|
|
|
basicInformationService.getDictLabel("xmfrdwxz", String.valueOf(a1.getBasicInformation().getNature()), sysDictData) : "/");
|
|
|
|
|
map.put("name", a1.getBasicInformation().getName() != null ? a1.getBasicInformation().getName() : "/");
|
|
|
|
|
map.put("ssgnq", a1.getBasicInformation().getSsgnq() != null ?
|
|
|
|
|
basicInformationService.getDictLabel("ssgnq", String.valueOf(a1.getBasicInformation().getSsgnq()),sysDictData) : "/");
|
|
|
|
|
basicInformationService.getDictLabel("ssgnq", String.valueOf(a1.getBasicInformation().getSsgnq()), sysDictData) : "/");
|
|
|
|
|
map.put("jsdd", a1.getBasicInformation().getJsdd() != null ? a1.getBasicInformation().getJsdd() : "/");
|
|
|
|
|
map.put("xmfrdwxz", a1.getBasicInformation().getXmfrdwxz() != null ? a1.getBasicInformation().getXmfrdwxz() : "/");
|
|
|
|
|
map.put("tyshxydm", a1.getBasicInformation().getTyshxydm() != null ? a1.getBasicInformation().getTyshxydm() : "/");
|
|
|
|
@ -412,7 +585,7 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
map.put("kzczmj", a1.getQyrzInformation().getKzczmj() != null ? a1.getQyrzInformation().getKzczmj() : "/");
|
|
|
|
|
map.put("gycfpjzj", a1.getQyrzInformation().getGycfpjzj() != null ? a1.getQyrzInformation().getGycfpjzj() : "/");
|
|
|
|
|
try {
|
|
|
|
|
String itemsFileName = fatherFile + "/" + a1.getBasicInformation().getName()+".docx";
|
|
|
|
|
String itemsFileName = fatherFile + "/" + a1.getBasicInformation().getName() + ".docx";
|
|
|
|
|
Path targetPath = Paths.get(itemsFileName);
|
|
|
|
|
Files.createDirectories(targetPath.getParent());
|
|
|
|
|
// 2. 打开输出流(自动覆盖已有文件)
|
|
|
|
@ -420,7 +593,7 @@ public class BasicInformationController extends BaseController {
|
|
|
|
|
Files.newOutputStream(targetPath,
|
|
|
|
|
StandardOpenOption.CREATE,
|
|
|
|
|
StandardOpenOption.TRUNCATE_EXISTING))) {
|
|
|
|
|
basicInformationService.generateDocument(map,"xmdtcl.docx",out);
|
|
|
|
|
basicInformationService.generateDocument(map, "xmdtcl.docx", out);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new RuntimeException("文件下载失败");
|
|
|
|
|