Explorar o código

Merge branch 'refs/heads/dev' into lihb

LHB hai 4 semanas
pai
achega
cc8245a1a8
Modificáronse 22 ficheiros con 1207 adicións e 53 borrados
  1. 48 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrailDeviceUseInfoDTO.java
  2. 64 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSeleInspectionRecordBaseInfoDTO.java
  3. 94 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSeleInspectionRecordInfoDTO.java
  4. 8 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordDTO.java
  5. 2 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordPageDTO.java
  6. 20 2
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDeviceUse.java
  7. 5 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialMaterialMobilization.java
  8. 6 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSampleInfo.java
  9. 8 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSelfInspectionRecord.java
  10. 156 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialBaseInfo.java
  11. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  12. 294 6
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  13. 4 4
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.xml
  14. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml
  15. 2 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java
  16. 2 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/EntrustInfoServiceImpl.java
  17. 2 2
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java
  18. 13 7
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java
  19. 6 2
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java
  20. 244 14
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  21. 28 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java
  22. 199 11
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

+ 48 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrailDeviceUseInfoDTO.java

@@ -0,0 +1,48 @@
+package org.springblade.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.business.entity.TrialDeviceUse;
+
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TrailDeviceUseInfoDTO extends TrialDeviceUse {
+
+    /**
+     * 测量范围
+     */
+    @ApiModelProperty(value = "测量范围")
+    private String measuringRange;
+
+    /**
+     * 精准度
+     */
+    @ApiModelProperty(value = "精准度")
+    private String accuracy;
+
+
+    /**
+     * 使用时长
+     */
+    @ApiModelProperty(value = "使用时长,分")
+    private Long useDuration;
+
+    /**
+     * 使用日期
+     */
+    @ApiModelProperty(value = "使用日期")
+    private String useDate;
+
+    /**
+     * 使用开始时间
+     */
+    @ApiModelProperty(value = "使用开始时间")
+    private String useStartTime;
+    /**
+     * 使用结束时间
+     */
+    @ApiModelProperty(value = "使用结束时间")
+    private String useEndTime;
+
+}

+ 64 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSeleInspectionRecordBaseInfoDTO.java

@@ -0,0 +1,64 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.business.entity.TrialSampleInfo;
+import org.springblade.business.vo.StandardInfoDtoVo;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+public class TrialSeleInspectionRecordBaseInfoDTO implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty("委托单id")
+	private Long entrustId;
+
+	@ApiModelProperty("委托单编号")
+	private String entrustNo;
+	/**
+	 * 项目名称
+	 */
+	@ApiModelProperty("项目名称")
+	private String projectName;
+	/**
+	 * 施工单位
+	 */
+	@ApiModelProperty("施工单位")
+	private String constructionUnit;
+	/**
+	 * 监理单位
+	 */
+	@ApiModelProperty("监理单位")
+	private String supervisionUnit;
+
+    @ApiModelProperty("实验室名称")
+    private String labName;
+
+	@ApiModelProperty("合同段/工区")
+	private String contractName;
+
+	@ApiModelProperty("工程部位/用途")
+	private String projectPosition;
+
+	@ApiModelProperty("样品信息")
+	private TrialSampleInfo trialSampleInfo;
+}

+ 94 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSeleInspectionRecordInfoDTO.java

@@ -0,0 +1,94 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.business.entity.TrialSampleInfo;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+public class TrialSeleInspectionRecordInfoDTO extends TrialSeleInspectionRecordBaseInfoDTO {
+	private static final long serialVersionUID = 1L;
+
+	@ApiModelProperty("id")
+	private Long id;
+
+	@ApiModelProperty(value = "所属方类型 1=施工自检 2=监理抽检 3业主")
+	private Integer type;
+
+	@ApiModelProperty(value = "节点ID")
+	private Long nodeId;
+
+	@ApiModelProperty(value = "项目IDid")
+	private Long projectId;
+
+	@ApiModelProperty(value = "合同段id")
+	private Long contractId;
+
+	@ApiModelProperty("记录编号")
+	private String recordNo;
+
+	@ApiModelProperty("报告编号")
+	private String reportNo;
+
+	@ApiModelProperty(value = "记录表自增流水号")
+	private String recordAutoNumber;
+
+	@ApiModelProperty(value = "报告单自增流水号")
+	private String reportAutoNumber;
+
+	@ApiModelProperty("判断依据列表")
+	private List<StandardVo> standardVos;
+
+	@ApiModelProperty("判断依据:规范id")
+	private Long standardId;
+
+	@ApiModelProperty("规范信息ids")
+	private String standardInfoIds;
+
+	@ApiModelProperty("规范信息")
+	private List<StandardVo> standardInfos;
+
+
+	@ApiModelProperty("设备信息和使用信息")
+	private List<TrailDeviceUseInfoDTO> trailDeviceUseInfoDTOS;
+
+
+	@ApiModelProperty("样品信息")
+	private List<TrialSampleInfo> trialSampleInfoList;
+
+
+	private String oldRecordNumber;
+
+
+	private String oldReportNumber;
+
+	@Data
+	public static class StandardVo {
+		@ApiModelProperty("id")
+		private Long id;
+		@ApiModelProperty("name")
+		private String name;
+		@ApiModelProperty("value")
+		private String value;
+		private List<StandardVo> info;
+	}
+}

+ 8 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordDTO.java

@@ -40,4 +40,12 @@ public class TrialSelfInspectionRecordDTO extends TrialSelfInspectionRecord {
     @ApiModelProperty(value = "旧报告编号")
     private String oldReportNumber;
 
+    @ApiModelProperty("样品品种id")
+    private Long sampleVarietyId;
+
+    @ApiModelProperty("代号id")
+    private Long codeId;
+
+    @ApiModelProperty("强度等级id")
+    private Long strengthLevelId;
 }

+ 2 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordPageDTO.java

@@ -25,4 +25,6 @@ public class TrialSelfInspectionRecordPageDTO extends TrialSelfInspectionRecord
     @ApiModelProperty(value = "质检树的节点pKeyId")
     private String qualityTestPKeyId;
 
+    @ApiModelProperty(value = "排序类型, 1 记录/报告编号升序, 2 记录/报告编号降序, 3 规格型号升序, 4 规格型号降序")
+    private String sortType;
 }

+ 20 - 2
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDeviceUse.java

@@ -61,6 +61,12 @@ public class TrialDeviceUse extends BaseEntity {
     @ApiModelProperty(value = "检测项目-试验树节点id")
     private Long nodeId;
 
+    /**
+     * 检测项目-试验记录id
+     */
+    @ApiModelProperty(value = "试验记录id")
+    private Long selfInspectionRecordId;
+
     /**
      * 样品名称
      */
@@ -83,14 +89,14 @@ public class TrialDeviceUse extends BaseEntity {
      * 使用日期(起)
      */
     @ApiModelProperty(value = "使用日期(起)")
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date startDate;
 
     /**
      * 使用日期(止)
      */
     @ApiModelProperty(value = "使用日期(止)")
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date endDate;
 
     /**
@@ -111,4 +117,16 @@ public class TrialDeviceUse extends BaseEntity {
     @ApiModelProperty(value = "pdfURL")
     private String pdfUrl;
 
+    /**
+     * 运转前检查情况
+     */
+    @ApiModelProperty(value = "运转前检查情况")
+    private String beforeRunCheck;
+
+    /**
+     * 运转后检查情况
+     */
+    @ApiModelProperty(value = "运转前检查情况")
+    private String afterRunCheck;
+
 }

+ 5 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialMaterialMobilization.java

@@ -11,6 +11,7 @@ import org.springblade.core.mp.base.BaseEntity;
 import javax.validation.constraints.DecimalMax;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.Date;
 
@@ -27,6 +28,7 @@ public class TrialMaterialMobilization extends BaseEntity {
      * 合同段id
      */
     @ApiModelProperty(value = "合同段id")
+    @NotNull
     private Long contractId;
 
     /**
@@ -40,12 +42,14 @@ public class TrialMaterialMobilization extends BaseEntity {
      */
     @ApiModelProperty(value = "材料名称")
     @Length(max = 100, message = "材料名称最大长度100个字符")
+    @NotNull
     private String materialName;
 
     /**
      * 材料类型
      */
     @ApiModelProperty(value = "材料类型")
+    @NotNull
     private Integer materialType;
 
     /**
@@ -53,6 +57,7 @@ public class TrialMaterialMobilization extends BaseEntity {
      */
     @ApiModelProperty(value = "规格型号")
     @Length(max = 100, message = "规格型号最大长度100个字符")
+    @NotNull
     private String specificationModel;
 
     /**

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSampleInfo.java

@@ -69,6 +69,12 @@ public class TrialSampleInfo extends BaseEntity {
     @ApiModelProperty(value = "代表数量")
     private String representativeCount;
 
+    /**
+     * 代表单位
+     */
+    @ApiModelProperty(value = "代表单位")
+    private String representativeUnit;
+
     /**
      * 计算单位
      */

+ 8 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSelfInspectionRecord.java

@@ -80,5 +80,13 @@ public class TrialSelfInspectionRecord extends BaseEntity {
     @ApiModelProperty(value = "委托单Id")
     private Long entrustId;
 
+    @ApiModelProperty("判断依据:规范id")
+    private Long standardId;
+
+    @ApiModelProperty("规范信息")
+    private String standardInfoIds;
+
+    @ApiModelProperty("基础信息")
+    private String baseInfo;
 
 }

+ 156 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/TrialBaseInfo.java

@@ -0,0 +1,156 @@
+package org.springblade.manager.vo;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springblade.business.entity.TrialSampleInfo;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author yangyj
+ * @Date 2023/12/14 15:55
+ * @description 基础信息
+ */
+@Data
+public class TrialBaseInfo implements  DataModel{
+    public static final String ID="20370000000";
+    public static final String TBN="TBInfo";
+    public static final String TBN_CH="试验基础信息";
+    static final String UNKNOWN="未设置";
+    /**
+     * 项目名称/工程名称
+     */
+    @JSONField(name = "key_1",label="项目名称",ordinal = 1)
+    private String projectName;
+    /**
+     * 施工单位
+     */
+    @JSONField(name = "key_2",label="施工单位",ordinal = 2)
+    private String constructionUnit;
+
+    /**
+     * 监理单位
+     */
+    @JSONField(name = "key_3",label="监理单位",ordinal = 3)
+    private String supervisionUnit;
+
+    /**
+     * 实验室名称
+     */
+    @JSONField(name = "key_4",label="实验室名称",ordinal = 4)
+    private String labName;
+
+    /**
+     * 合同段/工区
+     */
+    @JSONField(name = "key_5",label="合同段/工区",ordinal = 5)
+    private String contractName;
+
+    /**
+     * 工程部位/用途
+     */
+    @JSONField(name = "key_6",label="工程部位/用途",ordinal = 6)
+    private String projectPosition;
+
+    /**
+     * 委托单编号
+     */
+    @JSONField(name = "key_7",label="委托单编号",ordinal = 7)
+    private String entrustNo;
+
+    /**
+     * 记录编号
+     */
+    @JSONField(name = "key_8",label="记录编号",ordinal = 8)
+    private String recordNo;
+
+    /**
+     * 报告编号
+     */
+    @JSONField(name = "key_9",label="报告编号",ordinal = 9)
+    private String reportNo;
+
+    /**
+     * 判断依据
+     */
+    @JSONField(name = "key_10",label="判断依据",ordinal = 10)
+    private String standard;
+
+    /**
+     * 样品名称
+     */
+    @JSONField(name = "key_11",label="样品名称",ordinal = 11)
+    private String materialName;
+
+    /**
+     * 样品编号
+     */
+    @JSONField(name = "key_12",label="样品编号",ordinal = 12)
+    private String specificationNumber;
+
+    /**
+     * 样品描述
+     */
+    @JSONField(name = "key_13",label="样品描述",ordinal = 13)
+    private String sampleDescription;
+
+    /**
+     * 来样/取样时间
+     */
+    @JSONField(name = "key_14",label="来样/取样时间",ordinal = 14)
+    private Date samplingDate;
+
+    /**
+     * 样品数量
+     */
+    @JSONField(name = "key_15",label="样品数量",ordinal = 15)
+    private String materialCount;
+
+    /**
+     * 样品数量
+     */
+    @JSONField(name = "key_16",label="强度等级",ordinal = 16)
+    private String designStrength;
+
+    public Object getValueByKey(String key) {
+        String keyPrefix = TBN + ":";
+        if ((keyPrefix + "key_1").equals( key)) {
+            return projectName;
+        } else if ((keyPrefix + "key_2").equals( key)) {
+            return constructionUnit;
+        } else if ((keyPrefix + "key_3").equals( key)) {
+            return supervisionUnit;
+        } else if ((keyPrefix + "key_4").equals( key)) {
+            return labName;
+        } else if ((keyPrefix + "key_5").equals( key)) {
+            return contractName;
+        } else if ((keyPrefix + "key_6").equals( key)) {
+            return projectPosition;
+        } else if ((keyPrefix + "key_7").equals( key)) {
+            return entrustNo;
+        } else if ((keyPrefix + "key_8").equals( key)) {
+            return recordNo;
+        } else if ((keyPrefix + "key_9").equals( key)) {
+            return reportNo;
+        } else if ((keyPrefix + "key_10").equals( key)) {
+            return standard;
+        } else if ((keyPrefix + "key_11").equals( key)) {
+            return materialName;
+        } else if ((keyPrefix + "key_12").equals( key)) {
+            return specificationNumber;
+        } else if ((keyPrefix + "key_13").equals( key)) {
+            return sampleDescription;
+        } else if ((keyPrefix + "key_14").equals(key)) {
+            return samplingDate;
+        } else if ((keyPrefix + "key_15").equals(key)) {
+            return materialCount;
+        } else if ((keyPrefix + "key_16").equals(key)) {
+            return designStrength;
+        }
+        return null;
+    }
+
+}

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1631,7 +1631,7 @@ public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
                             LocalDateTime now = LocalDateTime.now();
                             //格式化时间
                             String nowFormat = now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-                            String sql = "update u_entrust_info set status = 2 , entrust_time = '" + nowFormat + "' ,sample_status=1 where id = " + startTaskVO.getIds();
+                            String sql = "update u_entrust_info set status = 2 , entrust_time = '" + nowFormat + "' ,sample_status=1 where id in (" + startTaskVO.getIds() + ")";
                             jdbcTemplate.execute(sql);
                         }
                         var = true;

+ 294 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java

@@ -1,5 +1,6 @@
 package org.springblade.business.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -12,12 +13,9 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.springblade.business.dto.*;
-import org.springblade.business.entity.EntrustInfo;
-import org.springblade.business.entity.TrialDetectionData;
-import org.springblade.business.entity.TrialSelfInspectionRecord;
-import org.springblade.business.service.ITrialDetectionDataService;
-import org.springblade.business.service.ITrialSampleInfoService;
-import org.springblade.business.service.ITrialSelfInspectionRecordService;
+import org.springblade.business.entity.*;
+import org.springblade.business.service.*;
+import org.springblade.business.utils.DateUtils;
 import org.springblade.business.utils.FileUtils;
 import org.springblade.business.vo.*;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -26,8 +24,11 @@ import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.manager.entity.ContractInfo;
+import org.springblade.manager.entity.ProjectInfo;
 import org.springblade.manager.entity.TrialSelfDataRecord;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.feign.WbsTreePrivateClient;
@@ -40,9 +41,11 @@ import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -59,6 +62,8 @@ public class TrialDetectionController extends BladeController {
     private final WbsTreePrivateClient wbsTreePrivateClient;
     private final JdbcTemplate jdbcTemplate;
     private final NewIOSSClient newIOSSClient;
+    private final ITrialNumberRuleService trialNumberRuleService;
+    private final StandardInfoService uStandardInfoService;
 
     @GetMapping("/data/detail")
     @ApiOperationSupport(order = 1)
@@ -530,4 +535,287 @@ public class TrialDetectionController extends BladeController {
         jdbcTemplate.execute("delete from m_wbs_tree_private where p_key_id = " + pKeyId);
         return R.success("删除成功");
     }
+
+    /**
+     * 获取试验自检基础信息
+     */
+    @GetMapping("/self/getBaseInfo")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "获取试验自检基础信息", notes = "传入节点pKeyId")
+    public R<TrialSeleInspectionRecordInfoDTO> getBaseInfo(@RequestParam Long projectId, @RequestParam Long contractId, @RequestParam Long nodeId, @RequestParam(required = false) Long id, @RequestParam(required = false, defaultValue = "false") Boolean isReacquire) {
+        ProjectInfo projectInfo = jdbcTemplate.query("select * from m_project_info where id = " + projectId, new BeanPropertyRowMapper<>(ProjectInfo.class)).stream().findAny().orElse(null);
+        if (projectInfo == null) {
+            return R.fail("未获取到项目信息");
+        }
+        ContractInfo contractInfo = jdbcTemplate.query("select * from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
+        if (contractInfo == null) {
+            return R.fail("未获取到合同信息");
+        }
+        TrialSeleInspectionRecordInfoDTO vo = new TrialSeleInspectionRecordInfoDTO();
+        vo.setNodeId(nodeId);
+        vo.setContractId(contractId);
+        vo.setId(id);
+        vo.setProjectName(projectInfo.getProjectName());
+        vo.setConstructionUnit(contractInfo.getConstructionUnitName());
+        if (contractInfo.getContractType().equals(2)) {
+            List<ContractInfo> query = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
+            vo.setConstructionUnit(org.apache.commons.lang.StringUtils.join(query.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), "、"));
+        } else if (contractInfo.getContractType().equals(3)) {
+            List<ContractInfo> query = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 1", new BeanPropertyRowMapper<>(ContractInfo.class));
+            vo.setConstructionUnit(org.apache.commons.lang.StringUtils.join(query.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), "、"));
+            List<ContractInfo> query1 = jdbcTemplate.query("select contract_name from m_contract_info where is_deleted = 0 and p_id = " + projectId + " and contract_type = 2", new BeanPropertyRowMapper<>(ContractInfo.class));
+            vo.setSupervisionUnit(org.apache.commons.lang.StringUtils.join(query1.stream().map(ContractInfo::getContractName).collect(Collectors.toList()), "、"));
+        }
+        vo.setSupervisionUnit(contractInfo.getSupervisionUnitName());
+        vo.setLabName(contractInfo.getLaboratoryName());
+        vo.setContractName(contractInfo.getContractName());
+        if (id != null && !isReacquire) {
+            TrialSelfInspectionRecord record = jdbcTemplate.query("select * from u_trial_self_inspection_record where id = " + id, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
+            if (record != null) {
+                String baseInfo = record.getBaseInfo();
+                if (baseInfo != null) {
+                    TrialSeleInspectionRecordInfoDTO info = JSON.parseObject(baseInfo, TrialSeleInspectionRecordInfoDTO.class);
+                    if (info != null) {
+                        vo.setEntrustId(info.getEntrustId());
+                        vo.setEntrustNo(info.getEntrustNo());
+                        vo.setProjectName(info.getProjectName());
+                        vo.setConstructionUnit(info.getConstructionUnit());
+                        vo.setSupervisionUnit(info.getSupervisionUnit());
+                        vo.setLabName(info.getLabName());
+                        vo.setContractName(info.getContractName());
+                        vo.setProjectPosition(info.getProjectPosition());
+                        vo.setTrialSampleInfo(info.getTrialSampleInfo());
+                    }
+                }
+                // 取样
+                Long entrustId = record.getEntrustId();
+                if (vo.getEntrustNo() == null && entrustId != null) {
+                    EntrustInfo entrustInfo = jdbcTemplate.query("select * from u_entrust_info where id = " + entrustId, new BeanPropertyRowMapper<>(EntrustInfo.class)).stream().findAny().orElse(null);
+                    if (entrustInfo != null) {
+                        vo.setEntrustNo(entrustInfo.getEntrustNo());
+                        vo.setEntrustId(entrustInfo.getId());
+                    }
+                }
+                if (vo.getTrialSampleInfo() == null) {
+                    List<TrialSelfSample> selfSampleList = jdbcTemplate.query("select * from u_trial_self_sample where self_id = " + id, new BeanPropertyRowMapper<>(TrialSelfSample.class));
+                    if (!selfSampleList.isEmpty()) {
+                        String samplingIds = selfSampleList.stream().map(TrialSelfSample::getSamplingId).map(String::valueOf).collect(Collectors.joining(","));
+                        if (!samplingIds.isEmpty()) {
+                            List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id in (" + samplingIds + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+                            vo.setTrialSampleInfo(trialSampleInfoList.isEmpty() ? new TrialSampleInfo() : trialSampleInfoList.get(0));
+                        }
+                    }
+                }
+                if (vo.getProjectPosition() == null) {
+                    vo.setProjectPosition(record.getProjectPosition());
+                }
+                vo.setStandardId(record.getStandardId());
+                vo.setStandardInfoIds(record.getStandardInfoIds());
+                if (record.getStandardId() != null && record.getStandardInfoIds() != null && !record.getStandardInfoIds().isEmpty()) {
+                    List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, record.getStandardId()).eq(StandardInfo::getType, 1).eq(StandardInfo::getIsDeleted, 0));
+                    List<TrialSeleInspectionRecordInfoDTO.StandardVo> standardVos = new ArrayList<>();
+                    if (list != null && !list.isEmpty()) {
+                        Map<Long, List<StandardInfo>> map = list.stream().peek(standardInfo -> {
+                            if (standardInfo.getParentId() == null) {
+                                standardInfo.setParentId(0L);
+                            }
+                        }).collect(Collectors.groupingBy(StandardInfo::getParentId));
+                        List<StandardInfo> parentStandardInfos = map.get(0L);
+                        parentStandardInfos.forEach(standardInfo -> {
+                            TrialSeleInspectionRecordInfoDTO.StandardVo standardVo = new TrialSeleInspectionRecordInfoDTO.StandardVo();
+                            List<StandardInfo> standardInfos = map.get(standardInfo.getId());
+                            List<TrialSeleInspectionRecordInfoDTO.StandardVo> standardVoList = standardInfos.stream().map(item -> {
+                                TrialSeleInspectionRecordInfoDTO.StandardVo standardVo1 = new TrialSeleInspectionRecordInfoDTO.StandardVo();
+                                standardVo1.setId(item.getId());
+                                standardVo1.setName(item.getName());
+                                standardVo1.setValue("");
+                                return standardVo1;
+                            }).collect(Collectors.toList());
+                            TrialSeleInspectionRecordInfoDTO.StandardVo standardVo1 = standardVoList.stream().filter(item -> record.getStandardInfoIds().contains(item.getId() + "")).findFirst().orElse(null);
+                            if (standardVo1 != null) {
+                                standardVo.setValue(standardVo1.getId() + "");
+                            } else {
+                                standardVo.setValue("");
+                            }
+                            standardVo.setId(standardInfo.getId());
+                            standardVo.setName(standardInfo.getName());
+                            standardVo.setInfo(standardVoList);
+                            standardVos.add(standardVo);
+                        });
+
+                    }
+                    vo.setStandardInfos(standardVos);
+                }
+                vo.setReportNo(record.getReportNo());
+                vo.setRecordNo(record.getRecordNo());
+                // 获取设备信息和使用信息
+                List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where self_inspection_record_id = " + id, new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
+                if (!trialDeviceUseList.isEmpty()) {
+                    Set<Long> ids = trialDeviceUseList.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toSet());
+                    List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_trial_device_info where id in (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
+                    Map<Long, TrialDeviceInfo> trialDeviceInfoMap = deviceInfoList.stream().collect(Collectors.toMap(TrialDeviceInfo::getId, trailDeviceInfo -> trailDeviceInfo));
+                    trialDeviceUseList.forEach(trailDeviceUseInfoDTO -> {
+                        TrialDeviceInfo deviceInfo = trialDeviceInfoMap.get(trailDeviceUseInfoDTO.getDeviceInfoId());
+                        if (deviceInfo != null) {
+                            trailDeviceUseInfoDTO.setMeasuringRange(deviceInfo.getMeasuringRange());
+                            trailDeviceUseInfoDTO.setAccuracy(deviceInfo.getAccuracy());
+                            // 计算使用时长
+                            if (trailDeviceUseInfoDTO.getStartDate() != null && trailDeviceUseInfoDTO.getEndDate() != null) {
+                                trailDeviceUseInfoDTO.setUseDuration(DateUtils.dateDiff(trailDeviceUseInfoDTO.getStartDate(), trailDeviceUseInfoDTO.getEndDate()));
+                            }
+                            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+                            if (trailDeviceUseInfoDTO.getStartDate() != null) {
+                                // 从开始时间中获取日期
+                                trailDeviceUseInfoDTO.setUseDate(DateUtils.getDateStr(trailDeviceUseInfoDTO.getStartDate()));
+                                trailDeviceUseInfoDTO.setUseEndTime(sdf.format(trailDeviceUseInfoDTO.getStartDate()));
+                            }
+                            if (trailDeviceUseInfoDTO.getEndDate() != null) {
+                                trailDeviceUseInfoDTO.setUseStartTime(sdf.format(trailDeviceUseInfoDTO.getEndDate()));
+                            }
+                        }
+                    });
+                }
+                vo.setTrailDeviceUseInfoDTOS(trialDeviceUseList);
+            }
+        }
+        if (vo.getRecordNo() == null) {
+            Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId, contractId, 4, nodeId, true);
+            vo.setRecordNo(map.get("trialNumber"));
+            vo.setRecordAutoNumber(map.get("trialAutoNumber"));
+        }
+        if (vo.getReportNo() == null) {
+            Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId, contractId, 5, nodeId, true);
+            vo.setReportNo(map.get("trialNumber"));
+            vo.setReportAutoNumber(map.get("trialAutoNumber"));
+        }
+        List<TrialSeleInspectionRecordInfoDTO.StandardVo> mapList = jdbcTemplate.query("SELECT id,name from u_wbs_private_standard WHERE type = 2 and is_deleted = 0  and private_id = " + nodeId,
+                new BeanPropertyRowMapper<>(TrialSeleInspectionRecordInfoDTO.StandardVo.class));
+        vo.setStandardVos(mapList);
+        return R.data(vo);
+    }
+
+
+    @PostMapping("/self/saveBaseInfo")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "保存试验自检基础信息")
+    public R<Long> saveBaseInfo(@RequestBody TrialSeleInspectionRecordInfoDTO vo) {
+        return R.data(iTrialSelfInspectionRecordService.saveBaseInfo(vo));
+    }
+
+    @GetMapping("/self/getTrialSampleInfoByEntrustId")
+    @ApiOperation(value = "根据委托单查询样品信息")
+    public R<TrialSampleInfo> getTrialSampleInfoByEntrustId(@RequestParam Long entrustId) {
+        EntrustInfo entrustInfo = jdbcTemplate.query("select * from u_entrust_info where id = " + entrustId, new BeanPropertyRowMapper<>(EntrustInfo.class)).stream().findAny().orElse(null);
+        if (entrustInfo != null && entrustInfo.getSampleId() != null) {
+            List<TrialSampleInfo> trialSampleInfoList = jdbcTemplate.query("select * from u_trial_sample_info where id = (" + entrustInfo.getSampleId() + ")", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+            TrialSampleInfo sampleInfo = trialSampleInfoList.stream().findFirst().orElse(null);
+            return R.data(sampleInfo);
+        }
+        return R.data(null);
+    }
+
+    @GetMapping("/self/getEntrustInfoBySampleId")
+    @ApiOperation(value = "根据样品id查询关联的委托单信息")
+    public R<EntrustInfo> getEntrustInfoBySampleId(@RequestParam Long sampleId) {
+        EntrustInfo entrustInfo = jdbcTemplate.query("select * from u_entrust_info where sample_id = " + sampleId, new BeanPropertyRowMapper<>(EntrustInfo.class)).stream().findAny().orElse(null);
+        return R.data(entrustInfo);
+    }
+
+    /**
+     * 获取最近一次使用的设备信息
+     */
+    @GetMapping("/self/lastTrailDeviceInfo")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "获取上一次使用设备信息", notes = "传入节点pKeyId")
+    public R<List<TrialDeviceInfo>> getTrailDeviceInfo( @RequestParam Long contractId, @RequestParam Long nodeId) {
+        TrialSelfInspectionRecord record = iTrialSelfInspectionRecordService.getOne(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getId)
+                .eq(TrialSelfInspectionRecord::getContractId, contractId).eq(TrialSelfInspectionRecord::getNodeId, nodeId).last(" order by id desc limit 1"));
+        if (record == null) {
+            return R.data(new ArrayList<>());
+        }
+        List<TrialDeviceInfo> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_info WHERE id in ( select device_info_id from u_trial_device_use where self_inspection_record_id = ? and node_id = ?)" ,
+                new BeanPropertyRowMapper<>(TrialDeviceInfo.class), record.getId(), nodeId);
+        return R.data(trialDeviceUseList);
+    }
+
+    /**
+     * 根据standardId 查询 样品品种,代号和强度等级
+     */
+    @GetMapping("/self/getStandardInfoByStandardId")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "根据 standardId 查询 样品品种,代号和强度等级", notes = "standardId")
+    public R<List<StandardInfoDTO>> getStandardInfoByStandardId( @RequestParam Long standardId) {
+        List<StandardInfo> list = uStandardInfoService.list(Wrappers.<StandardInfo>lambdaQuery().eq(StandardInfo::getStandardId, standardId).eq(StandardInfo::getType, 1).eq(StandardInfo::getIsDeleted, 0));
+        if (list == null || list.isEmpty()) {
+            return R.data(new ArrayList<>());
+        }
+        Map<Long, List<StandardInfo>> map = list.stream().collect(Collectors.groupingBy(StandardInfo::getParentId));
+        List<StandardInfo> standardInfos = map.get(0L);
+        List<StandardInfoDTO> result = new ArrayList<>();
+        if (standardInfos != null) {
+            standardInfos.forEach(standardInfo -> {
+                StandardInfoDTO dto = BeanUtil.copy(standardInfo, StandardInfoDTO.class);
+                if (dto != null) {
+                    dto.setInfo(map.get(standardInfo.getId()));
+                    result.add(dto);
+                }
+            });
+        }
+        return R.data(result);
+    }
+
+    /**
+     * 根据 设备id 查询 设备信息以及设备使用信息
+     */
+    @GetMapping("/self/getDeviceInfoByIds")
+    @ApiOperationSupport(order = 30)
+    @ApiOperation(value = "根据 设备ids 查询 设备信息以及设备使用信息", notes = "deviceInfoIds")
+    public R<List<TrailDeviceUseInfoDTO>> getDeviceInfoByIds( @RequestParam String deviceInfoIds) {
+        if (deviceInfoIds.isEmpty()) {
+            return R.data(new ArrayList<>());
+        }
+        // 校验设备id
+        try {
+            String[] split = deviceInfoIds.split(",");
+            for (String s : split) {
+                long id = Long.parseLong(s);
+                if (id <= 0) {
+                    return R.fail("设备id格式错误");
+                }
+            }
+        } catch (Exception e) {
+            return R.fail("设备id格式错误");
+        }
+        List<TrialDeviceInfo> deviceInfoList = jdbcTemplate.query("select * from u_trial_device_info where id in (" + deviceInfoIds + ")", new BeanPropertyRowMapper<>(TrialDeviceInfo.class));
+        List<TrailDeviceUseInfoDTO> trailDeviceUseInfoDTOS = new ArrayList<>();
+        deviceInfoList.forEach(deviceInfo -> {
+            // 查询该设备最近一次的使用信息
+            List<TrailDeviceUseInfoDTO> trialDeviceUseList = jdbcTemplate.query("select * from u_trial_device_use where device_info_id = " + deviceInfo.getId() + " limit 1", new BeanPropertyRowMapper<>(TrailDeviceUseInfoDTO.class));
+            TrailDeviceUseInfoDTO dto = new TrailDeviceUseInfoDTO();
+            if (!trialDeviceUseList.isEmpty()) {
+                dto = trialDeviceUseList.get(0);
+                // 计算使用时长
+                if (dto.getStartDate() != null && dto.getEndDate() != null) {
+                    dto.setUseDuration(DateUtils.dateDiff(dto.getStartDate(), dto.getEndDate()));
+                }
+                SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
+                if (dto.getStartDate() != null) {
+                    dto.setUseEndTime(sdf.format(dto.getStartDate()));
+                }
+                if (dto.getEndDate() != null) {
+                    dto.setUseStartTime(sdf.format(dto.getEndDate()));
+                }
+            } else {
+                dto.setDeviceName(deviceInfo.getDeviceName());
+                dto.setDeviceNumber(deviceInfo.getDeviceNumber());
+                dto.setDeviceModel(deviceInfo.getDeviceModel());
+                dto.setRemarks(deviceInfo.getRemarks());
+                dto.setDeviceInfoId(deviceInfo.getId());
+            }
+            dto.setMeasuringRange(deviceInfo.getMeasuringRange());
+            dto.setAccuracy(deviceInfo.getAccuracy());
+            trailDeviceUseInfoDTOS.add(dto);
+        });
+        return R.data(trailDeviceUseInfoDTOS);
+    }
 }

+ 4 - 4
blade-service/blade-business/src/main/java/org/springblade/business/mapper/EntrustInfoMapper.xml

@@ -69,7 +69,7 @@
             and a.status = #{param2.status}
         </if>
         <if test="param2.entrustName != null and param2.entrustName != ''">
-            AND ( a.entrust_name like CONCAT(CONCAT('%', #{param2.entrustName}), '%') or a.entrust_no like CONCAT(CONCAT('%', #{param2.entrustName}), '%') )
+            AND ( a.entrust_name like CONCAT(CONCAT('%', #{param2.entrustName}), '%') or a.entrust_no like CONCAT(CONCAT('%', #{param2.entrustName}), '%') or b.material_name like CONCAT(CONCAT('%', #{param2.entrustName}), '%'))
         </if>
     </select>
 
@@ -105,7 +105,7 @@
         where  a.sample_id=b.id and a.is_deleted = 0 and b.is_deleted=0
           and a.sample_status=#{param2.status}
         <if test="param2.materialName != null and param2.materialName != ''">
-            AND b.material_name like CONCAT(CONCAT('%', #{param2.materialName}), '%')
+            AND (b.material_name like CONCAT('%', #{param2.materialName}, '%') or b.specification_model like CONCAT('%', #{param2.materialName}, '%'))
         </if>
         <if test="param2.nodeId != null and param2.nodeId != ''">
             AND b.node_id = #{param2.nodeId}
@@ -168,7 +168,7 @@
                 #{id}
             </foreach>
             )
-        and (status = 2
+        and (status > 1
         or id  in (select entrust_id from u_trial_self_inspection_record where is_deleted=0))
     </select>
     <select id="getRfiList" resultType="org.springblade.business.entity.EntrustInfo">
@@ -184,7 +184,7 @@
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
-        and status !=2
+        and status  in (0,1)
         and id not in(SELECT entrust_id from u_trial_self_inspection_record where is_deleted=0 and  LENGTH(entrust_id)>=5)
     </delete>
 

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialSelfInspectionRecordMapper.xml

@@ -65,7 +65,7 @@
     </delete>
 
     <select id="selectAll" resultType="org.springblade.business.entity.TrialSelfInspectionRecord">
-        select record_no,report_no from u_trial_self_inspection_record where node_id = #{nodeId} and contract_id = #{contractId} and is_deleted = 0 and type = #{type}
+        select id,record_no,report_no from u_trial_self_inspection_record where node_id = #{nodeId} and contract_id = #{contractId} and is_deleted = 0 and type = #{type}
     </select>
 
     <select id="selectSelfSampleRecord" resultType="java.lang.String">

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java

@@ -45,4 +45,6 @@ public interface ITrialSelfInspectionRecordService extends BaseService<TrialSelf
 
 
     R getSamplePdfUrl(String id,String contrctId);
+
+    Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO vo);
 }

+ 2 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/EntrustInfoServiceImpl.java

@@ -253,9 +253,10 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
 			return R.fail("ids不能为null");
 		}
 		List<Long> longList = Func.toLongList(ids);
+		//只有未上报的委托单才可以删除
 		List<EntrustInfo> entrustInfos = baseMapper.checkDelete(longList);
 		if (entrustInfos.size()>0){
-			return R.fail("删除失败");
+			return R.fail("只有未上报的委托单才可以删除");
 		}
 		int delete = baseMapper.delEntrustInfo(longList);
         if(delete!=longList.size()){

+ 2 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java

@@ -40,7 +40,6 @@ import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
@@ -372,7 +371,7 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
         return null;
     }
 
-    public void addDeviceUseInfo(TrialSelfInspectionRecordDTO dto) {
+    public void addDeviceUseInfo(TrialSelfInspectionRecordDTO dto, Long id) {
         if (StringUtils.isNotEmpty(dto.getDeviceUseIds())) {
             //获取进场记录
             List<TrialDeviceInfo> deviceInfos = trialDeviceInfoMapper.selectList(Wrappers.<TrialDeviceInfo>lambdaQuery().in(TrialDeviceInfo::getId, Func.toLongList(dto.getDeviceUseIds())));
@@ -396,6 +395,7 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
                 TrialDeviceUse trialDeviceUses = BeanUtil.copyProperties(deviceInfo, TrialDeviceUse.class);
                 if (trialDeviceUses != null) {
                     trialDeviceUses.setId(SnowFlakeUtil.getId());
+                    trialDeviceUses.setSelfInspectionRecordId(id);
                     trialDeviceUses.setNodeId(dto.getNodeId());
                     trialDeviceUses.setDeviceInfoId(deviceInfo.getId());
                     trialDeviceUses.setManagerName(dto.getTrialUserName());

+ 13 - 7
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java

@@ -94,12 +94,12 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
         if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
             throw new ServiceException("获取用户信息失败");
         }
-        boolean b=true;
         if(StringUtils.isNotEmpty(obj.getMaterialNumber())){
-            b= trialNumberRuleService.checkTrialNumberIsExist(obj.getMaterialNumber(), 1,obj.getContractId());
-        }
-        if(!b){
-            throw new ServiceException("编号已存在");
+            Long count = baseMapper.selectCount(Wrappers.<TrialMaterialMobilization>lambdaQuery().eq(TrialMaterialMobilization::getMaterialNumber, obj.getMaterialNumber())
+                    .ne( obj.getId() !=  null,TrialMaterialMobilization::getId, obj.getId()));
+            if (count > 0) {
+                throw new ServiceException("编号已存在");
+            }
         }
         obj.setUserId(SecureUtil.getUserId());
         this.saveOrUpdate(obj);
@@ -403,12 +403,16 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
 
     @Override
     public List<TrialSamplingRecordVO> samplingRecordList(Long id) {
+        TrialMaterialMobilization trialMaterialMobilization = this.getById(id);
+        if (trialMaterialMobilization == null) {
+            return new ArrayList<>();
+        }
         //获取用户信息
         List<User> userList = iUserClient.selectUserAll();
         //获取关联信息
         List<TrialSamplingRecord> trialSamplingRecords = trialSamplingRecordMapper.selectListByMobilizationId(id);
         //获取样品信息
-        List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectList(Wrappers.<TrialSampleInfo>query().lambda());
+        List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectList(Wrappers.<TrialSampleInfo>query().lambda().eq(TrialSampleInfo::getContractId, trialMaterialMobilization.getContractId()));
         List<TrialSamplingRecordVO> list = new ArrayList<>();
         for (TrialSamplingRecord trialSamplingRecord : trialSamplingRecords) {
             for (TrialSampleInfo trialSampleInfo : trialSampleInfos) {
@@ -444,10 +448,12 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
             } else if (extension.equals("docx") || extension.equals("doc")) {
                 bladeFile = this.commonFileClient.wordToPdf(files);
             } else if (extension.equals("pdf")) {
-                pdfUrl = url;
+                bladeFile = null;
             }
             if (bladeFile != null) {
                 pdfUrl = bladeFile.getPdfUrl();
+            } else {
+                pdfUrl = url;
             }
         } catch (IOException e) {
             log.error("上传文件失败", e);

+ 6 - 2
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java

@@ -79,7 +79,7 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
             return trialSampleInfo != null;
         } else {
             TrialSampleInfo trialSampleInfo = list.stream().filter(f -> f.getId().equals(Long.parseLong(id))).findAny().orElse(null);
-            if (trialSampleInfo != null && !trialSampleInfo.getSpecificationNumber().equals(specificationNumber)) {
+            if (trialSampleInfo != null && trialSampleInfo.getSpecificationNumber() != null && !trialSampleInfo.getSpecificationNumber().equals(specificationNumber)) {
                 TrialSampleInfo trialSampleInfo1 = list.stream().filter(f -> f.getSpecificationNumber().equals(specificationNumber)).findAny().orElse(null);
                 return trialSampleInfo1 != null;
             }
@@ -246,6 +246,10 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
             }
             trialSampleInfoDTO.setId(SnowFlakeUtil.getId());
             list.add(trialSampleInfoDTO);
+            if (trialSampleInfoDTO.getId() != null && trialSampleInfoDTO.getMobilizationId() != null && trialSampleInfoDTO.getMobilizationId() != -1) {
+                // todo 批量插入
+                this.trialSamplingRecordMapper.insertRecord(SnowFlakeUtil.getId(), trialSampleInfoDTO.getMobilizationId(), trialSampleInfoDTO.getId());
+            }
         }
         return this.saveBatch(list);
     }
@@ -258,7 +262,7 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
         }
         data.forEach(excel -> {
             TrialSampleInfo trialSampleInfo = BeanUtil.copyProperties(excel, TrialSampleInfo.class);
-            if (trialSampleInfo != null) {
+            if (trialSampleInfo != null && StringUtils.isNotEmpty(excel.getMaterialName())) {
                 if (StringUtils.isNotEmpty(excel.getMaterialCount())) {
                     trialSampleInfo.setMaterialCount(excel.getMaterialCount());
                 }

+ 244 - 14
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -1,9 +1,11 @@
 package org.springblade.business.service.impl;
 
 import cn.hutool.core.date.LocalDateTimeUtil;
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -40,6 +42,9 @@ 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.oss.model.BladeFile;
+import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.*;
@@ -139,6 +144,17 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             if (org.apache.commons.lang.StringUtils.isNotEmpty(dto.getQueryStatus())) {
                 queryWrapper.lambda().eq(TrialSelfInspectionRecord::getDetectionResult, dto.getQueryStatus());
             }
+            if (dto.getSortType() !=  null) {
+                if (dto.getSortType().equals("1")) {
+                    queryWrapper.lambda().orderByAsc(TrialSelfInspectionRecord::getReportNo);
+                } else if (dto.getSortType().equals("2")) {
+                    queryWrapper.lambda().orderByDesc(TrialSelfInspectionRecord::getReportNo);
+                } else if (dto.getSortType().equals("3")) {
+                    queryWrapper.lambda().orderByAsc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
+                } else if (dto.getSortType().equals("4")) {
+                    queryWrapper.lambda().orderByDesc(Arrays.asList(TrialSelfInspectionRecord::getSpecificationModel, TrialSelfInspectionRecord::getReportNo));
+                }
+            }
 
             IPage<TrialSelfInspectionRecord> pages = this.page(page, queryWrapper.lambda().orderByDesc(true, TrialSelfInspectionRecord::getCreateTime));
             IPage<TrialSelfInspectionRecordVO> trialSelfInspectionRecordVOIPage = TrialSelfInspectionRecordWarpper.build().pageVO(pages);
@@ -205,6 +221,21 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                          }
                      }
                 }
+                if (record.getBaseInfo() != null && !record.getBaseInfo().isEmpty()) {
+                    try {
+                        TrialSeleInspectionRecordBaseInfoDTO baseInfoDTO = JSON.parseObject(record.getBaseInfo(), TrialSeleInspectionRecordBaseInfoDTO.class);
+                        if (baseInfoDTO != null) {
+                            if (StringUtil.hasText(baseInfoDTO.getEntrustNo())) {
+                                record.setEntrustNo(baseInfoDTO.getEntrustNo());
+                            }
+                            if (StringUtil.hasText(baseInfoDTO.getProjectPosition())) {
+                                record.setProjectPositionName(baseInfoDTO.getProjectPosition());
+                            }
+                        }
+                    } catch (Exception e) {
+                        log.warn("JSON反序列化失败:" + record.getBaseInfo());
+                    }
+                }
                 //合并的pdfUrl
                 String pdf = this.getMergePdfToTrialNew(record.getContractId(), record.getId(), dto.getType());
                 record.setPdfUrl(pdf);
@@ -1131,7 +1162,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             this.recordSampleSubmit(dto, obj);
 
             //------关联新增设备使用记录信息------
-            this.trialDeviceUseService.addDeviceUseInfo(dto);
+            this.trialDeviceUseService.addDeviceUseInfo(dto, obj.getId());
         }
 
         // ---- 修改样品单号信息 --------
@@ -1420,16 +1451,16 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
 
             //取样信息
             List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectList(Wrappers.<TrialSampleInfo>lambdaQuery().in(TrialSampleInfo::getId, ids));
-            List<String> samplingLocations = trialSampleInfos.stream().map(TrialSampleInfo::getSamplingLocation).filter(string -> !string.isEmpty()).collect(Collectors.toList());
+            List<String> samplingLocations = trialSampleInfos.stream().map(TrialSampleInfo::getSamplingLocation).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
             String samplingLocation = org.apache.commons.lang.StringUtils.join(samplingLocations, "、");
 
-            List<String> calculationUnits = trialSampleInfos.stream().map(TrialSampleInfo::getCalculationUnit).filter(string -> !string.isEmpty()).collect(Collectors.toList());
+            List<String> calculationUnits = trialSampleInfos.stream().map(TrialSampleInfo::getCalculationUnit).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
             String calculationUnit = org.apache.commons.lang.StringUtils.join(calculationUnits, "、");
 
-            List<String> specificationNumbers = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationNumber).filter(string -> !string.isEmpty()).collect(Collectors.toList());
+            List<String> specificationNumbers = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationNumber).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
             String specificationNumber = org.apache.commons.lang.StringUtils.join(specificationNumbers, "、");
 
-            List<String> specificationModels = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationModel).filter(string -> !string.isEmpty()).collect(Collectors.toList());
+            List<String> specificationModels = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationModel).filter(string -> string !=null && !string.isEmpty()).collect(Collectors.toList());
             String specificationModel = org.apache.commons.lang.StringUtils.join(specificationModels, "、");
 
             //更新
@@ -1678,7 +1709,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         StringSPUtils spUtils = new StringSPUtils();
         List<TrialSelfInspectionRecord> result = baseMapper.selectAll(dto.getNodeId(), dto.getContractId(), dto.getType());
         List<TrialSelfInspectionRecord> trialSelfInspectionRecords = result.stream().filter(Objects::nonNull).collect(Collectors.toList());
-
+        TrialSelfInspectionRecord trialSelfInspectionRecord = trialSelfInspectionRecords.stream().filter(item -> Objects.equals(item.getId(), dto.getId())).findFirst().orElse(null);
         //两种类型同时生成
         if (dto.getTableType().contains("1,2") || dto.getTableType().contains("2,1") || dto.getTableType().contains("9,10") || dto.getTableType().contains("10,9")) {
             String maxRecordNo = "";
@@ -1736,26 +1767,34 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             } else {
                 //记录表
                 if (StringUtils.isNotEmpty(maxRecordNo)) {
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","记录表");
+                    if (trialSelfInspectionRecord != null) {
+                        stringStringHashMap.put("valueStr",trialSelfInspectionRecord.getRecordNo());
+                        return stringStringHashMap;
+                    }
                     String str1 = "JL" +
                             "-" + contract.getContractNumber() +
                             "-" + year +
                             "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
                             "-" + maxRecordNo;
-                    HashMap<String, String> stringStringHashMap = new HashMap<>();
-                    stringStringHashMap.put("type","记录表");
                     stringStringHashMap.put("valueStr",str1);
                     return stringStringHashMap;
                 }
 
                 //报告单
                 if (StringUtils.isNotEmpty(maxReportNo)) {
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","报告单");
+                    if (trialSelfInspectionRecord != null) {
+                        stringStringHashMap.put("valueStr",trialSelfInspectionRecord.getReportNo());
+                        return stringStringHashMap;
+                    }
                     String str2 = "BG" +
                             "-" + contract.getContractNumber() +
                             "-" + year +
                             "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
                             "-" + maxReportNo;
-                    HashMap<String, String> stringStringHashMap = new HashMap<>();
-                    stringStringHashMap.put("type","报告单");
                     stringStringHashMap.put("valueStr",str2);
                     return stringStringHashMap;
                 }
@@ -1792,13 +1831,17 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                     throw new ServiceException("未找到当前项目合同段的节点信息,操作失败!");
                 } else {
                     //记录表
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","记录表");
+                    if (trialSelfInspectionRecord != null) {
+                        stringStringHashMap.put("valueStr",trialSelfInspectionRecord.getRecordNo());
+                        return stringStringHashMap;
+                    }
                     String str1 = "JL" +
                             "-" + contract.getContractNumber() +
                             "-" + year +
                             "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
                             "-" + maxRecordNo;
-                    HashMap<String, String> stringStringHashMap = new HashMap<>();
-                    stringStringHashMap.put("type","记录表");
                     stringStringHashMap.put("valueStr",str1);
                     return stringStringHashMap;
                 }
@@ -1835,13 +1878,17 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
                     throw new ServiceException("未找到当前项目合同段的节点信息,操作失败!");
                 } else {
                     //报告单
+                    HashMap<String, String> stringStringHashMap = new HashMap<>();
+                    stringStringHashMap.put("type","报告单");
+                    if (trialSelfInspectionRecord != null) {
+                        stringStringHashMap.put("valueStr",trialSelfInspectionRecord.getReportNo());
+                        return stringStringHashMap;
+                    }
                     String str2 = "BG" +
                             "-" + contract.getContractNumber() +
                             "-" + year +
                             "-" + spUtils.getStringSP(wbsTreePrivate.getNodeName().trim()) +
                             "-" + maxReportNo;
-                    HashMap<String, String> stringStringHashMap = new HashMap<>();
-                    stringStringHashMap.put("type","报告单");
                     stringStringHashMap.put("valueStr",str2);
                     return stringStringHashMap;
                 }
@@ -2073,5 +2120,188 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         }
     }
 
+    @Override
+    public Long saveBaseInfo(TrialSeleInspectionRecordInfoDTO dto) {
+        TrialSelfInspectionRecord record = new TrialSelfInspectionRecord();
+        BeanUtil.copyProperties(dto, record);
+        if (record.getEntrustId() == null) {
+            record.setEntrustId(0L);
+        }
+        TrialSelfInspectionRecord oldRecord = null;
+        EntrustInfo oldEntrustInfo = null;
+        TrialSampleInfo oldTrialSampleInfo = null;
+        if (dto.getId() != null) {
+            oldRecord = baseMapper.selectById(dto.getId());
+            if (oldRecord != null) {
+                if (oldRecord.getTaskStatus() != null && !oldRecord.getTaskStatus().equals("未上报") && !oldRecord.getTaskStatus().isEmpty()) {
+                    throw new ServiceException("当前试验已上报,请勿修改");
+                }
+                if (oldRecord.getEntrustId() != null) {
+                    oldEntrustInfo = entrustInfoMapper.selectById(oldRecord.getEntrustId());
+                }
+                try {
+                    if (oldRecord.getBaseInfo() != null && !oldRecord.getBaseInfo().isEmpty()) {
+                        TrialSeleInspectionRecordBaseInfoDTO baseInfo = JSONObject.parseObject(oldRecord.getBaseInfo(), TrialSeleInspectionRecordBaseInfoDTO.class);
+                        if (baseInfo != null) {
+                            oldTrialSampleInfo = baseInfo.getTrialSampleInfo();
+                        }
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        TrialSeleInspectionRecordBaseInfoDTO baseInfo = new TrialSeleInspectionRecordBaseInfoDTO();
+        BeanUtil.copyProperties(dto, baseInfo);
+        EntrustInfo entrustInfo = null;
+        if (record.getEntrustId() != null && record.getEntrustId() > 0) {
+            entrustInfo = entrustInfoMapper.selectById(record.getEntrustId());
+        }
+        List<TrialSampleInfo> trialSampleInfoList = dto.getTrialSampleInfoList();
+        TrialSampleInfo info = dto.getTrialSampleInfo();
+        if (info == null && !trialSampleInfoList.isEmpty()) {
+            info = trialSampleInfoList.get(0);
+        }
+        if (entrustInfo != null && info != null) {
+            // 判断是否冲突
+            if (entrustInfo.getSampleId() != null && !entrustInfo.getSampleId().equals(info.getId())) {
+                // 判断是否是现场试验节点
+                WbsTreePrivate wbs = wbsTreePrivateClient.getNodeByPrimaryKeyId(entrustInfo.getNodeId());
+                if (wbs == null || wbs.getNodeType() != 51) {
+                    throw new ServiceException("关联的委托单与取样材料不匹配,请重新选择");
+                }
+            }
+        }
+        if ((entrustInfo == null && oldEntrustInfo != null) && info != null) {
+            // 判断是否关联,如果关联一起取消
+            if (oldEntrustInfo.getSampleId() != null && oldEntrustInfo.getSampleId().equals(info.getId())) {
+                //删除关联
+                baseMapper.delSelfSample(record.getId());
+                info = null;
+                baseInfo.setTrialSampleInfo(null);
+                entrustInfoService.update(Wrappers.<EntrustInfo>lambdaUpdate().eq(EntrustInfo::getId, record.getId()).set(EntrustInfo::getExpCount, 0));
+            }
+        }
+        if (entrustInfo != null && info == null && oldTrialSampleInfo != null) {
+            if (entrustInfo.getSampleId() != null && entrustInfo.getSampleId().equals(oldTrialSampleInfo.getId())) {
+                record.setEntrustId(null);
+                baseInfo.setEntrustId( null);
+                baseInfo.setEntrustNo(null);
+            }
+        }
+        boolean a=true;
+        boolean b=true;
+        record.setBaseInfo(JSON.toJSONString(baseInfo));
+        if (oldRecord == null) {
+            if(StringUtils.isNotEmpty(record.getRecordNo())){
+                if(StringUtils.isNotEmpty(record.getRecordNo())){
+                    a= trialNumberRuleService.checkTrialNumberIsExist(record.getRecordNo(), 4, record.getContractId());
+                }
+            }
+            if(StringUtils.isNotEmpty(record.getRecordNo())){
+                if(StringUtils.isNotEmpty(record.getReportNo())){
+                    b= trialNumberRuleService.checkTrialNumberIsExist(record.getReportNo(), 5, record.getContractId());
+                }
+            }
+            if(!a){
+                throw new ServiceException("记录编号已存在");
+            }
+            if(!b){
+                throw new ServiceException("报告编号已存在");
+            }
+            this.save(record);
+        } else {
+            this.updateById(record);
+        }
+        if (info != null) {
+            TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(info.getId());
+            if (sampleInfo != null) {
+                //------关联取样信息------
+                RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
+                sampleSubmitDTO.setId(record.getId());
+                sampleSubmitDTO.setSampleIds(info.getId() + "");
+                //删除关联
+                baseMapper.delSelfSample(record.getId());
+                baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), info.getId() + "");
+                String samplingLocation = sampleInfo.getSamplingLocation();
+                String calculationUnit = sampleInfo.getCalculationUnit();
+                String specificationNumber = info.getSpecificationNumber();
+                String specificationModel = sampleInfo.getSpecificationModel();
+                //更新
+                if (StringUtils.isNotBlank(samplingLocation) || StringUtils.isNotBlank(calculationUnit) || StringUtils.isNotBlank(specificationNumber) || StringUtils.isNotBlank(specificationModel)) {
+                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                            .set(StringUtils.isNotBlank(samplingLocation), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
+                            .set(StringUtils.isNotBlank(calculationUnit),TrialSelfInspectionRecord::getCompany, calculationUnit)
+                            .set(StringUtils.isNotBlank(specificationNumber),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
+                            .set(StringUtils.isNotBlank(specificationModel),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
+                            .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                }
+                if (entrustInfo == null) {
+                    // 根据样品关联的委托单关联委托单
+                    entrustInfo = entrustInfoMapper.selectList(Wrappers.<EntrustInfo>lambdaQuery().eq(EntrustInfo::getSampleId, info.getId())).stream().findFirst().orElse(null);
+                    if (entrustInfo != null) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(TrialSelfInspectionRecord::getEntrustId, entrustInfo.getId())
+                                .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                    }
+                }
+            }
+        }
+        // ---- 修改样品单号信息 --------
+        if(entrustInfo != null){
+            //修改项目节点基础信息
+            jdbcTemplate.update("update u_entrust_info set sample_status=4 where id ='"+entrustInfo.getId()+"'");
+            if (entrustInfo.getSampleId() != null) {
+                TrialSampleInfo sampleInfo = trialSampleInfoMapper.selectById(entrustInfo.getSampleId());
+                if (sampleInfo != null) {
+                    //------关联取样信息------
+                    RecordSampleSubmitDTO sampleSubmitDTO = new RecordSampleSubmitDTO();
+                    sampleSubmitDTO.setId(record.getId());
+                    sampleSubmitDTO.setSampleIds(sampleInfo.getId() + "");
+                    //删除关联
+                    baseMapper.delSelfSample(record.getId());
+                    baseMapper.saveSelfSample(SnowFlakeUtil.getId(), record.getId(), sampleInfo.getId() + "");
+                    String samplingLocation = sampleInfo.getSamplingLocation();
+                    String calculationUnit = sampleInfo.getCalculationUnit();
+                    String specificationNumber = sampleInfo.getSpecificationNumber();
+                    String specificationModel = sampleInfo.getSpecificationModel();
+                    //更新
+                    if (StringUtils.isNotBlank(samplingLocation) || StringUtils.isNotBlank(calculationUnit) || StringUtils.isNotBlank(specificationNumber) || StringUtils.isNotBlank(specificationModel)) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(StringUtils.isNotBlank(samplingLocation), TrialSelfInspectionRecord::getSamplingLocation, samplingLocation)
+                                .set(StringUtils.isNotBlank(calculationUnit),TrialSelfInspectionRecord::getCompany, calculationUnit)
+                                .set(StringUtils.isNotBlank(specificationNumber),TrialSelfInspectionRecord::getSpecificationNumber, specificationNumber)
+                                .set(StringUtils.isNotBlank(specificationModel),TrialSelfInspectionRecord::getSpecificationModel, specificationModel)
+                                .eq(TrialSelfInspectionRecord::getId, record.getId()));
+                    }
+                }
+            }
+        }
+        //------关联新增设备使用记录信息------
+        List<TrailDeviceUseInfoDTO> deviceUseInfoDTOS = dto.getTrailDeviceUseInfoDTOS();
+        if (deviceUseInfoDTOS != null && !deviceUseInfoDTOS.isEmpty()) {
+            List<Long> ids = deviceUseInfoDTOS.stream().map(TrailDeviceUseInfoDTO::getDeviceInfoId).collect(Collectors.toList());
+            TrialSelfInspectionRecordDTO recordDTO = new TrialSelfInspectionRecordDTO();
+            recordDTO.setDeviceUseIds(org.apache.commons.lang.StringUtils.join(ids, ","));
+            List<Long> collect = trialSampleInfoList.stream().map(TrialSampleInfo::getId).collect(Collectors.toList());
+            recordDTO.setSampleIds(org.apache.commons.lang.StringUtils.join(collect, ","));
+            recordDTO.setNodeId(dto.getNodeId());
+            recordDTO.setTrialUserName(AuthUtil.getUserName());
+            this.trialDeviceUseService.addDeviceUseInfo(recordDTO, record.getId());
+        }
+            if(dto.getOldRecordNumber()!=null&&dto.getOldRecordNumber().equals(dto.getRecordNo())){
+                if(StringUtils.isNotEmpty(dto.getRecordAutoNumber())){
+                    trialNumberRuleService.checkSave(dto.getContractId(),4,record.getId(),dto.getRecordAutoNumber());
+                }
+            }
+            if(dto.getOldReportNumber()!=null&&dto.getOldReportNumber().equals(dto.getReportNo())){
+                if(StringUtils.isNotEmpty(dto.getReportAutoNumber())){
+                    trialNumberRuleService.checkSave(dto.getContractId(),5,record.getId(),dto.getReportAutoNumber());
+                }
+            }
+
+        return record.getId();
+    }
+
 
 }

+ 28 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/feign/ExcelTabClientImpl.java

@@ -41,7 +41,6 @@ import org.springblade.manager.utils.RandomNumberHolder;
 import org.springblade.manager.vo.AppWbsTreeContractVO;
 import org.springblade.manager.vo.TrialSelfDataRecordVO1;
 import org.springblade.resource.feign.NewIOSSClient;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.RestController;
@@ -91,7 +90,7 @@ public class ExcelTabClientImpl implements ExcelTabClient {
 
         //应用抽取的数据
         dataArray = excelTabService.addLoadDataInfo(dataArray);
-
+        dataArray = putIfAbsent(dataArray);
         List<TableInfo> tableInfoList = this.excelTabService.getTableInfoListTrial(dataArray, tabIds);
         try {
             //试验特殊处理
@@ -885,6 +884,33 @@ public class ExcelTabClientImpl implements ExcelTabClient {
         return R.data(resultMapList);
     }
 
+    private JSONArray putIfAbsent(JSONArray jsonArray) {
+        JSONArray json2 = new JSONArray();
+        for (int i = 0; i < jsonArray.size(); i++) {
+            JSONObject jsonObject = jsonArray.getJSONObject(i);
+            String pkeyId = jsonObject.getString("pkeyId");
+            WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateService.getOne(Wrappers.<WbsTreePrivate>lambdaQuery().eq(WbsTreePrivate::getPKeyId, pkeyId));
+            String htmlString = null;
+            try {
+                htmlString = IoUtil.readToString(FileUtils.getInputStreamByUrl(wbsTreePrivate.getHtmlUrl()));
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+            Document doc = Jsoup.parse(htmlString);
+            for (Element element : doc.getElementsByAttributeValueStarting("id", "key_")) {
+                String id = element.attr("id");
+                if(id == null || id.startsWith("key__")) {
+                    continue;
+                }
+                String text = jsonObject.getString(id);
+                if (text == null || text.trim().isEmpty()) {
+                    jsonObject.put(id, "/");
+                }
+            }
+            json2.add(jsonObject);
+        }
+        return json2;
+    }
     @Override
     public R synPdfKeyInfo(String contractId, String nodeIds, String classify, String projectId, String authorization) throws Exception {
 

+ 199 - 11
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ExcelTabServiceImpl.java

@@ -31,6 +31,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.nodes.Node;
 import org.jsoup.select.Elements;
+import org.springblade.business.dto.TrialSeleInspectionRecordBaseInfoDTO;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
 import org.springblade.business.entity.*;
 import org.springblade.business.feign.ContractLogClient;
@@ -77,6 +78,7 @@ import org.springframework.dao.DataAccessException;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowCallbackHandler;
 import org.springframework.jdbc.datasource.DataSourceTransactionManager;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
@@ -2739,7 +2741,59 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             htmlString = htmlString.replaceAll("title", "titlexx");
             Document doc = Jsoup.parse(htmlString);
             keyNames= getKeyNameList(doc);
-            if(entrustId != null){
+            TrialSelfInspectionRecord record = jdbcTemplate.query("select * from u_trial_self_inspection_record where id = " + groupId, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
+            // 优先使用试验记录中的委托单和样品
+            TrialSeleInspectionRecordBaseInfoDTO baseInfoDTO = null;
+            if (record != null) {
+                if (record.getBaseInfo() != null && !record.getBaseInfo().isEmpty()) {
+                    try {
+                        baseInfoDTO = JSON.parseObject(record.getBaseInfo(), TrialSeleInspectionRecordBaseInfoDTO.class);
+                    } catch (Exception e) {
+                        log.warn("JSON反序列化失败:" + record.getBaseInfo());
+                    }
+                }
+                EntrustInfo entrustInfo = null;
+                Long sampleId = null;
+                if (record.getEntrustId() != null && record.getEntrustId() > 0) {
+                    String sql = "select * from u_entrust_info where id ="+ record.getEntrustId();
+                    try {
+                        entrustInfo = jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(EntrustInfo.class));
+                    } catch (Exception e) {
+                        log.warn("委托单查询失败:" + record.getEntrustId());
+                    }
+                }
+                if (entrustInfo == null) {
+                    entrustInfo = new EntrustInfo();
+                }
+                if (baseInfoDTO != null && StringUtil.hasText(baseInfoDTO.getEntrustNo())) {
+                    entrustInfo.setEntrustNo(baseInfoDTO.getEntrustNo());
+                }
+                TrialSampleInfo sampleInfo;
+                if (baseInfoDTO != null && baseInfoDTO.getTrialSampleInfo() != null) {
+                    sampleInfo = baseInfoDTO.getTrialSampleInfo();
+                    sampleId = sampleInfo.getId();
+                } else {
+                    sampleId = entrustInfo.getSampleId();
+                    String querySql1 = "select * from u_trial_sample_info where id=" + sampleId ;
+                    try {
+                        sampleInfo = jdbcTemplate.queryForObject(querySql1, new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+                    } catch (Exception e) {
+                        sampleInfo = null;
+                    }
+                }
+                TrialMaterialMobilization trialMaterialMobilization = null;
+                if (sampleInfo != null) {
+                    //用sampleId查询出关联的材料对象
+                    String querySql2 = "select * from u_trial_material_mobilization where id =(select mobilization_id from u_trial_sampling_record where sample_info_id = "+sampleId+") ";
+                    try {
+                        trialMaterialMobilization = jdbcTemplate.query(querySql2, new BeanPropertyRowMapper<>(TrialMaterialMobilization.class)).stream().findFirst().orElse(null);
+                    } catch (DataAccessException e) {
+                        e.printStackTrace();
+                    }
+                }
+                //通过html获取页面上的key值 返回key值对应的数据
+                setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization, entrustInfo,record, baseInfoDTO, wbsTreePrivate);
+            } else if(entrustId != null){
                 //有委托单信息是从实验报告关联委托单进来的 通过委托单查询到具体的样品id
                 String sql = "select * from u_entrust_info where id ="+entrustId;
                 EntrustInfo entrustInfo = jdbcTemplate.queryForObject(sql,new BeanPropertyRowMapper<>(EntrustInfo.class));
@@ -2755,7 +2809,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                     trialMaterialMobilization = null;
                 }
                 //通过html获取页面上的key值 返回key值对应的数据
-              setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization, entrustInfo);
+                setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization, entrustInfo,record, baseInfoDTO, wbsTreePrivate);
             }
             //第一次新增 回显系统生成的编号
             if(type != null && nodeId != null){
@@ -2797,17 +2851,29 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
             ContractInfo contractInfo = jdbcTemplate.query("select construction_unit_name,supervision_unit_name,contract_name,laboratory_name,is_test_record from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
             if (contractInfo != null) {
                 //承包单位
+                String constructionUnitName = "";
+                if (baseInfoDTO != null && ObjectUtils.isNotEmpty(baseInfoDTO.getConstructionUnit())) {
+                    constructionUnitName = baseInfoDTO.getConstructionUnit();
+                } else if (ObjectUtils.isNotEmpty(contractInfo.getConstructionUnitName())) {
+                    constructionUnitName = contractInfo.getConstructionUnitName();
+                }
                 if (cbdwBH.size() >= 1) {
                     for (Element element : cbdwBH) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getConstructionUnitName()) ? contractInfo.getConstructionUnitName() : "");
+                        reData.put(element.attr("keyname"), constructionUnitName);
                         break;
                     }
                 }
 
                 //监理单位
+                String supervisionUnitName = "";
+                if (baseInfoDTO != null && ObjectUtils.isNotEmpty(baseInfoDTO.getSupervisionUnit())) {
+                    supervisionUnitName = baseInfoDTO.getSupervisionUnit();
+                } else if (ObjectUtils.isNotEmpty(contractInfo.getSupervisionUnitName())) {
+                    supervisionUnitName = contractInfo.getSupervisionUnitName();
+                }
                 if (jldwBH.size() >= 1) {
                     for (Element element : jldwBH) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getSupervisionUnitName()) ? contractInfo.getSupervisionUnitName() : "");
+                        reData.put(element.attr("keyname"), supervisionUnitName);
                         break;
                     }
                 }
@@ -2815,7 +2881,7 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 //施工单位
                 if (sgName.size() >= 1) {
                     for (Element element : sgName) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getConstructionUnitName()) ? contractInfo.getConstructionUnitName() : "");
+                        reData.put(element.attr("keyname"), constructionUnitName);
                         break;
                     }
                 }
@@ -2823,23 +2889,35 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 //委托单位
                 if (wtName.size() >= 1) {
                     for (Element element : wtName) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getSupervisionUnitName()) ? contractInfo.getSupervisionUnitName() : "");
+                        reData.put(element.attr("keyname"), supervisionUnitName);
                         break;
                     }
                 }
 
                 //检测单位名称
                 if (jcdwName.size() >= 1) {
+                    String laboratoryName = "";
+                    if (baseInfoDTO != null && ObjectUtils.isNotEmpty(baseInfoDTO.getLabName())) {
+                        laboratoryName = baseInfoDTO.getLabName();
+                    } else if (ObjectUtils.isNotEmpty(contractInfo.getLaboratoryName())) {
+                        laboratoryName = contractInfo.getLaboratoryName();
+                    }
                     for (Element element : jcdwName) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getLaboratoryName()) ? contractInfo.getLaboratoryName() : "");
+                        reData.put(element.attr("keyname"), laboratoryName);
                         break;
                     }
                 }
 
                 //合同段/工区
                 if (htdName.size() >= 1) {
+                    String contractName = "";
+                    if (baseInfoDTO != null && ObjectUtils.isNotEmpty(baseInfoDTO.getContractName())) {
+                        contractName = baseInfoDTO.getContractName();
+                    } else if (ObjectUtils.isNotEmpty(contractInfo.getContractName())) {
+                        contractName = contractInfo.getContractName();
+                    }
                     for (Element element : htdName) {
-                        reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(contractInfo.getContractName()) ? contractInfo.getContractName() : "");
+                        reData.put(element.attr("keyname"), contractName);
                         break;
                     }
                 }
@@ -2848,14 +2926,18 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                 if (projectInfo != null) {
                     //工程名称
                     if (gcName.size() >= 1) {
+                        String projectName = "";
+                        if (baseInfoDTO != null && ObjectUtils.isNotEmpty(baseInfoDTO.getProjectName())) {
+                            projectName = baseInfoDTO.getProjectName();
+                        } else if (ObjectUtils.isNotEmpty(projectInfo.getProjectName())) {
+                            projectName = projectInfo.getProjectName();
+                        }
                         for (Element element : gcName) {
-                            reData.put(element.attr("keyname"), ObjectUtils.isNotEmpty(projectInfo.getProjectName()) ? projectInfo.getProjectName() : "");
+                            reData.put(element.attr("keyname"), projectName);
                             break;
                         }
                     }
                 }
-
-                TrialSelfInspectionRecord record = jdbcTemplate.query("select record_no,report_no from u_trial_self_inspection_record where id = " + groupId, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class)).stream().findAny().orElse(null);
                 if (record != null) {
                     //报告编号
                     if (bgBH.size() >= 1) {
@@ -2937,6 +3019,10 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
                                         String[] strings = StringUtils.strip(tabData[0], "[]").split(",");
                                         reData.put(key + "__" + tabData[1], strings);
                                     } else {
+                                        Object o = reData.get(key + "__" + tabData[1]);
+                                        if (o != null && tabData[0].equals("/")) {
+                                            continue;
+                                        }
                                         reData.put(key + "__" + tabData[1], tabData[0]);
                                     }
                                 }
@@ -2997,6 +3083,52 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         return list;
     }
 
+    public Map<String, String> formulaTrialData(WbsTreePrivate wbsTreePrivate) {
+        Map<String, String> keyMap = new HashMap<>();
+        try {
+            List<Map<String, Object>> formulas = null;
+            if (wbsTreePrivate != null) {
+                if (wbsTreePrivate.getInitTableId() != null) {
+                    formulas = jdbcTemplate.queryForList("SELECT a.e_name,b.rely FROM m_wbs_form_element a, m_formula b WHERE  b.id in ( SELECT formula_id FROM m_element_formula_mapping WHERE scope = 0 AND element_id = a.id) and a.f_id = " +
+                            wbsTreePrivate.getInitTableId() + " and b.rely like '%TBInfo:%'");
+                }
+                if (wbsTreePrivate.getInitTableName() != null) {
+                    List<org.springblade.manager.entity.TableInfo> tableInfos = tableInfoService.list(Wrappers.<org.springblade.manager.entity.TableInfo>lambdaQuery().eq(org.springblade.manager.entity.TableInfo::getTabEnName, wbsTreePrivate.getInitTableName()));
+                    if (!tableInfos.isEmpty()) {
+                        formulas = jdbcTemplate.queryForList("SELECT a.e_name,b.rely FROM m_wbs_form_element a, m_formula b WHERE  b.id in ( SELECT formula_id FROM m_element_formula_mapping WHERE scope = 0 AND element_id = a.id) and a.f_id = " +
+                                tableInfos.get(0).getId() + " and b.rely like '%TBInfo:%'");
+                    }
+                }
+            }
+            if (!ObjectUtil.isEmpty(formulas)) {
+                for (Map<String, Object> formula : formulas) {
+                    Object relyObj = formula.get("rely");
+                    if (relyObj == null) {
+                        continue;
+                    }
+                    List<String> relyList = Arrays.asList(relyObj.toString().split(","));
+                    if (relyList.isEmpty()) {
+                        continue;
+                    }
+                    Object map = formula.get("e_name");
+                    if (map == null) {
+                        continue;
+                    }
+                    for (String rely : relyList) {
+                        if (!rely.contains("TBInfo:")) {
+                            continue;
+                        }
+                        keyMap.put(rely, map.toString());
+                    }
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return keyMap;
+    }
+
+
     /**
      * 拿到html里面所有的keyName
      * @param doc
@@ -5031,6 +5163,62 @@ public class ExcelTabServiceImpl extends BaseServiceImpl<ExcelTabMapper, ExcelTa
         }
         return isCancelList;
     }
+    private  void setBasicFormData(Document doc, Map<String, Object> reData, TrialSampleInfo sampleInfo ,TrialMaterialMobilization trialMaterialMobilization, EntrustInfo entrustInfo,
+                                                 TrialSelfInspectionRecord record, TrialSeleInspectionRecordBaseInfoDTO baseInfoDTO, WbsTreePrivate wbsTreePrivate) {
+        List<String> isCancelList = setBasicFormData(doc, reData, sampleInfo, trialMaterialMobilization, entrustInfo);
+        TrialBaseInfo baseInfo = buildTrialBaseInfo(sampleInfo, entrustInfo, record, baseInfoDTO);
+        Map<String, String> keyMap = formulaTrialData(wbsTreePrivate);
+        keyMap.forEach((key, value) -> {
+            setFirstData(doc,value,baseInfo.getValueByKey(key),reData,isCancelList);
+        });
+        if (record != null && record.getStandardId() != null && record.getStandardInfoIds() != null) {
+            String[] split = record.getStandardInfoIds().split(",");
+            if (split.length > 0) {
+                // 技术指标
+                List<Map<String, Object>> mapList = jdbcTemplate.queryForList("SELECT concat(a.symbol,a.name) symbolName,b.col_key,b.col_name from u_standard_info a, u_standard_info_private_join b WHERE a.id = b.standard_info_id and " +
+                                "a.standard_id = ? and b.private_id = ? and a.is_deleted = 0 and b.is_deleted = 0 " +
+                                "and (SELECT count(1) from u_standard_info_join WHERE standard_info_right_id in ( "+ record.getStandardInfoIds() +" ) and standard_info_left_id = a.id and is_deleted = 0) = ?"
+                        , record.getStandardId() , wbsTreePrivate.getPKeyId(), split.length);
+                mapList.forEach(e -> {
+                    setFirstData(doc,e.get("col_name").toString(),e.get("symbolName").toString(),reData,isCancelList);
+                });
+            }
+        }
+    }
+    private TrialBaseInfo buildTrialBaseInfo(TrialSampleInfo sampleInfo, EntrustInfo entrustInfo,TrialSelfInspectionRecord record, TrialSeleInspectionRecordBaseInfoDTO baseInfoDTO) {
+        TrialBaseInfo trialBaseInfo = new TrialBaseInfo();
+        if (sampleInfo != null) {
+            trialBaseInfo.setMaterialName(sampleInfo.getMaterialName());
+            trialBaseInfo.setSpecificationNumber(sampleInfo.getSpecificationNumber());
+            trialBaseInfo.setSampleDescription(sampleInfo.getSampleDescription());
+            trialBaseInfo.setSamplingDate(sampleInfo.getSamplingDate());
+            trialBaseInfo.setMaterialCount(sampleInfo.getMaterialCount());
+            trialBaseInfo.setDesignStrength(sampleInfo.getDesignStrength());
+        }
+        if (record != null) {
+            trialBaseInfo.setRecordNo(record.getRecordNo());
+            trialBaseInfo.setReportNo(record.getReportNo());
+            if (record.getStandardId() != null) {
+                PrivateStandard standard = jdbcTemplate.query("SELECT id,name from u_wbs_private_standard WHERE id = " + record.getStandardId(),
+                        new BeanPropertyRowMapper<>(PrivateStandard.class)).stream().findFirst().orElse(null);
+                if (standard != null) {
+                    trialBaseInfo.setStandard(standard.getName());
+                }
+            }
+        }
+        if (entrustInfo != null) {
+            trialBaseInfo.setEntrustNo(entrustInfo.getEntrustNo());
+        }
+        if (baseInfoDTO != null) {
+            trialBaseInfo.setProjectName(baseInfoDTO.getProjectName());
+            trialBaseInfo.setConstructionUnit(baseInfoDTO.getConstructionUnit());
+            trialBaseInfo.setSupervisionUnit(baseInfoDTO.getSupervisionUnit());
+            trialBaseInfo.setLabName(baseInfoDTO.getLabName());
+            trialBaseInfo.setContractName(baseInfoDTO.getContractName());
+            trialBaseInfo.setProjectPosition(baseInfoDTO.getProjectPosition());
+        }
+        return trialBaseInfo;
+    }
 
     /**
      * 指定条件查找元素