Explorar el Código

Merge remote-tracking branch 'origin/master' into master

yangyj hace 2 meses
padre
commit
d8f93ef019

+ 4 - 0
blade-common/src/main/java/org/springblade/common/constant/CommonConstant.java

@@ -89,5 +89,9 @@ public interface CommonConstant {
      * 接口权限类型
      */
     Integer API_SCOPE_CATEGORY = 2;
+    /**
+     * 请求头参数名
+     */
+    String HEADER_AUTHORIZATION = "authorization";
 
 }

+ 65 - 0
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -595,6 +595,71 @@ public class CommonUtil {
     }
 
 
+    /**
+     * 图片压缩
+     *
+     * @param imageData
+     * @return
+     * @throws IOException
+     * @throws ImageProcessingException
+     * @throws MetadataException
+     */
+    public static byte[] compressImage2(byte[] imageData) throws IOException {
+        // 缩放图像
+        String formatName = "JPEG";
+        ByteArrayInputStream bais = new ByteArrayInputStream(imageData);
+        BufferedImage originalImage = ImageIO.read(bais);
+        long sizeLimit = 102400; //358KB
+        int width = 1500;
+        int height = 400;
+        Image scaledImage = originalImage.getScaledInstance(width, height, Image.SCALE_SMOOTH);
+        BufferedImage resizedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+        resizedImage.getGraphics().drawImage(scaledImage, 0, 0, null);
+
+        // 压缩图像
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageIO.write(resizedImage, formatName, baos);
+
+        if (baos.size() <= sizeLimit) {
+            // 图片大小已经小于等于目标大小,直接返回原始数据
+            return baos.toByteArray();
+        }
+
+        float quality = 0.5f; // 初始化压缩质量
+        int retries = 10; // 最多尝试 10 次
+
+        while (baos.size() > sizeLimit && retries > 0) {
+            // 压缩图像并重新计算压缩质量
+            byte[] data = baos.toByteArray();
+            bais = new ByteArrayInputStream(data);
+            BufferedImage compressedImage = ImageIO.read(bais);
+            baos.reset();
+
+            ImageWriter writer = null;
+            Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName(formatName);
+            if (writers.hasNext()) {
+                writer = writers.next();
+            } else {
+                throw new IllegalArgumentException("Unsupported image format: " + formatName);
+            }
+
+            ImageWriteParam writeParam = writer.getDefaultWriteParam();
+            writeParam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+            writeParam.setCompressionQuality(quality);
+
+            writer.setOutput(ImageIO.createImageOutputStream(baos));
+            writer.write(null, new IIOImage(compressedImage, null, null), writeParam);
+            writer.dispose();
+
+            float ratio = sizeLimit * 1.0f / baos.size();
+            quality *= Math.sqrt(ratio);
+            retries--;
+        }
+
+        return baos.toByteArray();
+    }
+
+
     /**
      * 根据起止日期获取工作日
      * @return

+ 64 - 0
blade-ops/blade-resource/src/main/java/org/springblade/resource/endpoint/OssEndpoint.java

@@ -21,6 +21,8 @@ import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.apache.commons.lang.StringUtils;
 import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.poi.util.IOUtils;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.oss.model.BladeFile;
@@ -198,6 +200,68 @@ public class OssEndpoint {
         return R.data(newBladeFile);
     }
 
+    /**
+     * 上传文件(兼容工程文件需求)
+     */
+    @SneakyThrows
+    @PostMapping("/upload-image-and-zip")
+    public  R<NewBladeFile> uploadImageAndZip(@RequestParam MultipartFile file) {
+        //处理PDF文件
+        NewBladeFile newBladeFile = new NewBladeFile();
+        if (Objects.requireNonNull(file.getOriginalFilename()).contains("xlsx")) {
+            newBladeFile = this.commonFileClient.excelToPdf(file);
+
+        } else if (file.getOriginalFilename().contains("xls")) {
+            newBladeFile = this.commonFileClient.excelToPdf(file);
+
+        } else if (file.getOriginalFilename().contains("docx")) {
+            newBladeFile = this.commonFileClient.wordToPdf(file);
+
+        } else if (file.getOriginalFilename().contains("png") || file.getOriginalFilename().contains("jpg")) {
+            newBladeFile = this.commonFileClient.pngOrJpgToPdf(file);
+
+        }else  if (file.getOriginalFilename().contains("pdf") || file.getOriginalFilename().contains("PDF")) {
+            newBladeFile.setPdfUrl("7");
+        }
+        if (newBladeFile == null || StringUtils.isBlank(newBladeFile.getPdfUrl())){
+            throw  new ServiceException("图片转换PDF失败");
+        }
+        long start1 = System.currentTimeMillis();
+        byte[] bytes = CommonUtil.compressImage2(IOUtils.toByteArray(file.getInputStream()));
+        long start2 = System.currentTimeMillis();
+        System.out.println(start2 - start1);
+        //上传原图
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
+        BladeFile bladeFile = ossBuilder.template().putFile(file.getOriginalFilename(), inputStream);
+        if (file.getOriginalFilename().contains("pdf") || file.getOriginalFilename().contains("PDF")) {
+            //获取PDF文件
+            PDDocument document = PDDocument.load(file.getInputStream());
+            //获取文件页数
+            newBladeFile.setPage(document.getPages().getCount());
+            //pdf的路径就是文件上传的路径
+            newBladeFile.setPdfUrl(bladeFile.getLink());
+        }
+
+        BeanUtils.copyProperties(bladeFile, newBladeFile);
+        newBladeFile.setFileSize(file.getSize() / 1024);
+        newBladeFile.setFileSizeName(formatSize(file.getSize()));
+        newBladeFile.setFileDate(LocalDateTime.now());
+        newBladeFile.setFileSuffix(bladeFile.getOriginalName().substring(bladeFile.getOriginalName().lastIndexOf(".")+1));
+
+        //入库
+        String fileExtension = FileUtil.getFileExtension(bladeFile.getOriginalName());
+        Attach attach = new Attach();
+        attach.setDomainUrl(bladeFile.getDomain());
+        attach.setLink(newBladeFile.getPdfUrl());
+        attach.setName(bladeFile.getName());
+        attach.setOriginalName(bladeFile.getOriginalName());
+        attach.setAttachSize(newBladeFile.getFileSize());
+        attach.setExtension(fileExtension);
+        attachService.save(attach);
+
+        return R.data(newBladeFile);
+    }
+
     /**
      * 上传文件(兼容工程文件需求)
      */

+ 19 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/CheckRemoveBussTabInfoVo.java

@@ -0,0 +1,19 @@
+package org.springblade.manager.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@NotNull
+@AllArgsConstructor
+public class CheckRemoveBussTabInfoVo {
+    //是否提示强制删除
+    private Boolean isForceDelete;
+    //删除信息
+    private String msg;
+    //删除的表单pKeyId
+    private Long pKeyId;
+
+}

+ 1 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/WbsTreePrivateVO4.java

@@ -63,5 +63,6 @@ public class WbsTreePrivateVO4 implements Serializable {
     private Integer isCopyTab;
 
     private String loadDataId;
+    private Long entrustId;
 
 }

+ 76 - 3
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
-import io.swagger.annotations.*;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.springblade.business.dto.*;
@@ -17,7 +20,6 @@ import org.springblade.business.service.ITrialSampleInfoService;
 import org.springblade.business.service.ITrialSelfInspectionRecordService;
 import org.springblade.business.utils.FileUtils;
 import org.springblade.business.vo.*;
-import org.springblade.common.constant.CommonConstant;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
@@ -29,10 +31,10 @@ import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.entity.TrialSelfDataRecord;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.feign.WbsTreePrivateClient;
+import org.springblade.manager.vo.CheckRemoveBussTabInfoVo;
 import org.springblade.manager.vo.TableFileVO;
 import org.springblade.manager.vo.WbsTreePrivateVO;
 import org.springblade.resource.feign.NewIOSSClient;
-import org.springblade.system.cache.ParamCache;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -457,4 +459,75 @@ public class TrialDetectionController extends BladeController {
     public R getSamplePdfUrl1(String testId,String contractId){
         return iTrialSelfInspectionRecordService.getSamplePdfUrl(testId,contractId);
     }
+
+    /**
+     * 强制删除自检复制的表前的校验及提示
+     * @param pKeyId
+     * @return
+     */
+    @PostMapping("/self/remove-buss-tab-check")
+    @ApiOperationSupport(order = 29)
+    @ApiOperation(value = "检查自检删除复制的表", notes = "传入节点pKeyId")
+    public R<CheckRemoveBussTabInfoVo> checkRemoveBussTabInfo(@RequestParam Long pKeyId) {
+        //查询当前表是否已经填报
+        List<TrialSelfDataRecord> query = jdbcTemplate.query("select record_id from u_trial_self_data_record where tab_id = " + pKeyId, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class));
+        if (query.size() > 0) {
+            WbsTreePrivate tab = wbsTreePrivateClient.queryByPKeyIds(Collections.singletonList(pKeyId + "")).stream().findAny().orElse(null);
+            List<String> names = new ArrayList<>();
+            if (tab != null) {
+                if (tab.getTableType().equals(1) || tab.getTableType().equals(9)) {
+                    List<Long> recordIds = query.stream().map(TrialSelfDataRecord::getRecordId).collect(Collectors.toList());
+                    List<TrialSelfInspectionRecord> recordList = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, recordIds));
+                    for (TrialSelfInspectionRecord record : recordList) {
+                        StringBuilder stringBuilder = new StringBuilder();
+                        if (StringUtils.isNotEmpty(record.getRecordNo())) {
+                            stringBuilder.append(record.getRecordNo());
+                        }
+                        names.add(stringBuilder.toString());
+                    }
+                    CheckRemoveBussTabInfoVo checkRemoveBussTabInfoVo = new CheckRemoveBussTabInfoVo(
+                            false,
+                            "当前表在试验记录【记录编号:" + org.apache.commons.lang.StringUtils.join(names, ",") + "】中有填报数据,是否确认删除?",
+                            pKeyId);
+                    return R.data(checkRemoveBussTabInfoVo);
+                }
+                if (tab.getTableType().equals(2) || tab.getTableType().equals(10)) {
+                    List<Long> recordIds = query.stream().map(TrialSelfDataRecord::getRecordId).collect(Collectors.toList());
+                    List<TrialSelfInspectionRecord> recordList = iTrialSelfInspectionRecordService.getBaseMapper().selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().in(TrialSelfInspectionRecord::getId, recordIds));
+                    for (TrialSelfInspectionRecord record : recordList) {
+                        StringBuilder stringBuilder = new StringBuilder();
+                        if (StringUtils.isNotEmpty(record.getReportNo())) {
+                            stringBuilder.append(record.getReportNo());
+                        }
+                        names.add(stringBuilder.toString());
+                    }
+                    CheckRemoveBussTabInfoVo checkRemoveBussTabInfoVo = new CheckRemoveBussTabInfoVo(
+                            false
+                            , "当前表在试验记录【报告编号:" + org.apache.commons.lang.StringUtils.join(names, ",") + "】中有填报数据,是否确认删除?"
+                            , pKeyId);
+                    return R.data(checkRemoveBussTabInfoVo);
+                }
+            }
+            return R.fail("未获取到当前表的信息,删除失败");
+        } else {
+            CheckRemoveBussTabInfoVo checkRemoveBussTabInfoVo = new CheckRemoveBussTabInfoVo(
+                    true
+                    , null
+                    , pKeyId);
+            return R.data(checkRemoveBussTabInfoVo);
+        }
+    }
+
+    /**
+     * 强制删除自检复制的表(已经经过校验后)
+     * @param pKeyId
+     * @return
+     */
+    @PostMapping("/self/remove-buss-tab-force")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "强制删除自检复制的表(已经经过校验后)", notes = "传入节点pKeyId")
+    public R<String> removeBussTabInfoByForce(@RequestParam Long pKeyId) {
+        jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
+        return R.success("删除成功");
+    }
 }

+ 18 - 15
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -989,7 +989,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         if (ObjectUtil.isNotEmpty(dto.getId())) {
             //------获取最新试验记录------
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
-            //如果传递了就修改对应记录的值
+            //如果传递了编号就修改对应记录的值 以第一张表的数据为准
             this.updateRecordNoOrReportNo(obj, dto);
             //------编辑时记录表编号或报告单编号为Null的重新生成------
             if(this.judgingParameters(dto)){
@@ -1024,9 +1024,9 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
      * @param dto
      */
     private void updateRecordNoOrReportNo(TrialSelfInspectionRecord obj, TrialSelfInspectionRecordDTO dto) {
-        JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
-        for (int i = 0; i < dataArray.size(); i++) {
-            JSONObject jsonObject = dataArray.getJSONObject(i);
+            JSONArray dataArray = dto.getDataInfo().getJSONArray("orderList");
+            //获取第一张表的数据  编号以第一张表为准
+            JSONObject jsonObject = dataArray.getJSONObject(0);
             String pkeyId = jsonObject.getString("pkeyId");
             String sql = "select * from m_wbs_tree_private where p_key_id =" + pkeyId;
             WbsTreePrivate table = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
@@ -1037,21 +1037,21 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
                 Document doc = Jsoup.parse(htmlString);
                 // 查找所有具有 placeholderxx 属性的元素
-                //表类型 1=记录表 2=报告单 ,字符串拼接
-                String tableType = dto.getTableType();
-                String[] singleTableType = tableType.split(",");
-                if("1".equals(singleTableType[i])){
-                    //记录表
-                    this.updateRecordNoOrReportNo(dto,jsonObject,doc,"记录编 号:","record_no");
-                    this.updateRecordNoOrReportNo(dto,jsonObject,doc,"记录编号:","record_no");
-                }else if("2".equals(singleTableType[i])){
+                //表类型 9=记录表 10=报告单
+                if(table.getTableType() == 9){
+                    //记录表  以第一张表为准
+                     this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编 号:", "record_no");
+                     this.updateRecordNoOrReportNo(dto, jsonObject, doc, "记录编号:", "record_no");
+                }else if(table.getTableType() == 10){
                     //报告单
                     this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
+                    //:不一样 一个中文一个英文
+                    this.updateRecordNoOrReportNo(dto,jsonObject,doc,"报告编号:","report_no");
                 }
             } catch (Exception e) {
                 log.error(e.getMessage());
             }
-        }
+
     }
 
     /**
@@ -1072,14 +1072,17 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                 String htmlString = IoUtil.readToString(fileInputStream);
                 htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
                 Document doc = Jsoup.parse(htmlString);
-                //可能出现的几种情况 4种情况 记录编 号: 记录编号: 报告编号: 编号:
+                //可能出现的几种情况 4种情况 记录编 号: 记录编号: 报告编号: 报告编号: 编号:
                 Elements elementsWithPlaceholderxx = doc.select("[placeholderxx='记录编 号:']");
                 if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
                     elementsWithPlaceholderxx = doc.select("[placeholderxx='记录编号:']");
                     if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
                         elementsWithPlaceholderxx = doc.select("[placeholderxx='报告编号:']");
                         if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
-                            elementsWithPlaceholderxx = doc.select("[placeholderxx='编号:']");
+                            elementsWithPlaceholderxx = doc.select("[placeholderxx='报告编号:']");
+                            if(elementsWithPlaceholderxx.size() == 0 || elementsWithPlaceholderxx == null){
+                                elementsWithPlaceholderxx = doc.select("[placeholderxx='编号:']");
+                            }
                         }
                     }
                 }

+ 10 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreePrivateController.java

@@ -6,6 +6,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import com.mixsmart.utils.StringUtils;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
+import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.vo.SaveLogContractVO;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.boot.ctrl.BladeController;
@@ -666,6 +667,13 @@ public class WbsTreePrivateController extends BladeController {
     @ApiOperationSupport(order = 22)
     @ApiOperation(value = "试验-根据所属方查询当前节点表信息", notes = "传入节点primaryKeyId、所属方type=1施工/=2监理、表单类型tableType=1记录表/=2报告单、合同段id、项目id、isAdd=是否新增、试验记录id")
     public R<List<WbsTreePrivateVO4>> searchNodeAllTable(String primaryKeyId, String type, String tableType, String contractId, String projectId, Integer isAdd, Long id) {
+       // 获取试验记录信息实体 从而获取委托单编号
+        TrialSelfInspectionRecord trialSelfInspectionRecord = null;
+        if(ObjectUtil.isNotEmpty(id)){
+            String sqlForInspectionRecord = "select entrust_id from u_trial_self_inspection_record  where id=" + id;
+            trialSelfInspectionRecord = jdbcTemplate.queryForObject(sqlForInspectionRecord, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
+        }
+
         List<WbsTreePrivateVO4> wbsTreePrivateVO4s = wbsTreePrivateService.searchNodeAllTable(primaryKeyId, type, tableType, contractId, projectId, isAdd, id);
         for (WbsTreePrivateVO4 treePrivate : wbsTreePrivateVO4s) {
             //试验新增
@@ -679,6 +687,8 @@ public class WbsTreePrivateController extends BladeController {
 
             //试验编辑
             else if (ObjectUtil.isNotEmpty(id)) {
+                //返回委托单id
+                treePrivate.setEntrustId(trialSelfInspectionRecord.getEntrustId());
                 //获取当前试验记录信息中表的按钮状态
                 String sql = "select tab_id,is_buss_show,is_tab_pdf,is_tab_file_type from u_trial_self_data_record where record_id = " + id;
                 Map<Long, TrialSelfDataRecord> map = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TrialSelfDataRecord.class)).stream().collect(Collectors.toMap(TrialSelfDataRecord::getTabId, Function.identity()));

+ 0 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/WbsTreePrivateMapper.java

@@ -3,7 +3,6 @@ package org.springblade.manager.mapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.springblade.manager.dto.WbsTreePrivateDTO2;
-import org.springblade.manager.dto.WbsTreePrivateDTO3;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.injector.EasyBaseMapper;
 import org.springblade.manager.vo.*;

+ 65 - 28
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -4537,9 +4537,14 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
     }
 
     private static void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization, EntrustInfo entrustInfo) {
-        if(entrustInfo != null){
-            setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
-        }
+        String representativeCount = sampleInfo.getRepresentativeCount();
+        String calculationUnit = sampleInfo.getCalculationUnit();
+        Date mobilizationDate = sampleInfo.getMobilizationDate();
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        String format = simpleDateFormat.format(mobilizationDate);
+
+        setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
+        setFirstData(doc,"生产批号",sampleInfo.getBatchNumber(),reData);
         setFirstData(doc,"样品编号",sampleInfo.getSpecificationNumber(),reData);
         setFirstData(doc,"取样地点",sampleInfo.getSamplingLocation(),reData);
         setFirstData(doc,"样品描述",sampleInfo.getSampleDescription(),reData);
@@ -4547,53 +4552,85 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         setFirstData(doc,"取样日期",sampleInfo.getSamplingDate(),reData);
         setFirstData(doc,"试样名称",sampleInfo.getMaterialName(),reData);
         setFirstData(doc,"样品名称",sampleInfo.getMaterialName(),reData);
+        setFirstData(doc,"材料名称",sampleInfo.getMaterialName(),reData);
         setFirstData(doc,"规格 型号",sampleInfo.getSpecificationModel(),reData);
         setFirstData(doc,"规格型号",sampleInfo.getSpecificationModel(),reData);
+        setFirstData(doc,"材料规格",sampleInfo.getSpecificationModel(),reData);
         setFirstData(doc,"试样 数量",sampleInfo.getMaterialCount(),reData);
+        setFirstData(doc,"试样数量",sampleInfo.getMaterialCount(),reData);
+        setFirstData(doc,"代表数量",sampleInfo.getMaterialCount(),reData);
+        setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
+        setFirstData(doc,"拟用结构部位",sampleInfo.getProposedPosition(),reData);
+        setFirstData(doc,"用途(使用在何工程部位)",sampleInfo.getProposedPosition(),reData);
+        setFirstData(doc,"进场日期代表数量",format+"/"+representativeCount+calculationUnit,reData);
+        setFirstData(doc,"材料进场日期",format,reData);
+
+        if(entrustInfo != null){
+            setFirstData(doc,"委托编号",entrustInfo.getEntrustNo(),reData);
+            setFirstData(doc,"本批材料数量",entrustInfo.getExpCount()+calculationUnit,reData);
+        }
         if(trialMaterialMobilization != null){
             setFirstData(doc,"生产厂家",trialMaterialMobilization.getPlaceOfProduction(),reData);
+            setFirstData(doc,"供应商",trialMaterialMobilization.getPlaceOfProduction(),reData);
         }
-        String representativeCount = sampleInfo.getRepresentativeCount();
-        String calculationUnit = sampleInfo.getCalculationUnit();
-        Date mobilizationDate = sampleInfo.getMobilizationDate();
-        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
-        String format = simpleDateFormat.format(mobilizationDate);
-        setFirstData(doc,"批号",sampleInfo.getBatchNumber(),reData);
-        setFirstData(doc,"拟用结构部 位",sampleInfo.getProposedPosition(),reData);
-        setFirstData(doc,"进场日期代表数量",format+"/"+representativeCount+calculationUnit,reData);
     }
+
+    /**
+     * 指定条件查找元素
+     * @param doc
+     * @param elementValue
+     * @param value
+     * @param reData
+     */
     private static void setFirstData(Document doc, String elementValue,Object value,Map<String, Object> reData) {
 
         Elements select = doc.select("[placeholderxx=" + elementValue + "]");
-        if(select.isEmpty()){
-            elementValue = elementValue + ":";
-            select = doc.select("[placeholderxx=" + elementValue + "]");
+
+        if(select.isEmpty()){//没找到加上:继续找
+            String elementValueNew = elementValue + ":";
+            select = doc.select("[placeholderxx=" + elementValueNew + "]");
+        }
+        if(select.isEmpty()){// 以传入的参数为结尾 继续找
+            select = doc.select("[placeholderxx$=" + elementValue + "]");
         }
-        if (!select.isEmpty()) {
+
+        if (!select.isEmpty()) {//找到元素后  获取输入框
+
             Element textareaElement = select.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
-            if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){
+            if( (elementValue.contains("时间") || elementValue.contains("日期")) && textareaElement == null){//特殊处理日期 没有id属性获取keyName
                 textareaElement = select.first();
                 String keyName = textareaElement.attr("keyName");
                 reData.put(keyName, value);
                 return;
             }
-            if(textareaElement != null){
+            if(textareaElement != null){//正常情况
                 String id = textareaElement.attr("id");
                 reData.put(id, value);
             }
-        } else {
-            if(elementValue.equals("进场日期代表数量")){
-                Elements select1 = doc.select("[titlexx=\"进场日期/ 代表数量\"]");
-                Element textareaElement = select1.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
-                if(textareaElement != null){
-                    List<Node> nodes = textareaElement.childNodes();
-                    Node node = nodes.get(1);
-                    String id = node.attributes().get("id");
-                    reData.put(id, value);
+
+        } else {// 没有找到 可能格式不同 换一种方式找
+            Elements select2 = doc.select("[titlexx$="+elementValue+"]");
+            if(select2.isEmpty()){//还是没找到  进入特殊情况
+                if(elementValue.equals("进场日期代表数量")){
+                    Elements select1 = doc.select("[titlexx=\"进场日期/ 代表数量\"]");
+                    Element textareaElement = select1.stream().filter(element -> element.tagName().equals("el-input")).findFirst().orElse(null);
+                    if(textareaElement != null){
+                        List<Node> nodes = textareaElement.childNodes();
+                        Node node = nodes.get(1);
+                        String id = node.attributes().get("id");
+                        reData.put(id, value);
+                    }
+                }else {
+                    System.out.println("没有找到[" + elementValue + "]的元素");
                 }
-//                Element textareaElement = select1.first();
             }else {
-                System.out.println("没有找到[" + elementValue + "]的元素");
+                //另一种方式找到后 获取id的值并赋值到map
+                Element textareaElement = select2.first();
+
+                if(textareaElement != null){//正常情况
+                    String id = textareaElement.attr("id");
+                    reData.put(id, value);
+                }
             }
         }
     }

+ 29 - 8
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -1,7 +1,8 @@
 package org.springblade.manager.service.impl;
 
+import cn.hutool.json.JSONArray;
+import cn.hutool.json.JSONUtil;
 import cn.hutool.log.StaticLog;
-import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -40,7 +41,6 @@ import org.springblade.manager.utils.FileUtils;
 import org.springblade.manager.vo.*;
 import org.springblade.system.cache.ParamCache;
 import org.springframework.beans.BeanUtils;
-import org.springframework.cache.annotation.Cacheable;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.scheduling.annotation.Async;
@@ -48,21 +48,18 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.validation.constraints.NotNull;
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.sql.Timestamp;
-import java.sql.Types;
 import java.time.LocalDateTime;
-import java.io.*;
 import java.util.*;
 import java.util.function.BiPredicate;
 import java.util.function.BinaryOperator;
 import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.stream.IntStream;
 
 @Service
 @AllArgsConstructor
@@ -224,10 +221,34 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
 
     @Override
     public List<WbsTreePrivateVO> lazyTree(String wbsId, String wbsType, Long parentId, String projectId) {
-        List<WbsTreePrivateVO> wbsTreePrivateVOS = baseMapper.lazyTree(wbsId, Integer.valueOf(wbsType), parentId, projectId);
+        //获取请求头中的authorization
+        String headerAuthorization = getHeaderAuthorization();
+        List<WbsTreePrivateVO>  wbsTreePrivateVOS = baseMapper.lazyTree(wbsId, Integer.valueOf(wbsType), parentId, projectId);
+        //判断如果是客户端就进入分支 把包含委托单的节点删除
+        if(headerAuthorization != null && !"".equals(headerAuthorization) && headerAuthorization.contains("client_secret") && wbsTreePrivateVOS.size()>0){
+            JSONArray objects = JSONUtil.parseArray(wbsTreePrivateVOS);
+            List<TreeNodeVO> treeNodeVOS = JSONUtil.toList(objects, TreeNodeVO.class);
+            for (int i = 0; i < treeNodeVOS.size(); i++) {
+                if(treeNodeVOS.get(i).getTitle().contains("委托单")){
+                    wbsTreePrivateVOS.remove(i);
+                }
+            }
+        }
         return ForestNodeMerger.merge(wbsTreePrivateVOS);
     }
 
+        private static String getHeaderAuthorization() {
+        //获取请求头中的authorization
+        String authorization = WebUtil.getRequest().getHeader(CommonConstant.HEADER_AUTHORIZATION);
+        //解析获取请求头中的authorization
+        String[] split = authorization.split(" ");
+        String authorizationBody = split[1];
+        //base64解码
+        byte[] decode = Base64.getDecoder().decode(authorizationBody);
+        String string = new String(decode, StandardCharsets.UTF_8);
+        return string;
+    }
+
     @Override
     public IPage<TreeNodeVOByTabType> tabTypeLazyTree(IPage<TreeNodeVOByTabType> page, Long parentId, String projectId, String titleName) {
         if ((parentId + "").equals("12345678910")) {