瀏覽代碼

现在文件修改

guozx 3 年之前
父節點
當前提交
e1b65a972e
共有 1 個文件被更改,包括 9 次插入10 次删除
  1. 9 10
      application-facade/src/main/java/com/factory/web/service/impl/FileServiceImpl.java

+ 9 - 10
application-facade/src/main/java/com/factory/web/service/impl/FileServiceImpl.java

@@ -21,10 +21,7 @@ import com.factory.web.service.pm.PreventMistakeService;
 import org.apache.poi.hssf.usermodel.HSSFCellStyle;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.functions.Index;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
@@ -97,7 +94,7 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
             rs.add(datas);
         } else {
             Optional<OnsiteCalendar> cal = plan.getOnsiteCalendarList().stream().filter(s -> s.getTypeFlag() .equals(param.getTypeFlag()) ).findFirst();
-            String userNm = getUserName(cal.get() == null ? null : cal.get().getUserId());
+            String userNm = getUserName(!cal.isPresent() ? null : cal.get().getUserId());
             String[] datas = null;
             for (PmCheckRecordListRes res : check) {
                 for (PmCheckRecordItemListRes item : res.getItemList()) {
@@ -147,8 +144,8 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
         u2 = approvals.stream().filter(s -> s.getApprovalLevel() == 2).findFirst();
         return new String[]{
                 String.format("Edited By:%s", getUserName(plan.getCreatedUserId())),
-                String.format("Checked By:%s", getUserName(u1 != null ? u1.get().getApprovalUserId() : null)),
-                String.format("Approved By:%s", getUserName(u2 != null ? u2.get().getApprovalUserId() : null)),
+                String.format("Checked By:%s", getUserName(u1.isPresent() ? u1.get().getApprovalUserId() : null)),
+                String.format("Approved By:%s", getUserName(u2.isPresent()? u2.get().getApprovalUserId() : null)),
         };
     }
 
@@ -174,11 +171,11 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
         String[] dates = param.getYearMonth().split("\\-");
         String setter = String.format("Setter/Jumper:%s", "");
         if (!iscontroll) {
-            setter = String.format("Setter/Jumper:%s", getUserName(cal.get() == null ? null : cal.get().getUserId()));
+            setter = String.format("Setter/Jumper:%s", getUserName(!cal.isPresent() ? null : cal.get().getUserId()));
         }
         return new String[]{
                 String.format("Production line:%s", plan.getOnsiteTitle() != null ? plan.getOnsiteTitle().getProductionLine() : ""),
-                String.format("Shift:%s", cal.get().getShift()),
+                String.format("Shift:%s", !cal.isPresent() ? "" : cal.get().getShift()),
                 setter,
                 String.format("Year:%s", dates[0]),
                 String.format("Month:%s", dates[1])
@@ -380,11 +377,13 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, FileEntry> implemen
         Utility.addCellValForStr(row.getCell(21), data[2], Utility.getTitleCellStyle(wb, (short) 10, HorizontalAlignment.LEFT));
         ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
         ImageIO.write(bufferImg, "png", byteArrayOut);
-        XSSFDrawing patriarch = (XSSFDrawing) sheet.createDrawingPatriarch();
+        Drawing patriarch =  sheet.createDrawingPatriarch();
         XSSFClientAnchor anchor = new XSSFClientAnchor(10, 10, 255, 255,
                 (short) 28, 0, (short) 36, 2);
         patriarch.createPicture(anchor, wb.addPicture(byteArrayOut
                 .toByteArray(), HSSFWorkbook.PICTURE_TYPE_PNG));  // 插入图片
         byteArrayOut.close();
+
+
     }
 }