Merge branch 'develop_3' into 'develop_master'

Develop 3

See merge request LiuChao/foton-slrs-system-rest!222
This commit is contained in:
super_liu
2021-11-07 16:49:22 +08:00
21 changed files with 475 additions and 27 deletions
@@ -28,6 +28,9 @@ public class ActDefineStartMap {
// 政策入库
map.put("laws1","lawsLibraryWkflow");
//政策征求意见, 认证重点法规/政策 流程
map.put("laws2","PolicyCommentProcessWorkFlow");
map.put("laws3","KCSTPReviewProcessWorkFlow");
//张超然
map.put("20","StandardApplyMeetProcess");
@@ -0,0 +1,99 @@
package com.adc.da.workFlow.common;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import sun.awt.SunHints;
import java.util.List;
import java.util.Map;
public class ExportExcel<T> {
private String header;
private static String[] property;
Workbook workbook=new XSSFWorkbook();
public void setProperty(String property){
this.property=property.split(",");
}
public void setHeader(String header){
this.header=header;
}
public Workbook getWorkBook(T dataJson) throws Exception {
JSONArray dataArray = JSONObject.parseArray(dataJson.toString());
CellStyle cellStyle = workbook.createCellStyle();//初始化单元格格式对象
cellStyle.setAlignment(HorizontalAlignment.CENTER);
Sheet sheet = workbook.createSheet();
sheet.setDefaultColumnWidth(25);
createHeader(sheet,header);
createData(sheet,dataArray);
return workbook;
}
public static void createHeader(Sheet sheet, String header){
Row rowHeader = sheet.createRow(0);//开始创建标题行
if (StringUtils.isNotBlank(header)) {
String[] headerArr = header.split(",");
for (int i=0;i < headerArr.length; i++) {
rowHeader.createCell(i).setCellValue(headerArr[i]);
}
}
}
public static void createData(Sheet sheet, List<?> data) throws Exception{
if (data != null && !data.isEmpty()) {
for (int i=0;i < data.size(); i++) {
Row row = sheet.createRow(i+1);
int sheetNum = 0;
JSONObject datumJson =(JSONObject)data.get(i);
/**
* 遍历jsonObject值填入一行的单元格中
*/
for (String s : property) {
String value = datumJson.getString(s);
row.createCell(sheetNum).setCellValue(value);
sheetNum++;
}
// Class cls = importDto.getClass();
// Field[] fields = cls.getDeclaredFields();
// for (Field field : fields) {
// field.setAccessible(true);
// if (field.get(importDto)!=null){
// String value = field.get(importDto).toString();
// row.createCell(sheetNum).setCellValue(value);
// }else {
// row.createCell(sheetNum).setCellValue("");
// }
// sheetNum++;
// }
}
}
}
}
@@ -0,0 +1,69 @@
package com.adc.da.workFlow.controller;
import com.adc.da.common.ReadExcel;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.workFlow.common.ExportExcel;
import com.adc.da.workFlow.service.PolicyWorkFlowService;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@RestController
@RequestMapping("/${restPath}/policy/activiti")
@Api(tags = "政策征求意见和重点法规或政策认证流程")
public class PolicyWorkFlowController {
/**
* 政策征求意见导出
*/
@PostMapping("/exportExcel")
@ApiOperation("导出政策征求意见为excel")
public void exportExcel(@RequestBody String dataJson, HttpServletResponse response, HttpServletRequest request) throws Exception {
JSONObject data = JSONObject.parseObject(dataJson);
JSONArray info = data.getJSONArray("dataList");
ExportExcel exportExcel = new ExportExcel();
exportExcel.setHeader("章节编号,章节名称,修改前,修改后,修改理由,原因,提出部门,提出人");
exportExcel.setProperty("chapterNumber,chapterName,oldText,newText,changeReason,reason,department,responUserName");
Workbook workbook=exportExcel.getWorkBook(info);
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename=" + ReadExcel.encodeFileName("政策征求意见"+".xlsx",request));
// response.setContentType("application/force-download");
ServletOutputStream outputStream = response.getOutputStream();
workbook.write(outputStream);
outputStream.flush();
}
@Autowired
private PolicyWorkFlowService policyWorkFlowService;
/**
* 政策征求意见导出
*/
@PostMapping("/enterIssue")
@ApiOperation("纳入重点问题管控")
public ResponseMessage enterIssue(@RequestBody String json){
boolean result = policyWorkFlowService.enterIssue(json);
return Result.success(result);
}
}
@@ -524,13 +524,22 @@ public class WorkFlowController {
map.put("flag","未完成");
}
if(map.get("comment")!=null && !map.get("comment").toString().equals("")){
if(map.get("comment").toString().equals("0")){
map.put("comment","同意");
}else if(map.get("comment").toString().equals("1")){
map.put("comment","不同意");
}else{
map.put("comment",map.get("commentText").toString());
String comment = map.get("comment").toString();
switch (comment){
case "0":
map.put("comment","同意");
break;
case "1":
map.put("comment","不同意");
break;
default:
String commentText="";
map.put("comment",comment+map.get("commentText"));
}
}else if (map.get("commentText")!=null && !"".equals(map.get("commentText"))){
map.put("comment",map.get("commentText").toString());
}
ProcessDetailExport user = JSON.parseObject(JSON.toJSONString(map), ProcessDetailExport.class);
exportDatas.add(user);
@@ -0,0 +1,45 @@
package com.adc.da.workFlow.service;
import com.adc.da.slrs.sarStandUnqualified.entity.BusinessDeptIssue;
import com.adc.da.slrs.sarStandUnqualified.service.IBusinessDeptIssueService;
import com.adc.da.util.UUIDUtils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class PolicyWorkFlowService {
@Autowired
private IBusinessDeptIssueService businessDeptIssueService;
public boolean enterIssue(String json){
boolean count=false; //是否成功
JSONObject dataJsonObj = JSONObject.parseObject(json);
if ("1".equals(dataJsonObj.getString("department"))) {
JSONArray dataList = dataJsonObj.getJSONArray("dataList");
/**
* 把json对象转换未实体对象
*/
List<BusinessDeptIssue> data = dataList
.stream()
.map(jsonObj -> {
BusinessDeptIssue businessDeptIssue = JSONObject.parseObject(jsonObj.toString(), BusinessDeptIssue.class);
businessDeptIssue.setId(UUIDUtils.randomUUID20());
return businessDeptIssue;
}).collect(Collectors.toList());
count=businessDeptIssueService.saveBatch(data);
}
return count;
}
}