法规符合性看板-导出符合性结果、导出符合性结果明细接口。
This commit is contained in:
+24
@@ -14,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
@Api(tags="法规符合性看板")
|
||||
@@ -42,4 +44,26 @@ public class LawsComplianceBoardController {
|
||||
JSONObject result = this.lawsComplianceBoardService.queryComplianceResultList(params);
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出符合性结果
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
@RequestMapping(value = "/exportComplianceResult")
|
||||
public void exportComplianceResult(HttpServletResponse response, HttpServletRequest request,@RequestParam Map<String,Object> params){
|
||||
this.lawsComplianceBoardService.exportComplianceResult(response,request,params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出符合性结果明细
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
@RequestMapping(value = "/exportComplianceResultDetail")
|
||||
public void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request,@RequestParam Map<String,Object> params){
|
||||
this.lawsComplianceBoardService.exportComplianceResultDetail(response,request,params);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-1
@@ -8,7 +8,7 @@ import java.util.Map;
|
||||
|
||||
public interface LawsComplianceBoardMapper {
|
||||
/**
|
||||
* 查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据
|
||||
* 分页查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据
|
||||
* @param page
|
||||
* @param params
|
||||
* @return
|
||||
@@ -21,4 +21,11 @@ public interface LawsComplianceBoardMapper {
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> queryComplianceResultList(@Param("params") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询出 启动过 设计、prehomo、验证符合性、法规技术评估、法规意见收集其中一个流程 的数据列表
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> queryList(Map<String, Object> params);
|
||||
}
|
||||
|
||||
+37
@@ -62,4 +62,41 @@
|
||||
and pni.project_name like CONCAT(CONCAT('%',#{params.projectName}),'%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="queryList" resultType="hashMap">
|
||||
SELECT
|
||||
bdl.id as "id",
|
||||
bdl.serial_number as "serialNumber",
|
||||
bdl.title as "title",
|
||||
bdl.technology_territory as "technologyTerritory",
|
||||
bdl.state as "state",
|
||||
bdl.create_time as "createTime"
|
||||
FROM
|
||||
buss_document_library bdl
|
||||
LEFT JOIN project_laws_inventory pli ON ( pli.stand_id = bdl.id )
|
||||
LEFT JOIN project_task_inventory pti ON ( pli.id = pti.project_laws_inventory_id )
|
||||
WHERE
|
||||
(
|
||||
bdl.id IN ( SELECT DISTINCT stand_id FROM laws_opinion_gather)
|
||||
OR bdl.id IN ( SELECT DISTINCT stand_id FROM laws_technology_evaluation)
|
||||
or pti.design_p_id IS NOT NULL
|
||||
OR pti.prehomo_p_id IS NOT NULL
|
||||
OR pti.verify_p_id IS NOT NULL
|
||||
)
|
||||
${params.condition}
|
||||
GROUP BY bdl.id
|
||||
order by bdl.create_time desc
|
||||
</select>
|
||||
|
||||
<sql id="Base_Where_Clause">
|
||||
where 1=1
|
||||
<trim suffixOverrides="," >
|
||||
<if test="id != null" >
|
||||
and id ${idOperator} #{id}
|
||||
</if>
|
||||
<if test="type != null" >
|
||||
and type ${typeOperator} #{type}
|
||||
</if>
|
||||
</trim>
|
||||
</sql>
|
||||
</mapper>
|
||||
|
||||
+18
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ILawsComplianceBoardService {
|
||||
@@ -15,4 +17,20 @@ public interface ILawsComplianceBoardService {
|
||||
* @return
|
||||
*/
|
||||
JSONObject queryComplianceResultList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 导出符合性结果
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
void exportComplianceResult(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 导出符合性结果明细
|
||||
* @param response
|
||||
* @param request
|
||||
* @param params
|
||||
*/
|
||||
void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
|
||||
}
|
||||
|
||||
+161
@@ -3,6 +3,8 @@ package com.jero.modules.project.service.impl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.constant.enums.CutEnum;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.document.enums.FieldTypeEnum;
|
||||
import com.jero.modules.document.service.IBussDocumentLibraryEOService;
|
||||
import com.jero.modules.document.vo.QueryConditionVO;
|
||||
@@ -16,12 +18,19 @@ import com.jero.modules.system.util.StringUtils;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -83,6 +92,145 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportComplianceResult(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params) {
|
||||
String cut = (String) params.get("cut");
|
||||
String condition = this.getConditionStr(params);
|
||||
params.put("condition",condition);
|
||||
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryList(params);
|
||||
if(CollectionUtils.isNotEmpty(exportData)){
|
||||
String title = "";
|
||||
String fileName = "";
|
||||
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
||||
title = "编号,标题,状态,技术领域,责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
||||
fileName = "符合性结果" + ".xlsx";
|
||||
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
||||
title = "Serial number,Title,State,Technology territory,Responsible Field,Relevant project,Design conformance,Pre-Homo Confirm,Verify conformance";
|
||||
fileName = "Compliance results" + ".xlsx";
|
||||
}
|
||||
OutputStream os = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
try {
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download");
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("sheet1");
|
||||
|
||||
CellStyle titleCellStyle = workbook.createCellStyle();
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
|
||||
titleCellStyle.setWrapText(true);//自动换行
|
||||
|
||||
//创建表头
|
||||
String[] firstLineTitleArr = title.split(",");
|
||||
Row firstRow = sheet.createRow(0);
|
||||
|
||||
//设置居中、表头值。
|
||||
for (int i = 0; i <= firstLineTitleArr.length; i++){
|
||||
Cell cell = firstRow.createCell(i);
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
cell.setCellValue(firstLineTitleArr[i]);
|
||||
}
|
||||
|
||||
//设置导出数据
|
||||
if(CollectionUtils.isNotEmpty(exportData)) {
|
||||
int rowIndex = 1;
|
||||
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
dataRow.createCell(0).setCellValue(exportData.get(dataIndex).get("serialNumber").toString());
|
||||
dataRow.createCell(1).setCellValue(exportData.get(dataIndex).get("title").toString());
|
||||
dataRow.createCell(2).setCellValue(exportData.get(dataIndex).get("state").toString());
|
||||
dataRow.createCell(3).setCellValue(exportData.get(dataIndex).get("technologyTerritory").toString());
|
||||
|
||||
dataRow.createCell(4).setCellValue(exportData.get(dataIndex).get("dutyTerritory").toString());
|
||||
dataRow.createCell(5).setCellValue(exportData.get(dataIndex).get("projectName").toString());
|
||||
dataRow.createCell(6).setCellValue(exportData.get(dataIndex).get("designStatus").toString());
|
||||
dataRow.createCell(7).setCellValue(exportData.get(dataIndex).get("prehomoStats").toString());
|
||||
dataRow.createCell(8).setCellValue(exportData.get(dataIndex).get("verifyStatus").toString());
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
}catch (IOException ex){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
throw new JeroBootException("下载文件失败");
|
||||
}else{
|
||||
throw new JeroBootException("Failed to download file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportComplianceResultDetail(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params) {
|
||||
String cut = (String) params.get("cut");
|
||||
List<Map<String,Object>> exportData = this.lawsComplianceBoardMapper.queryComplianceResultList(params);
|
||||
if(CollectionUtils.isNotEmpty(exportData)){
|
||||
String title = "";
|
||||
String fileName = "";
|
||||
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
|
||||
title = "责任领域,相关项目,设计符合性,Pre-Homo确认,验证符合性";
|
||||
fileName = "符合性结果" + ".xlsx";
|
||||
}else if(StringUtils.equals(cut,CutEnum.EN.getValue())){
|
||||
title = "Responsible Field,Relevant project,Design conformance,Pre-Homo Confirm,Verify conformance";
|
||||
fileName = "Compliance results" + ".xlsx";
|
||||
}
|
||||
OutputStream os = null;
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
|
||||
try {
|
||||
response.setHeader("Content-Disposition",
|
||||
"attachment; filename=" + fileName);
|
||||
response.setContentType("application/force-download");
|
||||
|
||||
HSSFSheet sheet = workbook.createSheet("sheet1");
|
||||
|
||||
CellStyle titleCellStyle = workbook.createCellStyle();
|
||||
titleCellStyle.setAlignment(HorizontalAlignment.CENTER);//垂直居中
|
||||
titleCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//水平居中
|
||||
titleCellStyle.setWrapText(true);//自动换行
|
||||
|
||||
//创建表头
|
||||
String[] firstLineTitleArr = title.split(",");
|
||||
Row firstRow = sheet.createRow(0);
|
||||
|
||||
//设置居中、表头值。
|
||||
for (int i = 0; i <= firstLineTitleArr.length; i++){
|
||||
Cell cell = firstRow.createCell(i);
|
||||
cell.setCellStyle(titleCellStyle);
|
||||
cell.setCellValue(firstLineTitleArr[i]);
|
||||
}
|
||||
|
||||
//设置导出数据
|
||||
if(CollectionUtils.isNotEmpty(exportData)) {
|
||||
int rowIndex = 1;
|
||||
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
|
||||
Row dataRow = sheet.createRow(rowIndex);
|
||||
dataRow.createCell(0).setCellValue(exportData.get(dataIndex).get("dutyTerritory").toString());
|
||||
dataRow.createCell(1).setCellValue(exportData.get(dataIndex).get("projectName").toString());
|
||||
dataRow.createCell(2).setCellValue(exportData.get(dataIndex).get("designStatus").toString());
|
||||
dataRow.createCell(3).setCellValue(exportData.get(dataIndex).get("prehomoStats").toString());
|
||||
dataRow.createCell(4).setCellValue(exportData.get(dataIndex).get("verifyStatus").toString());
|
||||
rowIndex ++;
|
||||
}
|
||||
}
|
||||
os = response.getOutputStream();
|
||||
workbook.write(os);
|
||||
os.flush();
|
||||
}catch (IOException ex){
|
||||
if(CutEnum.CN.getValue().equals(cut)){
|
||||
throw new JeroBootException("下载文件失败");
|
||||
}else{
|
||||
throw new JeroBootException("Failed to download file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public String getConditionStr(Map<String, Object> parameter) {
|
||||
@@ -184,6 +332,19 @@ public class LawsComplianceBoardServiceImpl implements ILawsComplianceBoardServi
|
||||
}
|
||||
}
|
||||
|
||||
String ids = (String) parameter.get("ids");
|
||||
if(StringUtils.isNotEmpty(ids)){
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
String idStr = "";
|
||||
for (String id : idList) {
|
||||
idStr += "'"+id+"',";
|
||||
}
|
||||
if(StringUtils.isNotEmpty(idStr)){
|
||||
idStr = idStr.substring(0,idStr.length()-1);
|
||||
conditionSb.append(" and id in("+idStr+")");
|
||||
}
|
||||
}
|
||||
|
||||
//处理列表表头排序
|
||||
/*if (StringUtils.isNotBlank((String) parameter.get("orderByField"))) {
|
||||
conditionSb.append(" order by " + (String) parameter.get("orderByField"));
|
||||
|
||||
Reference in New Issue
Block a user