修改页面和接口
This commit is contained in:
parent
5d4db27e1f
commit
282b35c0e4
|
@ -1,5 +1,11 @@
|
|||
package com.cyx.web.base.controller;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import com.cyx.common.config.RuoYiConfig;
|
||||
import com.itextpdf.text.*;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -16,6 +22,15 @@ import com.cyx.common.utils.poi.ExcelUtil;
|
|||
import com.cyx.system.service.ISysDeptService;
|
||||
import com.cyx.web.base.domain.*;
|
||||
import com.cyx.web.base.service.*;
|
||||
import com.itextpdf.text.pdf.PdfPCell;
|
||||
import com.itextpdf.text.pdf.PdfPTable;
|
||||
import com.itextpdf.text.pdf.PdfWriter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -26,6 +41,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 党务Controller
|
||||
*
|
||||
|
@ -104,6 +122,37 @@ public class TAmentPartyAffairsController extends BaseController
|
|||
return prefix + "/viewFiles";
|
||||
}
|
||||
|
||||
@GetMapping("getFiles")
|
||||
public void getFiles(String path, HttpServletResponse response,String filename) {
|
||||
File inputFile = new File("D:\\ruoyi\\uploadPath\\upload\\2023\\08\\31\\牛舍管理查询导出_20230831105444A002.xlsx");
|
||||
try {
|
||||
|
||||
InputStream inputStream = Files.newInputStream(inputFile.toPath());
|
||||
Document document = new Document();
|
||||
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("output.pdf"));
|
||||
document.open();
|
||||
PdfPTable table = new PdfPTable(1); // 创建一个表格,每行一个单元格
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
table.addCell(new PdfPCell(new Phrase(line))); // 将每一行内容添加到表格中
|
||||
}
|
||||
document.add(table); // 将表格添加到PDF文档中
|
||||
document.close();
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
// attachment是以附件的形式下载,inline是浏览器打开
|
||||
response.setHeader("Content-Disposition", "inline;filename="+filename+".pdf");
|
||||
response.setContentType("text/plain;UTF-8");
|
||||
// 把二进制流放入到响应体中
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
byte[] bytes = FileUtils.readFileToByteArray(inputFile);
|
||||
os.write(bytes);
|
||||
os.flush();
|
||||
os.close();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -280,6 +329,24 @@ public class TAmentPartyAffairsController extends BaseController
|
|||
return array;
|
||||
}
|
||||
|
||||
@GetMapping("/zhiwuTree")
|
||||
@ResponseBody
|
||||
public Object zhiwuTree(TAmentPartyAffairs tAmentPartyAffairs)
|
||||
{
|
||||
JSONArray array =new JSONArray();
|
||||
List<Map<String,Object>> list = tAmentPartyAffairsService.zhiwuTree(tAmentPartyAffairs);
|
||||
list.forEach(l->{
|
||||
JSONArray array1 = JSONArray.parseArray("["+l.get("json")+"]");
|
||||
array1.forEach(a->{
|
||||
JSONObject o = (JSONObject) a;
|
||||
o.put("pId",l.get("id"));
|
||||
o.put("type",l.get("type"));
|
||||
array.add(o);
|
||||
});
|
||||
});
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询党务列表
|
||||
*/
|
||||
|
|
|
@ -85,4 +85,6 @@ public interface TAmentPartyAffairsMapper
|
|||
|
||||
List<Map<String,Object>> importantWork(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
List<Map<String,Object>> labelTotal(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
|
||||
List<Map<String, Object>> zhiwuTree(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
}
|
||||
|
|
|
@ -85,4 +85,6 @@ public interface ITAmentPartyAffairsService
|
|||
|
||||
List<Map<String,Object>> importantWork(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
List<Map<String,Object>> labelTotal(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
|
||||
List<Map<String, Object>> zhiwuTree(TAmentPartyAffairs tAmentPartyAffairs);
|
||||
}
|
||||
|
|
|
@ -67,6 +67,11 @@ public class TAmentPartyAffairsServiceImpl implements ITAmentPartyAffairsService
|
|||
return tAmentPartyAffairsMapper.deptTree(tAmentPartyAffairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> zhiwuTree(TAmentPartyAffairs tAmentPartyAffairs){
|
||||
return tAmentPartyAffairsMapper.zhiwuTree(tAmentPartyAffairs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> importantWork(TAmentPartyAffairs tAmentPartyAffairs){
|
||||
return tAmentPartyAffairsMapper.importantWork(tAmentPartyAffairs);
|
||||
|
|
|
@ -158,6 +158,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
f.type
|
||||
</select>
|
||||
|
||||
<select id="deptTree" parameterType="TAmentPartyAffairs" resultType="map">
|
||||
SELECT
|
||||
f.id,
|
||||
f.type,
|
||||
GROUP_CONCAT( '{"pId":', f.id, ',"id":', f.dept_id, ',"name":"', f.dept_name, '","title":"', f.dept_name, '"}' ) json
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
a.id,
|
||||
a.type,
|
||||
b.id dept_id,
|
||||
b.party_duties dept_name
|
||||
FROM
|
||||
t_ament_party_affairs a
|
||||
LEFT JOIN t_ament_personnel b ON a.head = b.id
|
||||
WHERE
|
||||
1 = 1
|
||||
<if test="type != null and type != ''"> and a.type = #{type}</if>
|
||||
GROUP BY
|
||||
a.type,
|
||||
a.head
|
||||
) f
|
||||
GROUP BY
|
||||
f.type
|
||||
</select>
|
||||
|
||||
<select id="labelTotal" parameterType="TAmentPartyAffairs" resultType="map">
|
||||
SELECT
|
||||
ROUND( sum(a.now_score) / sum(a.score) * 100 ) percent,
|
||||
|
@ -381,6 +407,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
update t_ament_party_affairs
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="type != null and type != ''">type = #{type},</if>
|
||||
<if test="shotName != null and shotName != ''">shot_name = #{shotName},</if>
|
||||
<if test="unit != null">unit = #{unit},</if>
|
||||
<if test="target != null">target = #{target},</if>
|
||||
<if test="demand != null">demand = #{demand},</if>
|
||||
|
|
Loading…
Reference in New Issue