liuyc %!s(int64=2) %!d(string=hai) anos
pai
achega
2212618dee

+ 48 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSamplingRecord.java

@@ -0,0 +1,48 @@
+package org.springblade.business.entity;
+
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+import java.util.Date;
+
+@Data
+@TableName("u_trial_sampling_record")
+@EqualsAndHashCode(callSuper = true)
+public class TrialSamplingRecord extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 样品编号
+     */
+    private String specificationNumber;
+
+    /**
+     * 样品名称
+     */
+    private String materialName;
+
+    /**
+     * 取样时间
+     */
+    private Date samplingDate;
+
+    /**
+     * 取样人
+     */
+    private Long userId;
+
+    /**
+     * 试样数量
+     */
+    private Integer materialCount;
+
+    /**
+     * 是否委外 '0'=否 '1'=是
+     */
+    private Integer isOutsourcing;
+
+}

+ 5 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreeVO.java

@@ -79,4 +79,9 @@ public class WbsTreeVO extends WbsTree implements INode<WbsTreeVO> {
 	 */
 	private String fullName;
 
+	/**
+	 * 试验配合比ids
+	 */
+	private String mixRatioTestIds;
+
 }

+ 21 - 10
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java

@@ -85,7 +85,7 @@ public class TrialMaterialController extends BladeController {
         return R.status(iTrialMaterialMobilizationService.mobilizationCopy(ids));
     }
 
-    @PostMapping("mobilization/import")
+    @PostMapping("/mobilization/import")
     @ApiOperationSupport(order = 7)
     @ApiOperation(value = "导入进场材料", notes = "传入excel")
     public R mobilizationImport(MultipartFile file, Integer isCovered) {
@@ -94,50 +94,50 @@ public class TrialMaterialController extends BladeController {
         return R.success("操作成功");
     }
 
-    @PostMapping("mobilization/export-pdf")
-    @ApiOperationSupport(order = 7)
+    @PostMapping("/mobilization/export-pdf")
+    @ApiOperationSupport(order = 8)
     @ApiOperation(value = "导出进场材料Pdf", notes = "传入ids")
     public void mobilizationExportPdf(@Valid @RequestParam String ids, HttpServletResponse response) {
         iTrialMaterialMobilizationService.mobilizationExportPdf(ids, response);
     }
 
     @GetMapping("/sample/detail")
-    @ApiOperationSupport(order = 8)
+    @ApiOperationSupport(order = 9)
     @ApiOperation(value = "材料取样详情", notes = "传入id")
     public R<TrialSampleInfo> sampleDetail(@Valid @RequestParam Long id) {
         return R.data(iTrialSampleInfoService.sampleDetail(id));
     }
 
     @GetMapping("/sample/page")
-    @ApiOperationSupport(order = 9)
+    @ApiOperationSupport(order = 10)
     @ApiOperation(value = "材料取样分页查询", notes = "传入page、TrialSampleInfoVO")
     public R<IPage<TrialSampleInfoVO>> mobilizationPage(Query query, TrialSampleInfoVO obj) {
         return R.data(iTrialSampleInfoService.selectPage(Condition.getPage(query), obj));
     }
 
     @PostMapping("/sample/submit")
-    @ApiOperationSupport(order = 10)
+    @ApiOperationSupport(order = 11)
     @ApiOperation(value = "材料取样新增或修改", notes = "传入TrialSampleInfo对象")
     public R<Object> sampleSubmit(@Valid @RequestBody TrialSampleInfo obj) {
         return R.status(iTrialSampleInfoService.sampleSubmit(obj));
     }
 
     @PostMapping("/sample/remove")
-    @ApiOperationSupport(order = 11)
+    @ApiOperationSupport(order = 12)
     @ApiOperation(value = "材料取样批量删除", notes = "传入ids")
     public R<Object> sampleRemove(@Valid @RequestParam String ids) {
         return R.status(iTrialSampleInfoService.deleteLogic(Func.toLongList(ids)));
     }
 
     @PostMapping("/sample/copy")
-    @ApiOperationSupport(order = 12)
+    @ApiOperationSupport(order = 13)
     @ApiOperation(value = "材料取样批量复制", notes = "传入ids")
     public R<Object> sampleCopy(@Valid @RequestParam String ids) {
         return R.status(iTrialSampleInfoService.sampleCopy(ids));
     }
 
-    @PostMapping("sample/import")
-    @ApiOperationSupport(order = 13)
+    @PostMapping("/sample/import")
+    @ApiOperationSupport(order = 14)
     @ApiOperation(value = "导入样品材料", notes = "传入excel")
     public R sampleImport(MultipartFile file, Integer isCovered) {
         TrialSampleInfoImporter trialSampleInfoImporter = new TrialSampleInfoImporter(iTrialSampleInfoService, isCovered == 1);
@@ -145,5 +145,16 @@ public class TrialMaterialController extends BladeController {
         return R.success("操作成功");
     }
 
+    @PostMapping("/sample/export-pdf")
+    @ApiOperationSupport(order = 15)
+    @ApiOperation(value = "导出取样材料Pdf", notes = "传入ids")
+    public void sampleExportPdf(@Valid @RequestParam String ids, HttpServletResponse response) {
+        iTrialSampleInfoService.sampleExportPdf(ids, response);
+    }
+
+
+
+
+
 
 }

+ 1 - 0
blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialMaterialMobilizationExcel.java

@@ -22,6 +22,7 @@ public class TrialMaterialMobilizationExcel implements Serializable {
     private Long id;
 
     @ExcelProperty(value = "记录人")
+    @ExcelIgnore
     private String userName;
 
     @ExcelProperty(value = "材料名称")

+ 10 - 0
blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialSampleInfoExcel.java

@@ -1,11 +1,13 @@
 package org.springblade.business.excel;
 
+import com.alibaba.excel.annotation.ExcelIgnore;
 import com.alibaba.excel.annotation.ExcelProperty;
 import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.alibaba.excel.annotation.write.style.ContentRowHeight;
 import com.alibaba.excel.annotation.write.style.HeadRowHeight;
 import lombok.Data;
 
+import javax.validation.Valid;
 import java.io.Serializable;
 import java.util.Date;
 
@@ -17,6 +19,14 @@ public class TrialSampleInfoExcel implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    @ExcelProperty(value = "id")
+    @ExcelIgnore
+    private Long id;
+
+    @ExcelProperty(value = "取样人")
+    @ExcelIgnore
+    private String userName;
+
     @ExcelProperty(value = "样品名称")
     private String materialName;
 

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSampleInfoService.java

@@ -6,6 +6,7 @@ import org.springblade.business.excel.TrialSampleInfoExcel;
 import org.springblade.business.vo.TrialSampleInfoVO;
 import org.springblade.core.mp.base.BaseService;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 public interface ITrialSampleInfoService extends BaseService<TrialSampleInfo> {
@@ -20,4 +21,6 @@ public interface ITrialSampleInfoService extends BaseService<TrialSampleInfo> {
 
     void importSample(List<TrialSampleInfoExcel> data, Boolean isCovered);
 
+    void sampleExportPdf(String ids, HttpServletResponse response);
+
 }

+ 14 - 6
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java

@@ -10,7 +10,7 @@ import com.lowagie.text.Paragraph;
 import com.lowagie.text.pdf.BaseFont;
 import com.lowagie.text.pdf.PdfPTable;
 import com.lowagie.text.pdf.PdfWriter;
-import com.sun.org.apache.regexp.internal.RE;
+import com.sun.javafx.tk.FontLoader;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
@@ -19,6 +19,7 @@ import org.springblade.business.excel.TrialMaterialMobilizationExcel;
 import org.springblade.business.mapper.TrialMaterialMobilizationMapper;
 import org.springblade.business.service.ITrialMaterialMobilizationService;
 import org.springblade.business.utils.PDFUtil;
+import org.springblade.business.utils.SystemUtils;
 import org.springblade.business.vo.TrialMaterialMobilizationVO;
 import org.springblade.business.wrapper.TrialMaterialMobilizationWarpper;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -37,17 +38,17 @@ import org.springframework.stereotype.Service;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
+import java.awt.*;
 import java.io.*;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 @Service
 @AllArgsConstructor
 public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialMaterialMobilizationMapper, TrialMaterialMobilization> implements ITrialMaterialMobilizationService {
 
-    private final static String SIMYOU_TTF = "classpath:templates/SIMYOU.TTF";
     private final IUserClient iUserClient;
 
     @Override
@@ -142,9 +143,16 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
 
             //创建文档,设置页面大小、左右上下边距
             Document document = new Document();
-
+            BaseFont bfChinese = null;
             //处理中文显示问题,使用资源字体
-            BaseFont bfChinese = BaseFont.createFont(SIMYOU_TTF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+            if (SystemUtils.isWindows()) {
+                //windows
+                bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+            }
+            if (SystemUtils.isLinux()) {
+                //linux
+                bfChinese = BaseFont.createFont("/usr/share/fonts/my-fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+            }
 
             //Font dateTitle = new Font(bfChinese, 7, Font.NORMAL);
             //Font title = new Font(bfChinese, 12, Font.BOLD);//文字加粗

+ 128 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java

@@ -2,13 +2,24 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.lowagie.text.Document;
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Font;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfPTable;
+import com.lowagie.text.pdf.PdfWriter;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
+import org.springblade.business.entity.TrialMaterialMobilization;
 import org.springblade.business.entity.TrialSampleInfo;
+import org.springblade.business.excel.TrialMaterialMobilizationExcel;
 import org.springblade.business.excel.TrialSampleInfoExcel;
 import org.springblade.business.mapper.TrialSampleInfoMapper;
 import org.springblade.business.service.ITrialSampleInfoService;
+import org.springblade.business.utils.PDFUtil;
+import org.springblade.business.utils.SystemUtils;
 import org.springblade.business.vo.TrialSampleInfoVO;
 import org.springblade.business.wrapper.TrialSampleInfoWarpper;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -16,12 +27,19 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.secure.utils.SecureUtil;
+import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -29,6 +47,8 @@ import java.util.List;
 @AllArgsConstructor
 public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoMapper, TrialSampleInfo> implements ITrialSampleInfoService {
 
+    private final IUserClient iUserClient;
+
     @Override
     public TrialSampleInfo sampleDetail(Long id) {
         return baseMapper.selectById(id);
@@ -90,5 +110,113 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
         }
     }
 
+    @Override
+    public void sampleExportPdf(String ids, HttpServletResponse response) {
+        try {
+            String fileName = java.net.URLEncoder.encode(DateUtil.time() + ".pdf", "UTF-8");
+            response.reset();
+            response.setContentType("application/pdf; name=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
+            response.setHeader("Content-Disposition", "inline; filename=" + java.net.URLEncoder.encode(fileName, "UTF-8"));
+            //构建字节输出流
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+
+            //构造数据
+            List<TrialSampleInfo> list = baseMapper.selectBatchIds(Func.toLongList(ids));
+            List<TrialSampleInfoExcel> pdfData = new ArrayList<>();
+            for (TrialSampleInfo trialSampleInfo : list) {
+                R<User> userR = iUserClient.userInfoById(trialSampleInfo.getUserId());
+                TrialSampleInfoExcel trialSampleInfoExcel = BeanUtil.copyProperties(trialSampleInfo, TrialSampleInfoExcel.class);
+                assert trialSampleInfoExcel != null;
+                trialSampleInfoExcel.setUserName(userR.getData().getName());
+                pdfData.add(trialSampleInfoExcel);
+            }
+
+            //创建文档,设置页面大小、左右上下边距
+            Document document = new Document();
+
+            BaseFont bfChinese = null;
+            //处理中文显示问题,使用资源字体
+            if (SystemUtils.isWindows()) {
+                //windows
+                bfChinese = BaseFont.createFont("C:/WINDOWS/Fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+            }
+            if (SystemUtils.isLinux()) {
+                //linux
+                bfChinese = BaseFont.createFont("/usr/share/fonts/my-fonts/SIMYOU.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
+            }
+
+            //Font dateTitle = new Font(bfChinese, 7, Font.NORMAL);
+            //Font title = new Font(bfChinese, 12, Font.BOLD);//文字加粗
+            Font textFont = new Font(bfChinese, 7, Font.NORMAL);//文字正常
+
+            //设置分页
+            PdfWriter.getInstance(document, byteArrayOutputStream);
+
+            //打开文档
+            document.open();
+
+            //标题
+            PdfPTable tableTitle = new PdfPTable(3);
+            //生成一个9列的表格
+            PdfPTable table = new PdfPTable(9);
+
+            //定义每个单元格的宽度
+            float[] widthsHeaderTitle = {1f, 1f, 1f};
+            float[] widthsHeader = {1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f, 1f};
+
+            float lineHeight = (float) 20.0;
+
+            //设置表格每一格的宽度
+            tableTitle.setWidths(widthsHeaderTitle);
+            table.setWidths(widthsHeader);
+
+            //设置表格总体宽度
+            tableTitle.setWidthPercentage(100);
+            table.setWidthPercentage(100);
+
+            int colSpan = 1;
+
+            /*SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date date = new Date(System.currentTimeMillis());
+            //添加标题
+            PDFUtil.createTableCellLeft("导出人:XXX", textFont, tableTitle, lineHeight, colSpan);
+            PDFUtil.createTableCellCenter("XXX表", title, tableTitle, lineHeight, colSpan);
+            PDFUtil.createTableCellRight(formatter.format(date), dateTitle, tableTitle, lineHeight, colSpan);*/
+
+            document.add(tableTitle);
+            document.add(new Paragraph("\n"));
+
+            String[] array = {"取样名称", "取样日期", "取样编号", "规格型号", "试样数量", "计算单位", "拟用部位", "代表数量","取样人"};
+            for (String s : array) {
+                PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
+            }
+            for (TrialSampleInfoExcel pdfDatum : pdfData) {
+                PDFUtil.createTableCell(pdfDatum.getMaterialName(), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(DateUtil.formatDate(pdfDatum.getSamplingDate()), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(pdfDatum.getSpecificationModel(), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(String.valueOf(pdfDatum.getMaterialCount()), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(pdfDatum.getCalculationUnit(), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(pdfDatum.getProposedPosition(), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(String.valueOf(pdfDatum.getRepresentativeCount()), textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(pdfDatum.getUserName(), textFont, table, lineHeight, colSpan);
+            }
+            document.add(table);
+            document.close();
+            try {
+                byteArrayOutputStream.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+
+            //输出
+            ServletOutputStream os = response.getOutputStream();
+            os.write(byteArrayOutputStream.toByteArray());
+
+        } catch (DocumentException | IOException e) {
+            e.printStackTrace();
+        }
+    }
+
 
 }

+ 48 - 0
blade-service/blade-business/src/main/java/org/springblade/business/utils/SystemUtils.java

@@ -0,0 +1,48 @@
+package org.springblade.business.utils;
+
+public class SystemUtils {
+
+    /**
+     * 判断操作系统是否是 Windows
+     *
+     * @return true:操作系统是 Windows
+     *         false:其它操作系统
+     */
+    public static boolean isWindows() {
+        String osName = getOsName();
+
+        return osName != null && osName.startsWith("Windows");
+    }
+
+    /**
+     * 判断操作系统是否是 MacOS
+     *
+     * @return true:操作系统是 MacOS
+     *         false:其它操作系统
+     */
+    public static boolean isMacOs() {
+        String osName = getOsName();
+
+        return osName != null && osName.startsWith("Mac");
+    }
+
+    /**
+     * 判断操作系统是否是 Linux
+     *
+     * @return true:操作系统是 Linux
+     *         false:其它操作系统
+     */
+    public static boolean isLinux() {
+        String osName = getOsName();
+
+        return (osName != null && osName.startsWith("Linux")) || (!isWindows() && !isMacOs());
+    }
+
+    /**
+     * 获取操作系统名称
+     * @return os.name 属性值
+     */
+    public static String getOsName() {
+        return System.getProperty("os.name");
+    }
+}

+ 0 - 3
blade-service/blade-business/src/main/resources/application-dev.yml

@@ -8,6 +8,3 @@ spring:
     url: ${blade.datasource.dev.url}
     username: ${blade.datasource.dev.username}
     password: ${blade.datasource.dev.password}
-
-  resources:
-    static-locations: classpath*:/templates

BIN=BIN
blade-service/blade-business/src/main/resources/templates/SIMYOU.TTF