Merge remote-tracking branch 'origin/master'

# Conflicts:
#	cyx-admin/src/main/java/com/cyx/web/base/controller/TAmentPartyAffairsController.java
This commit is contained in:
duxp 2023-09-14 11:46:17 +08:00
commit 195b5045aa
5 changed files with 85 additions and 0 deletions

View File

@ -115,6 +115,37 @@ public class TAmentPartyAffairsController extends BaseController
return prefix + "/prePdf";
}
@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();
}
}
/**
*
@ -291,6 +322,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;
}
/**
* 查询党务列表
*/

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -158,6 +158,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
f.type
</select>
<select id="zhiwuTree" 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>