|
@@ -2,6 +2,8 @@ package com.ruoyi.project.invoice.controller;
|
|
|
|
|
|
import java.io.*;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -28,6 +30,7 @@ import com.ruoyi.project.sems.domain.TSpecdevCc;
|
|
|
import com.ruoyi.project.system.domain.SysDictData;
|
|
|
import com.ruoyi.project.system.service.ISysDictTypeService;
|
|
|
import io.jsonwebtoken.lang.Assert;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
@@ -104,8 +107,22 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
@GetMapping("/exportBook")
|
|
|
public AjaxResult exportBook(TInvoiceBookingworkticket tInvoiceBookingworkticket) throws IOException {
|
|
|
logger.info(JSON.toJSONString(tInvoiceBookingworkticket));
|
|
|
+ //字典查询
|
|
|
+ List<SysDictData> book_work_type = iSysDictTypeService.selectDictDataByType("book_work_type");
|
|
|
+ List<SysDictData> book_work_unit = iSysDictTypeService.selectDictDataByType("book_work_unit");
|
|
|
+ List<SysDictData> book_work_area = iSysDictTypeService.selectDictDataByType("book_work_area");
|
|
|
+ //
|
|
|
+ List<TInvoiceWorkcontent> newtInvoiceWorkcontentList =new ArrayList<>();
|
|
|
List<TInvoiceBookingworkticket> list = tInvoiceBookingworkticketService.selectTInvoiceBookingworkticketList(tInvoiceBookingworkticket);
|
|
|
-
|
|
|
+ for(int i=0;i<list.size();i++){
|
|
|
+ //遍历每一条主表 找到所有的子表 根据每条子表 将主表也同步到每一条数据
|
|
|
+ TInvoiceBookingworkticket bookingworkticket= list.get(i);
|
|
|
+ List<TInvoiceWorkcontent> workcontentList = tInvoiceBookingworkticketService.selectTInvoiceWorkcontentBybookingticketId(bookingworkticket.getId());
|
|
|
+ for (TInvoiceWorkcontent workcontent : workcontentList) {
|
|
|
+ workcontent.setBookingworkticket(bookingworkticket);
|
|
|
+ newtInvoiceWorkcontentList.add(workcontent);
|
|
|
+ }
|
|
|
+ }
|
|
|
SXSSFWorkbook wb = new SXSSFWorkbook(1000);
|
|
|
CellStyle wrapStyle = wb.createCellStyle();
|
|
|
wrapStyle.setWrapText(true); //设置自动换行
|
|
@@ -126,7 +143,6 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
sheet.setColumnWidth(11, 40*256);
|
|
|
sheet.setColumnWidth(12, 40*256);
|
|
|
//设置开始行和开始列
|
|
|
-
|
|
|
Row row0 = sheet.createRow(0);
|
|
|
CellStyle style = wb.createCellStyle();
|
|
|
style.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
|
|
@@ -154,19 +170,165 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
//填充数据
|
|
|
int rowIndex = 1;
|
|
|
int columnIndex = 1;
|
|
|
- for (TInvoiceBookingworkticket t: list
|
|
|
- ) {
|
|
|
+ for (TInvoiceWorkcontent t: newtInvoiceWorkcontentList) {
|
|
|
Row row = sheet.createRow(rowIndex);
|
|
|
- row.createCell(0).setCellValue(t.getId());
|
|
|
+ row.createCell(0).setCellValue("扬子石化-巴斯夫有限责任公司");
|
|
|
//
|
|
|
- if (t.getWorkStartTime()!= null){
|
|
|
- row.createCell(2).setCellValue(new SimpleDateFormat("yyyy/MM/dd").format(t.getWorkStartTime()));
|
|
|
+ if (t.getWorkType()!= null){
|
|
|
+ for (SysDictData p : book_work_type) {
|
|
|
+ if (t.getWorkType().toString().equals(p.getDictValue())) {
|
|
|
+ row.createCell(1).setCellValue(p.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (t.getBookingworkticket().getWorkStartTime()!= null){
|
|
|
+ row.createCell(2).setCellValue(new SimpleDateFormat("yyyy/MM/dd").format(t.getBookingworkticket().getWorkStartTime()));
|
|
|
+ }
|
|
|
+ //
|
|
|
+ if (t.getBookingworkticket().getWorkEndTime()!= null){
|
|
|
+ row.createCell(3).setCellValue(new SimpleDateFormat("yyyy/MM/dd").format(t.getBookingworkticket().getWorkEndTime()));
|
|
|
+ }
|
|
|
+ if (t.getBookingworkticket().getWorkArea()!= null){
|
|
|
+ for (SysDictData p : book_work_area) {
|
|
|
+ if (t.getBookingworkticket().getWorkArea().toString().equals(p.getDictValue())) {
|
|
|
+ row.createCell(4).setCellValue(p.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ row.createCell(5).setCellValue("是");
|
|
|
+ //
|
|
|
+ if (t.getBookingworkticket().getWorkUnit()!= null){
|
|
|
+ for (SysDictData p : book_work_unit) {
|
|
|
+ if (t.getBookingworkticket().getWorkUnit().toString().equals(p.getDictValue())) {
|
|
|
+ row.createCell(6).setCellValue(p.getDictLabel());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //
|
|
|
+ row.createCell(7).setCellValue(t.getBookingworkticket().getContact());
|
|
|
+ //
|
|
|
+ row.createCell(8).setCellValue(t.getBookingworkticket().getPhonenumber());
|
|
|
+ //
|
|
|
+ row.createCell(9).setCellValue("否");
|
|
|
+ //
|
|
|
+ row.createCell(10).setCellValue("");
|
|
|
+ //
|
|
|
+ row.createCell(11).setCellValue("否");
|
|
|
+ //
|
|
|
+ row.createCell(12).setCellValue("");
|
|
|
rowIndex++;
|
|
|
}
|
|
|
- // 总数统计
|
|
|
- Row row1 = sheet.createRow(rowIndex);
|
|
|
- row1.createCell(0).setCellValue("总计");
|
|
|
+ // 接着上面的最后一行追加
|
|
|
+ int rowIndex1 = sheet.getLastRowNum();
|
|
|
+ int columnIndex1= 1;
|
|
|
+ CellStyle setBorder = wb.createCellStyle();
|
|
|
+ //设置背景颜色
|
|
|
+ setBorder.setFillForegroundColor(IndexedColors.BLUE_GREY.getIndex());
|
|
|
+ setBorder.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
+ //设置自动换行
|
|
|
+ setBorder.setWrapText(true);
|
|
|
+ //边框样式
|
|
|
+ //设置上边框线条类型
|
|
|
+ setBorder.setBorderTop(BorderStyle.THIN);
|
|
|
+ //设置右边框线条类型
|
|
|
+ setBorder.setBorderRight(BorderStyle.THIN);
|
|
|
+ //设置下边框线条类型
|
|
|
+ setBorder.setBorderBottom(BorderStyle.THIN);
|
|
|
+ //设置左边框线条类型
|
|
|
+ setBorder.setBorderLeft(BorderStyle.THIN);
|
|
|
+ //设置上边框线条颜色
|
|
|
+ setBorder.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
|
|
|
+ //设置右边框线条颜色
|
|
|
+ setBorder.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
|
|
|
+ //设置下边框线条颜色
|
|
|
+ setBorder.setBottomBorderColor(IndexedColors.BLUE_GREY.getIndex());
|
|
|
+ //设置左边框线条颜色
|
|
|
+ setBorder.setLeftBorderColor(IndexedColors.BLUE_GREY.getIndex());
|
|
|
+ //对齐方式
|
|
|
+ //设置水平对齐方式
|
|
|
+ setBorder.setAlignment(HorizontalAlignment.CENTER);
|
|
|
+ //设置垂直对齐方式
|
|
|
+ setBorder.setVerticalAlignment(VerticalAlignment.CENTER);
|
|
|
+
|
|
|
+ Row row1 = sheet.createRow(rowIndex1);
|
|
|
+ row1.createCell(0).setCellValue("日期");row1.getCell(0).setCellStyle(setBorder);
|
|
|
+ row1.createCell(1).setCellValue("一级动火");row1.getCell(1).setCellStyle(setBorder);
|
|
|
+ row1.createCell(2).setCellValue("二级动火");row1.getCell(2).setCellStyle(setBorder);
|
|
|
+ row1.createCell(3).setCellValue("特级动火");row1.getCell(3).setCellStyle(setBorder);
|
|
|
+ row1.createCell(4).setCellValue("高处作业");row1.getCell(4).setCellStyle(setBorder);
|
|
|
+ row1.createCell(5).setCellValue("受限空间");row1.getCell(5).setCellStyle(setBorder);
|
|
|
+ row1.createCell(6).setCellValue("大型吊装");row1.getCell(6).setCellStyle(setBorder);
|
|
|
+ row1.createCell(7).setCellValue("临时用电");row1.getCell(7).setCellStyle(setBorder);
|
|
|
+ row1.createCell(8).setCellValue("动土作业");row1.getCell(8).setCellStyle(setBorder);
|
|
|
+ row1.createCell(9).setCellValue("断路作业");row1.getCell(9).setCellStyle(setBorder);
|
|
|
+ row1.createCell(10).setCellValue("盲板抽堵");row1.getCell(10).setCellStyle(setBorder);
|
|
|
+ row1.createCell(11).setCellValue("检维修作业");row1.getCell(11).setCellStyle(setBorder);
|
|
|
+ row1.createCell(12).setCellValue("清灌作业");row1.getCell(12).setCellStyle(setBorder);
|
|
|
+ row1.createCell(13).setCellValue("倒灌作业");row1.getCell(13).setCellStyle(setBorder);
|
|
|
+ row1.createCell(14).setCellValue("切水作业");row1.getCell(14).setCellStyle(setBorder);
|
|
|
+ row1.createCell(15).setCellValue("变更作业");row1.getCell(15).setCellStyle(setBorder);
|
|
|
+ row1.createCell(16).setCellValue("承包商作业");row1.getCell(16).setCellStyle(setBorder);
|
|
|
+ row1.createCell(17).setCellValue("停车装置数");row1.getCell(17).setCellStyle(setBorder);
|
|
|
+ row1.createCell(18).setCellValue("总计");row1.getCell(18).setCellStyle(setBorder);
|
|
|
+ //
|
|
|
+ int workType0=0; int workType1=0; int workType2=0; int workType3=0; int workType4=0;
|
|
|
+ int workType5=0; int workType6=0; int workType7=0; int workType8=0; int workType9=0;
|
|
|
+ int workType10=0; int workType11=0; int workType12=0; int workType13=0; int workType14=0;
|
|
|
+ int workType15=0; int workType16=0; int workType17=0;
|
|
|
+ //填充下一个表格
|
|
|
+ for (TInvoiceWorkcontent t: newtInvoiceWorkcontentList) {
|
|
|
+ if(t.getWorkType()==2){
|
|
|
+ workType0++;
|
|
|
+ }else if(t.getWorkType()==3){
|
|
|
+ workType1++;
|
|
|
+ }else if(t.getWorkType()==1){
|
|
|
+ workType2++;
|
|
|
+ }else if(t.getWorkType()==5||t.getWorkType()==6||t.getWorkType()==7||t.getWorkType()==8){
|
|
|
+ workType3++;
|
|
|
+ }else if(t.getWorkType()==15){
|
|
|
+ workType4++;
|
|
|
+ }else if(t.getWorkType()==12||t.getWorkType()==13||t.getWorkType()==14){
|
|
|
+ workType5++;
|
|
|
+ }else if(t.getWorkType()==4){
|
|
|
+ workType6++;
|
|
|
+ }else if(t.getWorkType()==9){
|
|
|
+ workType7++;
|
|
|
+ }else if(t.getWorkType()==10){
|
|
|
+ workType8++;
|
|
|
+ }else if(t.getWorkType()==11){
|
|
|
+ workType9++;//盲板
|
|
|
+ }else if(t.getWorkType()==17){
|
|
|
+ workType11++;//清罐
|
|
|
+ }else if(t.getWorkType()==16){
|
|
|
+ workType12++;//倒灌
|
|
|
+ }else if(t.getWorkType()==18){
|
|
|
+ workType13++;
|
|
|
+ }else {
|
|
|
+ //变更、承包、停车装置暂无数据
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Row row = sheet.createRow(rowIndex1+1);
|
|
|
+ row.createCell(0).setCellValue("");
|
|
|
+ row.createCell(1).setCellValue(workType0);
|
|
|
+ row.createCell(2).setCellValue(workType1);
|
|
|
+ row.createCell(3).setCellValue(workType2);
|
|
|
+ row.createCell(4).setCellValue(workType3);
|
|
|
+ row.createCell(5).setCellValue(workType4);
|
|
|
+ row.createCell(6).setCellValue(workType5);
|
|
|
+ row.createCell(7).setCellValue(workType6);
|
|
|
+ row.createCell(8).setCellValue(workType7);
|
|
|
+ row.createCell(9).setCellValue(workType8);
|
|
|
+ row.createCell(10).setCellValue(workType9);
|
|
|
+ row.createCell(11).setCellValue(0);
|
|
|
+ row.createCell(12).setCellValue(workType11);
|
|
|
+ row.createCell(13).setCellValue(workType12);
|
|
|
+ row.createCell(14).setCellValue(workType13);
|
|
|
+ row.createCell(15).setCellValue(0);
|
|
|
+ row.createCell(16).setCellValue(0);
|
|
|
+ row.createCell(17).setCellValue(0);
|
|
|
+ row.createCell(18).setCellValue(newtInvoiceWorkcontentList.size());
|
|
|
+
|
|
|
|
|
|
OutputStream out = null;
|
|
|
String filename = ExcelUtil.encodingFilename("预约票台账导出");
|
|
@@ -204,7 +366,6 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
tInvoiceBookingworkticket.setCreaterCode(getUserId());
|
|
|
// tInvoiceBookingworkticket.setContact(t.getContact());
|
|
|
// tInvoiceBookingworkticket.setPhonenumber(t.getPhonenumber());
|
|
|
- // 测试一下,先得到这个文件名 地址 在赋值插入 然后赋值 改文件名
|
|
|
tInvoiceBookingworkticketService.insertTInvoiceBookingworkticket(tInvoiceBookingworkticket);
|
|
|
|
|
|
Long didi=tInvoiceBookingworkticket.getId();
|
|
@@ -216,6 +377,7 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
tInvoiceBookingworkticketService.insertTInvoiceWorkcontent(wt);
|
|
|
}
|
|
|
try {
|
|
|
+ // 测试一下,先得到这个文件名 地址 在赋值插入 然后赋值 改文件名
|
|
|
String url= PreView(tInvoiceBookingworkticket.getId());
|
|
|
tInvoiceBookingworkticket.setFilename(url);
|
|
|
tInvoiceBookingworkticketService.updateTInvoiceBookingworkticket(tInvoiceBookingworkticket);
|
|
@@ -297,8 +459,19 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
String templatePath = "static/word/invoice/book.docx";
|
|
|
// 生成word的路径
|
|
|
String fileDir = RuoYiConfig.getProfile() + "/"+ "ticketWord";
|
|
|
- // 生成word的文件
|
|
|
- String fileName = "A" + invoiceBookingworkticket.getContact() + ".docx";
|
|
|
+ // 生成word的文件名称
|
|
|
+ // 承包商+联系人+当前时间
|
|
|
+ StringBuilder contentUserWorkUnit=new StringBuilder();
|
|
|
+ List<SysDictData> book_work_unit = iSysDictTypeService.selectDictDataByType("book_work_unit");
|
|
|
+ if(invoiceBookingworkticket.getWorkUnit()!=null){
|
|
|
+ for (SysDictData p : book_work_unit) {
|
|
|
+ if (invoiceBookingworkticket.getWorkUnit().toString().equals(p.getDictValue())) {
|
|
|
+ contentUserWorkUnit.append(p.getDictLabel());//施工单位承包商
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String time = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ String fileName = contentUserWorkUnit.toString()+invoiceBookingworkticket.getContact() +time+".docx";
|
|
|
String wordPath = this.createWord(templatePath, fileDir, fileName, params);
|
|
|
|
|
|
return wordPath;
|
|
@@ -330,7 +503,7 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
if(ticket.getWorkArea()!=null){
|
|
|
for (SysDictData p : book_work_area) {
|
|
|
if (ticket.getWorkArea().toString().equals(p.getDictValue())) {
|
|
|
- content.append("具体工作内容:"+tInvoiceWorkcontent.getWorkDescription()+"\r\n"+"区域:"+p.getDictLabel());//装置名称
|
|
|
+ content.append("具体工作内容:"+tInvoiceWorkcontent.getWorkDescription()+"区域:"+p.getDictLabel());//装置名称
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -349,7 +522,7 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
if(!params.containsKey("userUnit")){
|
|
|
- params.put("userUnit", Texts.of(contentUserWorkUnit.toString()).fontSize(10).bold().create());
|
|
|
+ params.put("userUnit", Texts.of(contentUserUnit.toString()).fontSize(10).bold().create());
|
|
|
}
|
|
|
}
|
|
|
if(ticket.getUserMg()!=null){
|
|
@@ -359,7 +532,7 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
if(!params.containsKey("userMg")){
|
|
|
- params.put("userMg", Texts.of(contentUserWorkUnit.toString()).fontSize(10).bold().create());
|
|
|
+ params.put("userMg", Texts.of(contentUserMg.toString()).fontSize(10).bold().create());
|
|
|
}
|
|
|
}
|
|
|
if(ticket.getWorkUnit()!=null){
|
|
@@ -391,12 +564,6 @@ public class TInvoiceBookingworkticketController extends BaseController
|
|
|
contentUserWorkType.delete(0, contentUserWorkType.length());
|
|
|
}
|
|
|
// 渲染文本
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return params;
|
|
|
};
|
|
|
|