|
|
@@ -262,8 +262,9 @@ public class ExternalOAServiceImpl implements ExternalOAService {
|
|
|
return CommonResult.error(400, "流程ID不能为空");
|
|
|
}
|
|
|
|
|
|
- // 回退目标状态:报告编制(520)
|
|
|
+ // 退回目标状态:记录录入(500)
|
|
|
Integer rollbackStatus = TaskOrderStatusEnum.REPORT_PREPARE.getStatus();
|
|
|
+ String returnReason = returnFlowVO.getState();
|
|
|
|
|
|
// 先在锅炉报告表中查找
|
|
|
BoilerTaskOrderItemReportDO boilerReport = boilerTaskOrderItemReportMapper.selectOne(
|
|
|
@@ -274,7 +275,7 @@ public class ExternalOAServiceImpl implements ExternalOAService {
|
|
|
LambdaUpdateWrapper<BoilerTaskOrderItemReportDO> updateObj = new LambdaUpdateWrapper<>();
|
|
|
updateObj.eq(BoilerTaskOrderItemReportDO::getId, boilerReport.getId());
|
|
|
updateObj.set(BoilerTaskOrderItemReportDO::getTaskStatus, rollbackStatus);
|
|
|
- updateObj.set(BoilerTaskOrderItemReportDO::getReturnReason, returnFlowVO.getHandleType());
|
|
|
+ updateObj.set(BoilerTaskOrderItemReportDO::getReturnReason, returnReason);
|
|
|
// 清空审批相关字段
|
|
|
updateObj.set(BoilerTaskOrderItemReportDO::getApprovalId, null);
|
|
|
updateObj.set(BoilerTaskOrderItemReportDO::getApprovalTime, null);
|
|
|
@@ -294,7 +295,7 @@ public class ExternalOAServiceImpl implements ExternalOAService {
|
|
|
LambdaUpdateWrapper<PipeTaskOrderItemReportDO> updateObj = new LambdaUpdateWrapper<>();
|
|
|
updateObj.eq(PipeTaskOrderItemReportDO::getId, pipeReport.getId());
|
|
|
updateObj.set(PipeTaskOrderItemReportDO::getTaskStatus, rollbackStatus);
|
|
|
- updateObj.set(PipeTaskOrderItemReportDO::getReturnReason, returnFlowVO.getHandleType());
|
|
|
+ updateObj.set(PipeTaskOrderItemReportDO::getReturnReason, returnReason);
|
|
|
// 清空审批相关字段
|
|
|
updateObj.set(PipeTaskOrderItemReportDO::getApprovalId, null);
|
|
|
updateObj.set(PipeTaskOrderItemReportDO::getApprovalTime, null);
|
|
|
@@ -308,114 +309,4 @@ public class ExternalOAServiceImpl implements ExternalOAService {
|
|
|
log.warn("OA退回流程:未找到summaryId={}对应的报告记录", summaryId);
|
|
|
return CommonResult.error(500, "未找到对应的报告记录");
|
|
|
}
|
|
|
-
|
|
|
- @Override
|
|
|
- public byte[] pdf(String templateId, String instanceId) throws Exception {
|
|
|
- CommonResult<StandardTemplateRespDTO> standardTemplate = standardTemplateApi.getStandardTemplate(templateId);
|
|
|
- String fileUrl = standardTemplate.getCheckedData().getFileUrl();
|
|
|
- byte[] bytes = fileApi.getFileByPath(fileUrl).getCheckedData();
|
|
|
- GrapeCityReqDTO grapeCityReqDTO = new GrapeCityReqDTO();
|
|
|
- grapeCityReqDTO.setTemplateBytes(bytes);
|
|
|
-
|
|
|
- List<DynamicTbValDO> list = dynamicTbValService.lambdaQuery().eq(DynamicTbValDO::getInsId, instanceId).list();
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- for (DynamicTbValDO dynamicTbValDO : list) {
|
|
|
- map.put(dynamicTbValDO.getColCode(), dynamicTbValDO.getValValue());
|
|
|
- }
|
|
|
- return this.fullPdf(bytes, map);
|
|
|
- }
|
|
|
-
|
|
|
- private byte[] fullPdf(byte[] templateBytes, Map<String, Object> data) throws Exception {
|
|
|
-
|
|
|
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
|
|
- WorkbookOptions workbookOptions = new WorkbookOptions();
|
|
|
- workbookOptions.setPixelBasedColumnWidth(true);
|
|
|
- //Don't autofit row height
|
|
|
- XlsxOpenOptions options = new XlsxOpenOptions();
|
|
|
- options.setImportFlags(EnumSet.of(ImportFlags.Data));
|
|
|
- options.setDoNotAutoFitAfterOpened(true);
|
|
|
- Workbook workbook = new Workbook(workbookOptions);
|
|
|
- InputStream inputStream = new ByteArrayInputStream(templateBytes);
|
|
|
- workbook.open(inputStream, OpenFileFormat.Sjs);
|
|
|
- int pageStart = 0;
|
|
|
- for (int i = 0; i < workbook.getWorksheets().getCount(); i++) {
|
|
|
- IWorksheet worksheet = workbook.getWorksheets().get(i);
|
|
|
- worksheet.getPageSetup().setPrintHeadings(false);
|
|
|
- worksheet.getPageSetup().setPaperSize(PaperSize.A4);
|
|
|
- worksheet.getPageSetup().setLeftMargin(15); // 左边距
|
|
|
- worksheet.getPageSetup().setRightMargin(15); // 右边距
|
|
|
- worksheet.getPageSetup().setCenterHorizontally(true);
|
|
|
- worksheet.setDataSource(new JsonDataSource(JSON.toJSONString(data)));
|
|
|
- if (worksheet.getName().contains("封面") || worksheet.getName().contains("注意")) {
|
|
|
- pageStart++;
|
|
|
- } else {
|
|
|
- if (pageStart == 0) {
|
|
|
- worksheet.getPageSetup().setCenterFooter("第&P页共&N页");
|
|
|
- } else {
|
|
|
- worksheet.getPageSetup().setCenterFooter("第&P-1页共&N-" + pageStart + "页");
|
|
|
- }
|
|
|
- worksheet.getPageSetup().setIsAutoFirstPageNumber(true);
|
|
|
- }
|
|
|
- // 填充签名图片
|
|
|
- for (int x = 0; x < worksheet.getRowCount(); x++) {
|
|
|
- for (int y = 0; y < worksheet.getColumnCount(); y++) {
|
|
|
- IRange range = worksheet.getCells().get(x, y);
|
|
|
- if (range.getBindingPath() != null && range.getValue() != null) {
|
|
|
- String value = (String) range.getValue();
|
|
|
- if (value.endsWith(".png") || value.endsWith(".jpg")) {
|
|
|
- // 是非多张图片
|
|
|
- if(!value.contains(",")){
|
|
|
- byte[] bytes = fileApi.getFileByPath(value).getCheckedData();
|
|
|
- range.setValue(null);
|
|
|
- IRange mergeArea = range.getMergeArea();
|
|
|
- mergeArea.setBackgroundImage(bytes);
|
|
|
- }else {
|
|
|
- String[] split = value.split(",");
|
|
|
- byte[][] bytes = new byte[split.length][];
|
|
|
- for (int k = 0; k < split.length; k++) {
|
|
|
- bytes[k] = fileApi.getFileByPath(split[k]).getCheckedData();
|
|
|
- }
|
|
|
- range.setValue(null);
|
|
|
- IRange mergeArea = range.getMergeArea();
|
|
|
-
|
|
|
- // 横向合并图片
|
|
|
- byte[] bytes1 = ImageUtil.mergeImages(bytes);
|
|
|
- mergeArea.setBackgroundImage(bytes1);
|
|
|
- }
|
|
|
- }
|
|
|
- if (range.getCellType() instanceof com.grapecity.documents.excel.CheckBoxCellType){
|
|
|
- if (!"true".equals(range.getValue())){
|
|
|
- range.setValue(null);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- // 浮动图片
|
|
|
- if (data.get("Illustration") != null){
|
|
|
- String illustration = (String) data.get("Illustration");
|
|
|
- if (illustration.startsWith("[") && illustration.endsWith("]")) {
|
|
|
- JSONArray jsonArray = JSON.parseArray(illustration);
|
|
|
- List<JSONObject> list = new ArrayList<>();
|
|
|
- for (int k = 0; k < jsonArray.size(); k++) {
|
|
|
- JSONObject jsonObject = jsonArray.getJSONObject(k);
|
|
|
- if (jsonObject.getString("sheet").equals(worksheet.getName())){
|
|
|
- byte[] bytes = fileApi.getFileByPath(jsonObject.getString("url")).getCheckedData();
|
|
|
- InputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
|
|
|
- worksheet.getShapes().addPictureInPixel(byteArrayInputStream, ImageType.JPG, jsonObject.getDouble("x"), jsonObject.getDouble("y"), jsonObject.getDouble("width"), jsonObject.getDouble("height"));
|
|
|
- }else {
|
|
|
- list.add(jsonObject);
|
|
|
- }
|
|
|
- }
|
|
|
- data.put("Illustration", JSON.toJSONString(list));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- PrintManager printManager = new PrintManager();
|
|
|
- Workbook.FontsFolderPath = this.fontsFolderPath;
|
|
|
- List<PageInfo> pages = printManager.paginate(workbook);
|
|
|
- printManager.savePageInfosToPDF(byteArrayOutputStream, pages);
|
|
|
- return byteArrayOutputStream.toByteArray();
|
|
|
- }
|
|
|
}
|