|
|
|
@ -1,23 +1,31 @@
|
|
|
|
|
package com.ruoyi.jjh.ent.controller;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel;
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
|
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;
|
|
|
|
|
import com.ruoyi.jjh.declaration.entity.BmsDeclarationRecords;
|
|
|
|
|
import com.ruoyi.jjh.ent.entity.JPolicyFile;
|
|
|
|
|
import com.ruoyi.jjh.ent.entity.request.JPolicyFileRequest;
|
|
|
|
|
import com.ruoyi.jjh.ent.service.JMemorandumService;
|
|
|
|
|
import com.ruoyi.jjh.ent.service.JPolicyFileService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 政策文件(j_policy_file)表控制层
|
|
|
|
@ -36,6 +44,9 @@ public class JPolicyFileController extends BaseController {
|
|
|
|
|
@Resource
|
|
|
|
|
private JPolicyFileService jPolicyFileService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private JMemorandumService jMemorandumService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询所有数据
|
|
|
|
|
*
|
|
|
|
@ -49,6 +60,79 @@ public class JPolicyFileController extends BaseController {
|
|
|
|
|
return success(jPolicyFileService.page(page, jPolicyFileRequest));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取某个模板的已填报数据并且导出")
|
|
|
|
|
@GetMapping("/getYtb")
|
|
|
|
|
public void getYtb(HttpServletResponse response, Long templateRecordId) {
|
|
|
|
|
List<BmsDeclarationRecords> ytb = jMemorandumService.getYtb(templateRecordId);
|
|
|
|
|
List<List<String>> data = new ArrayList<>();
|
|
|
|
|
//单选的value
|
|
|
|
|
List<String> value1 = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
List<List<String>> list = new ArrayList<>();
|
|
|
|
|
List<String> head0 = new ArrayList<>();
|
|
|
|
|
head0.add("企业名称");
|
|
|
|
|
List<String> head1 = new ArrayList<>();
|
|
|
|
|
head1.add("统一社会信用代码");
|
|
|
|
|
list.add(head0);
|
|
|
|
|
list.add(head1);
|
|
|
|
|
for (int i = 0; i < ytb.size(); i++) {
|
|
|
|
|
JSONArray js1 = JSONObject.parse(ytb.get(i).getTemplateJson()).getJSONArray("fields");
|
|
|
|
|
JSONArray op1 = JSONObject.parse(js1.get(0).toString()).getJSONArray("options");
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
for (Object s1 : op1) {
|
|
|
|
|
List<String> head2 = new ArrayList<>();
|
|
|
|
|
JSONObject parse = JSONObject.parse(s1.toString());
|
|
|
|
|
head2.add(parse.get("label").toString());
|
|
|
|
|
value1.add(parse.get("value").toString());
|
|
|
|
|
list.add(head2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
JSONArray jsonArray = JSONObject.parse(js1.get(0).toString()).getJSONArray("defaultValue");
|
|
|
|
|
for (Object o : jsonArray) {
|
|
|
|
|
int i1 = value1.indexOf(o.toString());
|
|
|
|
|
if (i1 != -1) {
|
|
|
|
|
if (i1==0) {
|
|
|
|
|
data.add(Arrays.asList(ytb.get(i).getMatter(), ytb.get(i).getCreditCode(), "是", "", "", "", ""));
|
|
|
|
|
}
|
|
|
|
|
if (i1==1) {
|
|
|
|
|
data.add(Arrays.asList(ytb.get(i).getMatter(), ytb.get(i).getCreditCode(), "", "是", "", "", ""));
|
|
|
|
|
}
|
|
|
|
|
if (i1==2) {
|
|
|
|
|
data.add(Arrays.asList(ytb.get(i).getMatter(), ytb.get(i).getCreditCode(), "", "", "是", "", ""));
|
|
|
|
|
}
|
|
|
|
|
if (i1==3) {
|
|
|
|
|
data.add(Arrays.asList(ytb.get(i).getMatter(), ytb.get(i).getCreditCode(), "", "", "", "是", ""));
|
|
|
|
|
}
|
|
|
|
|
if (i1==4) {
|
|
|
|
|
data.add(Arrays.asList(ytb.get(i).getMatter(), ytb.get(i).getCreditCode(), "", "", "", "", "是"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String fileName = "数据导出" + ".xlsx";
|
|
|
|
|
try {
|
|
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20");
|
|
|
|
|
} catch (UnsupportedEncodingException e) {
|
|
|
|
|
throw new RuntimeException("文件名编码失败", e);
|
|
|
|
|
}
|
|
|
|
|
// 创建 Excel 写入流
|
|
|
|
|
// 设置响应头,告诉浏览器下载文件
|
|
|
|
|
// 设置响应头,告诉浏览器下载文件
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
response.setHeader("Content-Disposition", "attachment; filename=" + fileName);
|
|
|
|
|
try (ServletOutputStream outputStream = response.getOutputStream()) {
|
|
|
|
|
// 使用 EasyExcel 写数据到响应流
|
|
|
|
|
EasyExcel.write(outputStream)
|
|
|
|
|
// 这里放入动态头
|
|
|
|
|
.head(list).sheet("模板")
|
|
|
|
|
// 当然这里数据也可以用 List<List<String>> 去传入
|
|
|
|
|
.doWrite(data);
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过主键查询单条数据
|
|
|
|
|