浏览代码

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

yangyj 2 年之前
父节点
当前提交
46f5b5aa32
共有 43 个文件被更改,包括 2174 次插入208 次删除
  1. 25 4
      blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java
  2. 2 0
      blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/entity/ArchivesAuto.java
  3. 86 0
      blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/vo/ArchivesAutoVO.java
  4. 2 2
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDetectionData.java
  5. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDeviceInfo.java
  6. 3 3
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialLaboratoryUserArchives.java
  7. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialMaterialMobilization.java
  8. 5 3
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSampleInfo.java
  9. 9 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ArchiveFileClient.java
  10. 5 6
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSamplingRecordVO.java
  11. 2 0
      blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveTreeVO2.java
  12. 14 4
      blade-service-api/blade-user-api/pom.xml
  13. 129 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileAutoController.java
  14. 50 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java
  15. 6 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java
  16. 49 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml
  17. 3 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java
  18. 45 0
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java
  19. 8 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDeviceInfoController.java
  20. 8 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java
  21. 5 3
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialDeviceInfoExcel.java
  22. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialMaterialMobilizationExcel.java
  23. 3 3
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialSampleInfoExcel.java
  24. 13 0
      blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java
  25. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialDeviceUseMapper.xml
  26. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialDeviceUseService.java
  27. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialMaterialMobilizationService.java
  28. 5 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialContainerClassificationServiceImpl.java
  29. 65 25
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceInfoServiceImpl.java
  30. 23 6
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceOverhaulServiceImpl.java
  31. 71 12
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java
  32. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialLaboratoryUserArchivesServiceImpl.java
  33. 70 13
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java
  34. 53 18
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java
  35. 76 66
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  36. 1228 0
      blade-service/blade-business/src/main/java/org/springblade/business/utils/DateUtils.java
  37. 4 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java
  38. 2 10
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ProjectInfoController.java
  39. 5 3
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.java
  40. 6 5
      blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.xml
  41. 46 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveAutoRuleWbsServiceImpl.java
  42. 24 13
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java
  43. 9 2
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

+ 25 - 4
blade-common/src/main/java/org/springblade/common/utils/CommonUtil.java

@@ -2,18 +2,17 @@ package org.springblade.common.utils;
 
 import cn.hutool.core.io.FileUtil;
 import org.apache.commons.lang.StringUtils;
+import org.springframework.util.CollectionUtils;
 
 import java.io.*;
 import java.math.BigDecimal;
 import java.net.HttpURLConnection;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Random;
+import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * 通用工具类
@@ -186,4 +185,26 @@ public class CommonUtil {
         return dest;
     }
 
+    /**
+     * Description: Java8 Stream分割list集合
+     * @param list 集合数据
+     * @param splitSize 几个分割一组
+     * @return 集合分割后的集合
+     */
+    public static <T> List<List<T>> splitList(List<T> list, int splitSize) {
+        //判断集合是否为空
+        if (CollectionUtils.isEmpty(list))
+            return Collections.emptyList();
+        //计算分割后的大小
+        int maxSize = (list.size() + splitSize - 1) / splitSize;
+        //开始分割
+        return Stream.iterate(0, n -> n + 1)
+                .limit(maxSize)
+                .parallel()
+                .map(a -> list.parallelStream().skip(a * splitSize).limit(splitSize).collect(Collectors.toList()))
+                .filter(b -> !b.isEmpty())
+                .collect(Collectors.toList());
+    }
+
+
 }

+ 2 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/entity/ArchivesAuto.java

@@ -144,5 +144,7 @@ public class ArchivesAuto extends BaseEntity {
 	private Integer isOpen;
 	private Integer ischeck;
 
+	//是否案卷收集上传的案卷
+	private Integer isAutoFile;
 
 }

+ 86 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/vo/ArchivesAutoVO.java

@@ -16,10 +16,14 @@
  */
 package org.springblade.archive.vo;
 
+import io.swagger.annotations.ApiModelProperty;
 import org.springblade.archive.entity.ArchivesAuto;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 视图实体类
  *
@@ -31,4 +35,86 @@ import lombok.EqualsAndHashCode;
 public class ArchivesAutoVO extends ArchivesAuto {
 	private static final long serialVersionUID = 1L;
 
+	/**
+	 * 当前页
+	 */
+	@ApiModelProperty("当前页")
+	private Integer current;
+
+	/**
+	 * 当前页
+	 */
+	@ApiModelProperty("当前页显示条数")
+	private Integer size;
+
+	/**
+	 * 输入框查询条件
+	 */
+	@ApiModelProperty("输入框查询条件")
+	private String queryValue;
+
+	/**
+	 * 节点查询条件
+	 */
+	@ApiModelProperty("节点查询条件")
+	private String nodeIds;
+
+	private List<String> nodeIdArray;
+	/**
+	* 案卷收集附件信息
+	* */
+	@ApiModelProperty("附件信息")
+	private List<ApprovalFile> approvalFileList = new ArrayList<>();
+	@Data
+	public static class ApprovalFile {
+
+		/**
+		 * 文件绑定的节点ID
+		 */
+		private String nodeId;
+
+		/**
+		 * 文件编号
+		 */
+		private String fileNumber;
+
+		/**
+		 * 文件名称
+		 */
+		private String fileName;
+
+		/**
+		 * 文件时间
+		 */
+		private String fileTime;
+
+		/**
+		 * 文件路径
+		 */
+		private String fileUrl;
+
+		/**
+		 * PDF文件路径
+		 */
+		private String pdfFileUrl;
+
+		/**
+		 * 文件页数
+		 */
+		private Integer filePage;
+
+		/**
+		 * 是否需要审批,0不需要,1需要
+		 */
+		private Integer isApproval;
+
+		/**
+		 * 是否需要认证,0不需要,1需要
+		 */
+		private Integer isNeedCertification;
+		/**
+		 * 责任者
+		 */
+		private String dutyUser;
+	}
 }

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

@@ -49,10 +49,10 @@ public class TrialDetectionData extends BaseEntity {
     private String testingAgencyCertificateNo;
 
     @ApiModelProperty(value = "样品数量")
-    private Integer materialCount;
+    private String materialCount;
 
     @ApiModelProperty(value = "代表数量")
-    private Integer representativeCount;
+    private String representativeCount;
 
     @ApiModelProperty(value = "取样人")
     private String userName;

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDeviceInfo.java

@@ -3,6 +3,8 @@ package org.springblade.business.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.NullSerializer;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -97,6 +99,7 @@ public class TrialDeviceInfo extends BaseEntity {
      * 校验周期
      */
     @ApiModelProperty(value = "校验周期")
+    @JsonSerialize(nullsUsing = NullSerializer.class)
     private Integer calibrationCycle;
 
     /**

+ 3 - 3
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialLaboratoryUserArchives.java

@@ -46,7 +46,7 @@ public class TrialLaboratoryUserArchives extends BaseEntity {
      * 身份证
      */
     @ApiModelProperty("身份证")
-    private Long idCard;
+    private String idCard;
 
     /**
      * 出生日期
@@ -123,14 +123,14 @@ public class TrialLaboratoryUserArchives extends BaseEntity {
      * 劳动合同起始时间
      */
     @ApiModelProperty("劳动合同起始时间")
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date laborContractStartDate;
 
     /**
      * 劳动合同终止时间
      */
     @ApiModelProperty("劳动合同终止时间")
-    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date laborContractEndDate;
 
     /**

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

@@ -7,6 +7,9 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import org.springblade.core.mp.base.BaseEntity;
 
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.Size;
 import java.math.BigDecimal;
 import java.util.Date;
 

+ 5 - 3
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSampleInfo.java

@@ -3,6 +3,7 @@ package org.springblade.business.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
@@ -35,6 +36,7 @@ public class TrialSampleInfo extends BaseEntity {
      * 取样人id
      */
     @ApiModelProperty(value = "取样人id")
+    @JsonFormat(shape = JsonFormat.Shape.STRING)
     private Long userId;
 
     /**
@@ -80,9 +82,9 @@ public class TrialSampleInfo extends BaseEntity {
     private String batchNumber;
 
     /**
-     * 拟部位
+     * 拟部位
      */
-    @ApiModelProperty(value = "拟部位")
+    @ApiModelProperty(value = "拟部位")
     private String proposedPosition;
 
     /**
@@ -120,7 +122,7 @@ public class TrialSampleInfo extends BaseEntity {
     /**
      * 是否委外 '0'=否 '1'=是
      */
-    @ApiModelProperty(value = "是否外 '0'=否 '1'=是")
+    @ApiModelProperty(value = "是否外 '0'=否 '1'=是")
     private Integer isOutsourcing;
 
     /**

+ 9 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/feign/ArchiveFileClient.java

@@ -2,7 +2,10 @@ package org.springblade.business.feign;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.vo.ArchiveFileVO;
 import org.springblade.common.constant.BusinessConstant;
 import org.springframework.cloud.openfeign.FeignClient;
@@ -46,4 +49,10 @@ public interface ArchiveFileClient {
 
     @PostMapping(API_PREFIX + "/updateArchiveFileByNodeId")
     boolean updateArchiveFileByNodeId(@RequestParam String ids,@RequestParam String nodeId);
+
+    @PostMapping(API_PREFIX + "/listWrappers")
+    List<ArchiveFile> listWrappers(@RequestBody LambdaQueryWrapper<ArchiveFile> in);
+
+    @PostMapping(API_PREFIX + "/updateWrappers")
+    boolean updateWrappers(LambdaUpdateWrapper<ArchiveFile> eq);
 }

+ 5 - 6
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSamplingRecordVO.java

@@ -1,17 +1,15 @@
 package org.springblade.business.vo;
 
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
-import org.springblade.business.entity.TrialSamplingRecord;
 
+import java.io.Serializable;
 import java.util.Date;
 
-@Data
-@EqualsAndHashCode(callSuper = true)
-public class TrialSamplingRecordVO extends TrialSamplingRecord {
 
-    private static final long serialVersionUID = 1L;
+@Data
+public class TrialSamplingRecordVO implements Serializable {
 
     /**
      * 合同段id
@@ -31,6 +29,7 @@ public class TrialSamplingRecordVO extends TrialSamplingRecord {
     /**
      * 取样时间
      */
+    @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd",timezone = "GTM+8")
     private Date samplingDate;
 
     /**

+ 2 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/ArchiveTreeVO2.java

@@ -181,4 +181,6 @@ public class ArchiveTreeVO2 implements INodeEx<ArchiveTreeVO2> {
      */
     private Long fromId;
 
+    private boolean iswbsNode;  //是否为关联的wbs节点
+
 }

+ 14 - 4
blade-service-api/blade-user-api/pom.xml

@@ -12,8 +12,6 @@
     <artifactId>blade-user-api</artifactId>
     <name>${project.artifactId}</name>
     <version>${bladex.project.version}</version>
-    <packaging>jar</packaging>
-
     <dependencies>
         <dependency>
             <groupId>org.springblade</groupId>
@@ -23,9 +21,21 @@
             <groupId>org.springblade</groupId>
             <artifactId>blade-manager-api</artifactId>
             <version>2.9.1.RELEASE</version>
-            <scope>compile</scope>
         </dependency>
-
     </dependencies>
+    <packaging>jar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.4.2</version>
+                <configuration>
+                    <skipTests>true</skipTests>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>

+ 129 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileAutoController.java

@@ -0,0 +1,129 @@
+package org.springblade.archive.controller;
+
+import com.alibaba.excel.util.DateUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.*;
+import lombok.AllArgsConstructor;
+import lombok.SneakyThrows;
+import org.apache.commons.lang.StringUtils;
+import org.springblade.archive.service.IArchivesAutoService;
+import org.springblade.archive.vo.ArchivesAutoVO;
+import org.springblade.business.entity.ArchiveFile;
+import org.springblade.business.feign.ArchiveFileClient;
+import org.springblade.business.vo.ArchiveFileVO;
+import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.evisa.feign.EVisaClient;
+import org.springblade.manager.entity.ArchiveTreeContract;
+import org.springblade.manager.feign.ArchiveTreeContractClient;
+import org.springblade.resource.feign.IOSSClient;
+import org.springblade.system.user.entity.UserOauth;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2022-07-08
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/archiveFileAuto")
+@Api(value = "案卷收集接口", tags = "案卷收集接口")
+public class ArchiveFileAutoController extends BladeController {
+
+    private final ArchiveFileClient archiveFileClient;
+    private final IOSSClient iossClient;
+    private final ArchiveTreeContractClient archiveTreeContractClient;
+    private final EVisaClient eVisaClient;
+    private final IArchivesAutoService archivesAutoService;
+    /**
+     * 批量新增
+     */
+    @PostMapping("/batchSave")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "批量新增")
+    public R<Boolean> batchSave(@RequestBody List<ArchivesAutoVO> archiveList){
+        try {
+            for(ArchivesAutoVO archive : archiveList) {
+                if(archive.getId() == null){
+                    int l = (int) System.currentTimeMillis();
+                    List<ArchivesAutoVO.ApprovalFile> saveList = archive.getApprovalFileList();
+                    ArchiveFileVO saveVos = new ArchiveFileVO();
+                    if (saveList != null && saveList.size() > 0) {
+                        int i = 1;
+                        for (ArchivesAutoVO.ApprovalFile approvalFile : saveList) {
+                            ArchiveFileVO saveVo = BeanUtil.copy(approvalFile, ArchiveFileVO.class);
+                            saveVo.setSort(l + i);
+                            saveVo.setStatus(new Integer("0").equals(saveVo.getIsApproval()) ? 2 : 0);
+                            saveVo.setIsCertification(new Integer("0").equals(saveVo.getIsNeedCertification()) ? 1 : 0);
+                            saveVos.getList().add(saveVo);
+                            i++;
+                        }
+                    }
+                    this.archiveFileClient.saveArchiveFile(saveVos);
+
+                    String archiveId = "";
+                    //获取方式
+                    archiveId = "FromNode_" + archive.getNodeId();
+                    archive.setId(Long.parseLong(archiveId));
+                    //待修改
+                    archive.setIsDeleted(0);
+                    archive.setIsArchive(0);
+                    archive.setIsAutoFile(1);
+                    archivesAutoService.save(archive);
+                }else{
+                    archivesAutoService.updateById(archive);
+                }
+            }
+        } catch (NumberFormatException e) {
+            e.printStackTrace();
+            return R.data(false);
+        }
+        return R.data(true);
+    }
+    /**
+     * 分页
+     */
+    @PostMapping("/page")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "分页")
+    public R<Object> page( ArchivesAutoVO queryVo){
+        if(queryVo.getNodeId() == null || queryVo.getNodeId().equals("")){
+            return  R.data(null);
+        }
+        List<ArchiveTreeContract> archiveTreeContracts = this.archiveTreeContractClient.queryAllChildByAncestors(queryVo.getNodeIds());
+        if(archiveTreeContracts != null && archiveTreeContracts.size() > 0){
+            List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(archiveTreeContracts.stream().map(ArchiveTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
+            ids.add(queryVo.getNodeId().toString());
+            queryVo.setNodeIdArray(ids);
+        }
+
+        return R.data(archivesAutoService.selectArchivesAutoFilePage(queryVo));
+    }
+
+
+    /**
+     * 迁移文件
+     */
+    @PostMapping("/migrateFile")
+    @ApiOperationSupport(order = 9)
+    @ApiOperation(value = "迁移文件", notes = "传入ids")
+    public R migrateFile(@RequestParam String ids,@RequestParam String nodeId) {
+        return R.status(archivesAutoService.updateArchivesAutoFileByNodeId(ids,nodeId));
+    }
+}

+ 50 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileController.java

@@ -1,12 +1,16 @@
 package org.springblade.archive.controller;
 
+import com.alibaba.excel.util.DateUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
+import org.apache.commons.lang.StringUtils;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
 import org.springblade.business.vo.ArchiveFileVO;
@@ -15,6 +19,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
+import org.springblade.evisa.feign.EVisaClient;
 import org.springblade.manager.entity.ArchiveTree;
 import org.springblade.manager.entity.ArchiveTreeContract;
 import org.springblade.manager.feign.ArchiveTreeContractClient;
@@ -23,6 +28,7 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -43,6 +49,7 @@ public class ArchiveFileController extends BladeController {
     private final ArchiveFileClient archiveFileClient;
     private final IOSSClient iossClient;
     private final ArchiveTreeContractClient archiveTreeContractClient;
+    private final EVisaClient eVisaClient;
     /**
      * 上传文件
      *
@@ -177,4 +184,47 @@ public class ArchiveFileController extends BladeController {
     public R migrateFile(@RequestParam String ids,@RequestParam String nodeId) {
         return R.status(this.archiveFileClient.updateArchiveFileByNodeId(ids,nodeId));
     }
+
+    /**
+     * 批量认证(特殊签章 签个透明空白图片,主要目的是在验签的时候有验签信息 )
+     */
+    @PostMapping("/batchCertification")
+    @ApiOperationSupport(order = 9)
+    @ApiOperation(value = "批量认证")
+    public R<Boolean> batchCertification(@RequestBody ArchiveFileVO vo){
+        List<String> list = new ArrayList<>();
+        if(vo.getIds() != null && vo.getIds().size() > 0){
+            //获取文件
+            List<ArchiveFile> archiveFileList = this.archiveFileClient.listWrappers(Wrappers.<ArchiveFile>lambdaQuery().in(ArchiveFile::getId, vo.getIds()));
+            if(archiveFileList != null && archiveFileList.size() > 0){
+                for(ArchiveFile archiveFile : archiveFileList){
+                    //获取文件地址并调用接口认证
+                    String result = this.eVisaClient.certification(StringUtils.isNotEmpty(archiveFile.getEVisaFile()) ? archiveFile.getEVisaFile() : archiveFile.getPdfFileUrl(), archiveFile.getFileName(), archiveFile.getContractId());
+                    if(StringUtils.isNotEmpty(result) && result.contains("success") && result.startsWith("success")){
+                        //成功,更改状态
+                        //签章成功后的文件路径,如果与原pdf文件路径不匹配则更新
+                        String newPdfUrl = null;
+                        if(result.contains("@@@@")){
+                            newPdfUrl = result.split("@@@@")[1];
+                        }
+                        LambdaUpdateWrapper<ArchiveFile> wrappers = Wrappers.lambdaUpdate();
+                        if(StringUtils.isNotEmpty(newPdfUrl) && !archiveFile.getPdfFileUrl().equals(newPdfUrl)){
+                            //不为空且不匹配时,更新
+                            wrappers.set(ArchiveFile::getEVisaFile, newPdfUrl);
+                        }
+                        //修改认证状态为已认证
+                        wrappers.set(ArchiveFile::getIsCertification, 1);
+                        //添加认证时间
+                        wrappers.set(ArchiveFile::getCertificationTime, DateUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
+
+                        //修改状态
+                        this.archiveFileClient.updateWrappers(wrappers.eq(ArchiveFile::getId, archiveFile.getId()));
+                    } else {
+                        list.add(archiveFile.getId().toString());
+                    }
+                }
+            }
+        }
+        return list.size() == 0 ? R.data(true) : R.data(300, false, "没有找到证书文件或PDF文件");
+    }
 }

+ 6 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.archive.mapper;
 
+import org.apache.ibatis.annotations.Param;
 import org.springblade.archive.entity.ArchivesAuto;
 import org.springblade.archive.vo.ArchivesAutoVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -39,4 +40,9 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
 	 */
 	List<ArchivesAutoVO> selectArchivesAutoPage(IPage page, ArchivesAutoVO archivesAuto);
 
+	Integer selectArchivesAutoFileCount(@Param("vo") ArchivesAutoVO vo);
+
+	List<ArchivesAuto> selectArchivesAutoFilePage(@Param("current") Integer current, @Param("size") Integer size, @Param("vo")  ArchivesAutoVO vo);
+
+	Integer updateArchivesAutoFileByNodeId(List<Long> toLongList, String nodeId);
 }

+ 49 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -44,6 +44,7 @@
         <result column="tree_sort" property="nodeSort"/>
         <result column="isOpen" property="isOpen"/>
         <result column="ischeck" property="ischeck"/>
+        <result column="is_auto_file" property="isAutoFile"/>
     </resultMap>
 
 
@@ -51,4 +52,52 @@
         select * from u_archives_auto where is_deleted = 0
     </select>
 
+
+    <select id="selectArchivesAutoFileCount" resultType="java.lang.Integer">
+        select count(id) from u_archives_auto where is_deleted = 0
+        <if test="vo.projectId != null and vo.projectId != ''">
+            and project_id = #{vo.projectId}
+        </if>
+        <if test="vo.contractId != null and vo.contractId != ''">
+            and contract_id = #{vo.contractId}
+        </if>
+        <if test="vo.contractId != null and vo.contractId != ''">
+            and is_auto_file = #{vo.isAutoFile}
+        </if>
+        <if test="vo.nodeIds != null and vo.nodeIds != ''">
+            and node_id in
+            <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                #{nodeId}
+            </foreach>
+        </if>
+    </select>
+
+    <select id="selectArchivesAutoFilePage" resultMap="archivesAutoResultMap">
+        select * from u_archives_auto where is_deleted = 0
+        <if test="vo.projectId != null and vo.projectId != ''">
+            and project_id = #{vo.projectId}
+        </if>
+        <if test="vo.contractId != null and vo.contractId != ''">
+            and contract_id = #{vo.contractId}
+        </if>
+        <if test="vo.isAutoFile != null and vo.isAutoFile != ''">
+            and is_auto_file = #{vo.isAutoFile}
+        </if>
+        <if test="vo.nodeIds != null and vo.nodeIds != ''">
+            and node_id in
+            <foreach collection="vo.nodeIdArray" item="nodeId" open="(" separator="," close=")">
+                #{nodeId}
+            </foreach>
+        </if>
+        order by sort,create_time DESC
+    </select>
+
+    <update id="updateArchivesAutoFileByNodeId" >
+        update u_archives_auto set node_id = #{nodeId} where
+        id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </update>
+
 </mapper>

+ 3 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java

@@ -38,4 +38,7 @@ public interface IArchivesAutoService extends BaseService<ArchivesAuto> {
 	 */
 	IPage<ArchivesAutoVO> selectArchivesAutoPage(IPage<ArchivesAutoVO> page, ArchivesAutoVO archivesAuto);
 
+	IPage<ArchivesAutoVO> selectArchivesAutoFilePage(ArchivesAutoVO queryVo);
+
+	boolean updateArchivesAutoFileByNodeId(String ids, String nodeId);
 }

+ 45 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -16,14 +16,23 @@
  */
 package org.springblade.archive.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import org.apache.commons.lang.StringUtils;
 import org.springblade.archive.entity.ArchivesAuto;
 import org.springblade.archive.vo.ArchivesAutoVO;
 import org.springblade.archive.mapper.ArchivesAutoMapper;
 import org.springblade.archive.service.IArchivesAutoService;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.system.entity.DictBiz;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.util.List;
+
 /**
  *  服务实现类
  *
@@ -38,4 +47,40 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		return page.setRecords(baseMapper.selectArchivesAutoPage(page, archivesAuto));
 	}
 
+	@Override
+	public IPage<ArchivesAutoVO> selectArchivesAutoFilePage(ArchivesAutoVO vo) {
+		Query query = new Query();
+		query.setCurrent(vo.getCurrent());
+		query.setSize(vo.getSize());
+		//设置分页
+		IPage<ArchivesAutoVO> iPage = Condition.getPage(query);
+
+		//汇总
+		Integer total = this.baseMapper.selectArchivesAutoFileCount(vo);
+		if(total == null){
+			total = 0;
+		}
+		//分页
+		int current = (vo.getCurrent() - 1) * vo.getSize();
+
+		List<ArchivesAuto> pageList = this.baseMapper.selectArchivesAutoFilePage(current, vo.getSize(), vo);
+		//设置分页信息
+		iPage.setTotal(total);
+		List<ArchivesAutoVO> pageVoList = JSONArray.parseArray(JSONObject.toJSONString(pageList), ArchivesAutoVO.class);
+
+		return iPage.setRecords(pageVoList);
+	}
+
+	@Override
+	public boolean updateArchivesAutoFileByNodeId(String ids, String nodeId) {
+		try {
+			baseMapper.updateArchivesAutoFileByNodeId(Func.toLongList(ids),nodeId);
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			return false;
+		}
+		return true;
+	}
+
 }

+ 8 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDeviceInfoController.java

@@ -28,6 +28,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/device")
@@ -118,6 +119,13 @@ public class TrialDeviceInfoController extends BladeController {
         return R.status(iTrialDeviceUseService.useSubmit(dto));
     }
 
+    @GetMapping("/use/submit/getSampleInfo")
+    @ApiOperationSupport(order = 11)
+    @ApiOperation(value = "使用设备新增或修改时,获取检测项目关联的样品信息", notes = "传入节点primaryKeyId")
+    public R<Map<String,String>> useSubmitGetSampleInfo(@RequestParam String primaryKeyId) {
+        return R.data(iTrialDeviceUseService.useSubmitGetSampleInfo(primaryKeyId));
+    }
+
     @GetMapping("/use/remove")
     @ApiOperationSupport(order = 12)
     @ApiOperation(value = "使用设备批量删除", notes = "传入ids")

+ 8 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java

@@ -29,6 +29,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
+import java.text.ParseException;
 import java.util.List;
 
 @RestController
@@ -54,6 +55,13 @@ public class TrialMaterialController extends BladeController {
         return R.data(iTrialMaterialMobilizationService.samplingRecordList(id));
     }
 
+    @PostMapping("/mobilization/upload-file")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "附件上传", notes = "传入材料id、type、url地址")
+    public R<Object> uploadFile(@RequestParam String id, Integer type, String url) {
+        return R.data(iTrialMaterialMobilizationService.uploadFile(id, type, url));
+    }
+
     @GetMapping("/mobilization/detail")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "进场材料详情", notes = "传入id")

+ 5 - 3
blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialDeviceInfoExcel.java

@@ -5,6 +5,8 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
 import com.alibaba.excel.annotation.write.style.ContentRowHeight;
 import com.alibaba.excel.annotation.write.style.HeadRowHeight;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.NullSerializer;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -51,7 +53,7 @@ public class TrialDeviceInfoExcel implements Serializable {
     private String accuracy;
 
     @ExcelProperty("效验周期(月)")
-    @JsonFormat(shape = JsonFormat.Shape.STRING)
+    @JsonSerialize(nullsUsing = NullSerializer.class)
     private Integer calibrationCycle;
 
     @ExcelProperty("最近效验时间")
@@ -60,11 +62,11 @@ public class TrialDeviceInfoExcel implements Serializable {
 
     @ExcelProperty("状态")
     @JsonFormat(shape = JsonFormat.Shape.STRING)
-    private Integer status;
+    private String status;
 
     @ExcelProperty("是否需要效验")
     @JsonFormat(shape = JsonFormat.Shape.STRING)
-    private Integer isCalibration;
+    private String isCalibration;
 
     @ExcelProperty("设备采集编号")
     private String equipmentAcquisitionNumber;

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

@@ -30,7 +30,7 @@ public class TrialMaterialMobilizationExcel implements Serializable {
     private String materialName;
 
     @ExcelProperty(value = "材料类型")
-    private Integer materialType;
+    private String materialType;
 
     @ExcelProperty(value = "规格型号")
     private String specificationModel;

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

@@ -49,7 +49,7 @@ public class TrialSampleInfoExcel implements Serializable {
     @ExcelProperty(value = "生产批号")
     private String batchNumber;
 
-    @ExcelProperty(value = "拟部位")
+    @ExcelProperty(value = "拟部位")
     private String proposedPosition;
 
     @ExcelProperty(value = "供应商单位")
@@ -69,7 +69,7 @@ public class TrialSampleInfoExcel implements Serializable {
     @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
     private Date samplingDate;
 
-    @ExcelProperty(value = "是否外")
-    private Integer isOutsourcing;
+    @ExcelProperty(value = "是否外")
+    private String isOutsourcing;
 
 }

+ 13 - 0
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java

@@ -2,8 +2,11 @@ package org.springblade.business.feignClient;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import lombok.AllArgsConstructor;
+import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.feign.ArchiveFileClient;
 import org.springblade.business.service.IArchiveFileService;
 import org.springblade.business.vo.ArchiveFileVO;
@@ -61,4 +64,14 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
     public boolean updateArchiveFileByNodeId(String ids, String nodeId) {
         return this.iArchiveFileService.updateArchiveFileByNodeId(ids,nodeId);
     }
+
+    @Override
+    public List<ArchiveFile> listWrappers(LambdaQueryWrapper<ArchiveFile> in) {
+        return this.iArchiveFileService.list(in);
+    }
+
+    @Override
+    public boolean updateWrappers(LambdaUpdateWrapper<ArchiveFile> eq) {
+        return this.iArchiveFileService.update(eq);
+    }
 }

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

@@ -30,7 +30,7 @@
     </resultMap>
 
     <select id="selectTrialTreeAll" resultType="org.springblade.manager.entity.WbsTreePrivate">
-        select * from m_wbs_tree_private where project_id = #{projectId} and wbs_type = 2 and status = 1 and is_deleted = 0
+        select p_key_id,id,node_name from m_wbs_tree_private where project_id = #{projectId} and wbs_type = 2 and status = 1 and is_deleted = 0
     </select>
 
 </mapper>

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

@@ -9,6 +9,7 @@ import org.springblade.core.mp.base.BaseService;
 
 import javax.servlet.http.HttpServletResponse;
 import java.util.List;
+import java.util.Map;
 
 public interface ITrialDeviceUseService extends BaseService<TrialDeviceUse> {
 
@@ -22,4 +23,6 @@ public interface ITrialDeviceUseService extends BaseService<TrialDeviceUse> {
 
     boolean importBatchDeviceUse(List<TrialDeviceUseExcel> list, Long projectId, Long contractId);
 
+    Map<String,String> useSubmitGetSampleInfo(String primaryKeyId);
+
 }

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

@@ -9,6 +9,7 @@ import org.springblade.business.vo.TrialSamplingRecordVO;
 import org.springblade.core.mp.base.BaseService;
 
 import javax.servlet.http.HttpServletResponse;
+import java.text.ParseException;
 import java.util.List;
 
 
@@ -32,4 +33,6 @@ public interface ITrialMaterialMobilizationService extends BaseService<TrialMate
 
     List<TrialSamplingRecordVO> samplingRecordList(Long id);
 
+    boolean uploadFile(String id, Integer type, String url);
+
 }

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialContainerClassificationServiceImpl.java

@@ -230,6 +230,11 @@ public class TrialContainerClassificationServiceImpl
                     String s1 = s.split(" ")[0];
                     objectObjectEntry.setValue(s1);
                 }
+                if (objectObjectEntry.getValue().toString().contains(" 00:00:00.0")) {
+                    Object value = objectObjectEntry.getValue();
+                    String replace = value.toString().replace(" 00:00:00.0", "");
+                    objectObjectEntry.setValue(replace);
+                }
             }
         }
         return page.setRecords(hashMaps);

+ 65 - 25
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceInfoServiceImpl.java

@@ -3,10 +3,7 @@ package org.springblade.business.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Font;
-import com.lowagie.text.Paragraph;
+import com.lowagie.text.*;
 import com.lowagie.text.pdf.BaseFont;
 import com.lowagie.text.pdf.PdfPTable;
 import com.lowagie.text.pdf.PdfWriter;
@@ -25,6 +22,7 @@ import org.springblade.business.vo.TrialDeviceInfoVO3;
 import org.springblade.business.wrapper.TrialDeviceInfoWarpper;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SystemUtils;
+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;
@@ -56,14 +54,25 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
 
     @Override
     public boolean submit(TrialDeviceInfo obj) {
-        if (ObjectUtil.isNotEmpty(obj.getId())) {
+        TrialDeviceInfo selectOne = baseMapper.selectOne(Wrappers.<TrialDeviceInfo>lambdaQuery().select(TrialDeviceInfo::getId, TrialDeviceInfo::getDeviceName).eq(TrialDeviceInfo::getDeviceNumber, obj.getDeviceNumber()));
+
+        if (ObjectUtil.isNotEmpty(obj.getId())) { //编辑
+            if (ObjectUtil.isNotEmpty(selectOne) && !selectOne.getId().equals(obj.getId())) {
+                throw new ServiceException("当前设备编号已存在,请重新填写");
+            }
+
             TrialDeviceInfo trialDeviceInfo = baseMapper.selectById(obj.getId());
             if (ObjectUtil.isNotEmpty(trialDeviceInfo.getLastCalibrationTime()) && ObjectUtil.isNotEmpty(obj.getLastCalibrationTime())
                     && !trialDeviceInfo.getLastCalibrationTime().equals(obj.getLastCalibrationTime())) {
                 //如果修改了最近校验时间,那么每次编辑默认修改校验为0=否
                 obj.setIsCalibration(0);
             }
+        } else { //新增
+            if (ObjectUtil.isNotEmpty(selectOne)) {
+                throw new ServiceException("当前设备编号已存在,请重新填写");
+            }
         }
+
         return this.saveOrUpdate(obj);
     }
 
@@ -113,9 +122,19 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
         List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
 
         QueryWrapper<TrialDeviceInfo> queryWrapper = Condition.getQueryWrapper(obj);
-        if (ObjectUtil.isNotEmpty(obj.getDeviceClassId())) {
-            queryWrapper.lambda().eq(TrialDeviceInfo::getDeviceClassId, obj.getDeviceClassId());
+
+        if (ObjectUtil.isEmpty(obj.getDeviceClassId()) || obj.getDeviceClassId() == 0) {
+            List<Long> ids = deviceClassifications.stream().map(TrialDeviceClassification::getId).collect(Collectors.toList());
+            if (ids.size() > 0) {
+                obj.setDeviceClassId(null);
+                queryWrapper.lambda().in(TrialDeviceInfo::getDeviceClassId, ids);
+            }
+        } else {
+            if (ObjectUtil.isNotEmpty(obj.getDeviceClassId())) {
+                queryWrapper.lambda().eq(TrialDeviceInfo::getDeviceClassId, obj.getDeviceClassId());
+            }
         }
+
         if (ObjectUtil.isNotEmpty(obj.getIsCalibration())) {
             queryWrapper.lambda().eq(TrialDeviceInfo::getIsCalibration, obj.getIsCalibration());
         }
@@ -166,7 +185,7 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
             }
 
             //创建文档,设置页面大小、左右上下边距
-            Document document = new Document();
+            Document document = new Document(new RectangleReadOnly(842F, 595F)); //横向pdf
 
             BaseFont bfChinese = null;
             String pdfUrl = null;
@@ -233,30 +252,39 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
             document.add(tableTitle);
             document.add(new Paragraph("\n"));
 
-            String[] array = {"ID", "设备名称", "设备分类", "设备编号", "设备型号", "生产厂家", "出厂日期", "出厂编号", "进场日期", "测量范围",
-                    "精准度", "校准周期(月)", "最近校验时间", "状态", "是否需要校验", "设备采集编号", "设备管理人员", "备注"};
+            String[] array = {"ID", "设备名称", "设备分类", "设备编号", "设备型号", "生产厂家", "出厂日期", "出厂编号", "进场日期", "测量范围", "精准度", "校准周期(月)", "最近校验时间", "状态", "是否需要校验", "设备采集编号", "设备管理人员", "备注"};
             for (String s : array) {
                 PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
             }
             for (TrialDeviceInfo pdfDatum : pdfData) {
                 PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(pdfDatum.getDeviceName(), textFont, table, lineHeight, colSpan);
+
+                String className = "";
                 for (TrialDeviceClassification classification : deviceClassificationList) {
                     if (classification.getId().equals(pdfDatum.getDeviceClassId())) {
-                        PDFUtil.createTableCell(classification.getClassName(), textFont, table, lineHeight, colSpan);
+                        className = classification.getClassName();
+                        break;
                     }
                 }
+                PDFUtil.createTableCell(className, textFont, table, lineHeight, colSpan);
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceNumber()) ? pdfDatum.getDeviceNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceModel()) ? pdfDatum.getDeviceModel() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManufacturer()) ? pdfDatum.getManufacturer() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryDate()) ? pdfDatum.getFactoryDate().toString() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryNumber()) ? pdfDatum.getFactoryNumber() : "", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getEquipmentAcquisitionNumber()) ? pdfDatum.getEquipmentAcquisitionNumber() : "", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getAccuracy()) ? pdfDatum.getAccuracy() : "", textFont, table, lineHeight, colSpan);
+
+                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMobilizationDate()) ? DateUtil.format(pdfDatum.getMobilizationDate(), "yyyy-MM-dd") : "", textFont, table, lineHeight, colSpan);
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMeasuringRange()) ? pdfDatum.getMeasuringRange() : "", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getLastCalibrationTime()) ? pdfDatum.getLastCalibrationTime().toString() : "", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(pdfDatum.getStatus().equals(0) ? "已停用" : "启用中", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(pdfDatum.getIsCalibration().equals(0) ? "否" : "是", textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getAccuracy()) ? pdfDatum.getAccuracy() : "", textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getCalibrationCycle()) ? pdfDatum.getCalibrationCycle().toString() : "", textFont, table, lineHeight, colSpan);
+
+                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getLastCalibrationTime()) ? DateUtil.format(pdfDatum.getLastCalibrationTime(), "yyyy-MM-dd") : "", textFont, table, lineHeight, colSpan);
+
+                PDFUtil.createTableCell(new Integer(0).equals(pdfDatum.getStatus()) ? "已停用" : "启用中", textFont, table, lineHeight, colSpan);
+                PDFUtil.createTableCell(new Integer(0).equals(pdfDatum.getIsCalibration()) ? "否" : "是", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getEquipmentAcquisitionNumber()) ? pdfDatum.getEquipmentAcquisitionNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManagerName()) ? pdfDatum.getManagerName() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getRemarks()) ? pdfDatum.getRemarks() : "", textFont, table, lineHeight, colSpan);
@@ -305,19 +333,31 @@ public class TrialDeviceInfoServiceImpl extends BaseServiceImpl<TrialDeviceInfoM
         List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
         List<TrialDeviceInfo> listData = new ArrayList<>();
         for (TrialDeviceInfoExcel trialDeviceInfoExcel : list) {
-            for (TrialDeviceClassification deviceClassification : deviceClassifications) {
-                if (trialDeviceInfoExcel.getDeviceClassName().equals(deviceClassification.getClassName())) {
-                    TrialDeviceInfo trialDeviceInfo = BeanUtil.copyProperties(trialDeviceInfoExcel, TrialDeviceInfo.class);
-                    if (trialDeviceInfo != null) {
-                        trialDeviceInfo.setStatus(trialDeviceInfoExcel.getStatus().equals(1) ? 1 : 0);
-                        trialDeviceInfo.setIsCalibration(trialDeviceInfoExcel.getIsCalibration().equals(1) ? 1 : 0);
-                        trialDeviceInfo.setDeviceClassId(deviceClassification.getId());
-                        listData.add(trialDeviceInfo);
+            if (ObjectUtil.isNotEmpty(trialDeviceInfoExcel.getDeviceClassName())) {
+                for (TrialDeviceClassification deviceClassification : deviceClassifications) {
+                    if (trialDeviceInfoExcel.getDeviceClassName().equals(deviceClassification.getClassName())) {
+                        TrialDeviceInfo trialDeviceInfo = BeanUtil.copyProperties(trialDeviceInfoExcel, TrialDeviceInfo.class);
+                        if (trialDeviceInfo != null) {
+                            trialDeviceInfo.setStatus(("已启用").equals(trialDeviceInfoExcel.getStatus()) ? 1 : 0);
+                            trialDeviceInfo.setIsCalibration(("是").equals(trialDeviceInfoExcel.getIsCalibration()) ? 1 : 0);
+                            trialDeviceInfo.setDeviceClassId(deviceClassification.getId());
+                            listData.add(trialDeviceInfo);
+                        }
                     }
                 }
             }
         }
-        return this.saveBatch(listData, 1000);
+        if (listData.size() > 0) {
+            List<String> numbers = listData.stream().map(TrialDeviceInfo::getDeviceNumber).collect(Collectors.toList());
+            List<TrialDeviceInfo> trialDeviceInfos = baseMapper.selectList(Wrappers.<TrialDeviceInfo>lambdaQuery().select(TrialDeviceInfo::getId, TrialDeviceInfo::getDeviceName).in(TrialDeviceInfo::getDeviceNumber, numbers));
+            if (trialDeviceInfos.size() > 0) {
+                List<String> collect = trialDeviceInfos.stream().map(TrialDeviceInfo::getDeviceName).collect(Collectors.toList());
+                throw new ServiceException("【" + StringUtils.join(collect, ",") + "】的设备编号重复,请重新填写设备编号");
+            }
+
+            return this.saveBatch(listData, 1000);
+        }
+        return true;
     }
 
     @Override

+ 23 - 6
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceOverhaulServiceImpl.java

@@ -17,6 +17,7 @@ import org.springblade.business.dto.TrialDeviceOverhaulDTO;
 import org.springblade.business.entity.TrialDeviceClassification;
 import org.springblade.business.entity.TrialDeviceInfo;
 import org.springblade.business.entity.TrialDeviceOverhaul;
+import org.springblade.business.entity.TrialDeviceUse;
 import org.springblade.business.excel.TrialDeviceOverhaulExcel;
 import org.springblade.business.mapper.TrialDeviceClassificationMapper;
 import org.springblade.business.mapper.TrialDeviceInfoMapper;
@@ -70,7 +71,7 @@ public class TrialDeviceOverhaulServiceImpl extends BaseServiceImpl<TrialDeviceO
             dto.setFactoryNumber(trialDeviceInfo.getFactoryNumber());
         }
         TrialDeviceOverhaul trialDeviceOverhaul = BeanUtil.copyProperties(dto, TrialDeviceOverhaul.class);
-        if (trialDeviceOverhaul != null){
+        if (trialDeviceOverhaul != null) {
             return this.saveOrUpdate(trialDeviceOverhaul);
         }
         return false;
@@ -82,11 +83,21 @@ public class TrialDeviceOverhaulServiceImpl extends BaseServiceImpl<TrialDeviceO
         List<TrialDeviceClassification> deviceClassificationList = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
 
         QueryWrapper<TrialDeviceOverhaul> queryWrapper = Condition.getQueryWrapper(dto);
-        if (ObjectUtil.isNotEmpty(dto.getDeviceClassId())) {
-            queryWrapper.lambda().eq(TrialDeviceOverhaul::getDeviceClassId, dto.getDeviceClassId());
+
+        if (ObjectUtil.isEmpty(dto.getDeviceClassId()) || dto.getDeviceClassId() == 0) {
+            List<Long> ids = deviceClassificationList.stream().map(TrialDeviceClassification::getId).collect(Collectors.toList());
+            if (ids.size() > 0) {
+                dto.setDeviceClassId(null);
+                queryWrapper.lambda().in(TrialDeviceOverhaul::getDeviceClassId, ids);
+            }
+        } else {
+            if (ObjectUtil.isNotEmpty(dto.getDeviceClassId())) {
+                queryWrapper.lambda().eq(TrialDeviceOverhaul::getDeviceClassId, dto.getDeviceClassId());
+            }
         }
+
         if (ObjectUtil.isNotEmpty(dto.getQueryValue())) {
-            queryWrapper.lambda().and(wrapper -> wrapper.like(TrialDeviceOverhaul::getDeviceName, dto.getDeviceName()).or().like(TrialDeviceOverhaul::getDeviceModel, dto.getDeviceModel()));
+            queryWrapper.lambda().and(wrapper -> wrapper.like(TrialDeviceOverhaul::getDeviceName, dto.getQueryValue()).or().like(TrialDeviceOverhaul::getDeviceModel, dto.getQueryValue()));
         }
         if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) {
             String endTime = dto.getEndTime();
@@ -203,16 +214,22 @@ public class TrialDeviceOverhaulServiceImpl extends BaseServiceImpl<TrialDeviceO
             for (TrialDeviceOverhaul pdfDatum : pdfData) {
                 PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(pdfDatum.getDeviceName(), textFont, table, lineHeight, colSpan);
+
+                String className = "";
                 for (TrialDeviceClassification classification : deviceClassificationList) {
                     if (classification.getId().equals(pdfDatum.getDeviceClassId())) {
-                        PDFUtil.createTableCell(classification.getClassName(), textFont, table, lineHeight, colSpan);
+                        className = classification.getClassName();
                         break;
                     }
                 }
+                PDFUtil.createTableCell(className, textFont, table, lineHeight, colSpan);
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceNumber()) ? pdfDatum.getDeviceNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceModel()) ? pdfDatum.getDeviceModel() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryNumber()) ? pdfDatum.getFactoryNumber() : "", textFont, table, lineHeight, colSpan);
-                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getOverhaulDate()) ? pdfDatum.getOverhaulDate().toString() : "", textFont, table, lineHeight, colSpan);
+
+                PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getOverhaulDate()) ? DateUtil.format(pdfDatum.getOverhaulDate(), "yyyy-MM-dd") : "", textFont, table, lineHeight, colSpan);
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getOverhaulText()) ? pdfDatum.getOverhaulText() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManagerName()) ? pdfDatum.getManagerName() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getRemarks()) ? pdfDatum.getRemarks() : "", textFont, table, lineHeight, colSpan);

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

@@ -15,16 +15,15 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
 import org.springblade.business.dto.TrialDeviceUseDTO;
 import org.springblade.business.dto.TrialSelfInspectionRecordDTO;
-import org.springblade.business.entity.TrialDeviceClassification;
-import org.springblade.business.entity.TrialDeviceInfo;
+import org.springblade.business.entity.*;
 import org.springblade.business.excel.TrialDeviceUseExcel;
 import org.springblade.business.mapper.TrialDeviceClassificationMapper;
 import org.springblade.business.mapper.TrialDeviceInfoMapper;
 import org.springblade.business.utils.PDFUtil;
 import org.springblade.business.vo.TrialDeviceUsePageVO;
-import org.springblade.business.entity.TrialDeviceUse;
 import org.springblade.business.mapper.TrialDeviceUseMapper;
 import org.springblade.business.service.ITrialDeviceUseService;
+import org.springblade.business.vo.TrialSelfSample;
 import org.springblade.business.wrapper.TrialDeviceUseWarpper;
 import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
@@ -38,6 +37,8 @@ import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ObjectUtil;
 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;
 
@@ -46,7 +47,9 @@ import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service
@@ -56,6 +59,8 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
     private final NewIOSSClient newIOSSClient;
     private final TrialDeviceClassificationMapper trialDeviceClassificationMapper;
     private final TrialDeviceInfoMapper trialDeviceInfoMapper;
+    private final TrialSampleInfoServiceImpl trialSampleInfoService;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public TrialDeviceUse useDetail(Long id) {
@@ -87,9 +92,19 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
         List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectTrialTreeAll(String.valueOf(projectId), 2);
 
         QueryWrapper<TrialDeviceUse> queryWrapper = Condition.getQueryWrapper(dto);
-        if (ObjectUtil.isNotEmpty(dto.getDeviceClassId())) {
-            queryWrapper.lambda().eq(TrialDeviceUse::getDeviceClassId, dto.getDeviceClassId());
+
+        if (ObjectUtil.isEmpty(dto.getDeviceClassId()) || dto.getDeviceClassId() == 0) {
+            List<Long> ids = deviceClassificationList.stream().map(TrialDeviceClassification::getId).collect(Collectors.toList());
+            if (ids.size() > 0) {
+                dto.setDeviceClassId(null);
+                queryWrapper.lambda().in(TrialDeviceUse::getDeviceClassId, ids);
+            }
+        } else {
+            if (ObjectUtil.isNotEmpty(dto.getDeviceClassId())) {
+                queryWrapper.lambda().eq(TrialDeviceUse::getDeviceClassId, dto.getDeviceClassId());
+            }
         }
+
         if (ObjectUtil.isNotEmpty(dto.getQueryValue())) {
             queryWrapper.lambda().and(wrapper -> wrapper.like(TrialDeviceUse::getDeviceName, dto.getDeviceName()).or().like(TrialDeviceUse::getDeviceModel, dto.getDeviceModel()));
         }
@@ -101,15 +116,19 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
         IPage<TrialDeviceUse> resultPages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialDeviceUse::getCreateTime));
         IPage<TrialDeviceUsePageVO> trialDeviceUsePageDTOIPage = TrialDeviceUseWarpper.build().pageVO(resultPages);
         List<TrialDeviceUsePageVO> records = trialDeviceUsePageDTOIPage.getRecords();
+
         for (TrialDeviceUsePageVO record : records) {
             for (TrialDeviceClassification classification : deviceClassificationList) {
                 if (record.getDeviceClassId().equals(classification.getId())) {
                     record.setDeviceClassName(classification.getClassName());
+                    break;
                 }
             }
+
             for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
                 if (ObjectUtil.isNotEmpty(record.getNodeId()) && record.getNodeId().equals(wbsTreePrivate.getPKeyId())) {
                     record.setNodeName(wbsTreePrivate.getNodeName());
+                    break;
                 }
             }
         }
@@ -128,7 +147,7 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
             //获取设备分类数据
             List<TrialDeviceClassification> deviceClassificationList = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
             //获取当前试验树
-            List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectTrialTreeAll(projectId, 2);
+            List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectTrialTreeAll(String.valueOf(projectId), 2);
 
             //删除旧PDF
             List<String> pdfUrls = pdfData.stream().map(TrialDeviceUse::getPdfUrl).distinct().collect(Collectors.toList());
@@ -208,31 +227,40 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
             document.add(tableTitle);
             document.add(new Paragraph("\n"));
 
-            String[] array = {"序号", "设备名称", "设备分类", "设备编号", "设备型号", "出厂编号", "使用日期(起)", "使用日期(止)",
-                    "检测试验项目", "样品编号", "样品名称", "使用人", "备注"};
+            String[] array = {"序号", "设备名称", "设备分类", "设备编号", "设备型号", "出厂编号", "使用日期(起)", "使用日期(止)", "检测试验项目", "样品编号", "样品名称", "使用人", "备注"};
             for (String s : array) {
                 PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
             }
             for (TrialDeviceUse pdfDatum : pdfData) {
                 PDFUtil.createTableCell(String.valueOf(pdfDatum.getId()), textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(pdfDatum.getDeviceName(), textFont, table, lineHeight, colSpan);
+
+                String className = "";
                 for (TrialDeviceClassification classification : deviceClassificationList) {
                     if (classification.getId().equals(pdfDatum.getDeviceClassId())) {
-                        PDFUtil.createTableCell(classification.getClassName(), textFont, table, lineHeight, colSpan);
+                        className = classification.getClassName();
                         break;
                     }
                 }
+                PDFUtil.createTableCell(className, textFont, table, lineHeight, colSpan);
+
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceNumber()) ? pdfDatum.getDeviceNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getDeviceModel()) ? pdfDatum.getDeviceModel() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getFactoryNumber()) ? pdfDatum.getFactoryNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getStartDate()) ? pdfDatum.getStartDate().toString() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getEndDate()) ? pdfDatum.getEndDate().toString() : "", textFont, table, lineHeight, colSpan);
+
+                String nodeName = "";
                 for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
                     if (pdfDatum.getNodeId().equals(wbsTreePrivate.getPKeyId())) {
-                        PDFUtil.createTableCell(wbsTreePrivate.getNodeName(), textFont, table, lineHeight, colSpan);
+                        nodeName = wbsTreePrivate.getNodeName();
                         break;
                     }
                 }
+                PDFUtil.createTableCell(nodeName, textFont, table, lineHeight, colSpan);
+
+
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getSpecificationNumber()) ? pdfDatum.getSpecificationNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMaterialName()) ? pdfDatum.getMaterialName() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getManagerName()) ? pdfDatum.getManagerName() : "", textFont, table, lineHeight, colSpan);
@@ -280,7 +308,9 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
     @Override
     public boolean importBatchDeviceUse(List<TrialDeviceUseExcel> list, Long projectId, Long contractId) {
         //获取当前合同段的设备分类
-        List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda().eq(TrialDeviceClassification::getContractId, contractId));
+        List<TrialDeviceClassification> deviceClassifications = trialDeviceClassificationMapper.selectList(Wrappers.<TrialDeviceClassification>query().lambda()
+                .select(TrialDeviceClassification::getId, TrialDeviceClassification::getClassName)
+                .eq(TrialDeviceClassification::getContractId, contractId));
         //获取当前项目试验树
         List<WbsTreePrivate> wbsTreePrivates = baseMapper.selectTrialTreeAll(String.valueOf(projectId), 2);
 
@@ -300,7 +330,7 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
             for (WbsTreePrivate wbsTreePrivate : wbsTreePrivates) {
                 if (trialDeviceUseExcel.getNodeName().equals(wbsTreePrivate.getNodeName())) {
                     if (trialDeviceUse != null) {
-                        trialDeviceUse.setNodeId(wbsTreePrivate.getId());
+                        trialDeviceUse.setNodeId(wbsTreePrivate.getPKeyId());
                         break;
                     }
                 }
@@ -310,6 +340,35 @@ public class TrialDeviceUseServiceImpl extends BaseServiceImpl<TrialDeviceUseMap
         return this.saveBatch(listData, 1000);
     }
 
+    @Override
+    public Map<String, String> useSubmitGetSampleInfo(String primaryKeyId) {
+        //获取所有试验记录
+        List<TrialSelfInspectionRecord> trialSelfInspectionRecords = jdbcTemplate.query("select id from u_trial_self_inspection_record where node_id = " + primaryKeyId, new BeanPropertyRowMapper<>(TrialSelfInspectionRecord.class));
+
+        //获取当前节点下所有试验记录下的关联的所有样品信息
+        if (trialSelfInspectionRecords.size() > 0) {
+            List<Long> ids = trialSelfInspectionRecords.stream().map(TrialSelfInspectionRecord::getId).collect(Collectors.toList());
+            if (ids.size() > 0) {
+                List<TrialSelfSample> query = jdbcTemplate.query("select sampling_id from u_trial_self_sample where self_id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(TrialSelfSample.class));
+                List<Long> collect = query.stream().map(TrialSelfSample::getSamplingId).collect(Collectors.toList());
+                if (collect.size() > 0) {
+                    List<TrialSampleInfo> trialSampleInfos = trialSampleInfoService.getBaseMapper().selectList(Wrappers.<TrialSampleInfo>lambdaQuery()
+                            .select(TrialSampleInfo::getSpecificationNumber, TrialSampleInfo::getMaterialName)
+                            .in(TrialSampleInfo::getId, collect));
+                    Map<String, String> map = new HashMap<>();
+                    if (trialSampleInfos.size() > 0) {
+                        List<String> names = trialSampleInfos.stream().map(TrialSampleInfo::getMaterialName).collect(Collectors.toList());
+                        List<String> numbers = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationNumber).collect(Collectors.toList());
+                        map.put("sampleNames", StringUtils.join(names, "、"));
+                        map.put("sampleNumbers", StringUtils.join(numbers, "、"));
+                        return map;
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
     @Async
     public void addDeviceUseInfo(TrialSelfInspectionRecordDTO dto) {
         if (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(dto.getDeviceUseIds())) {

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

@@ -71,7 +71,7 @@ public class TrialLaboratoryUserArchivesServiceImpl
         if (StringUtils.isNotEmpty(pageVO.getQueryValue())) {
             queryWrapper.lambda().like(TrialLaboratoryUserArchives::getName, pageVO.getQueryValue());
         }
-        IPage<TrialLaboratoryUserArchives> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialLaboratoryUserArchives::getCreateTime));
+        IPage<TrialLaboratoryUserArchives> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TrialLaboratoryUserArchives::getCreateTime));
         IPage<TrialLaboratoryUserArchivesPageVO> archivesPageVOIPage = TrialLaboratoryUserArchivesWarpper.build().pageVO(pages);
         List<TrialLaboratoryUserArchivesPageVO> records = archivesPageVOIPage.getRecords();
 

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

@@ -42,10 +42,16 @@ import org.springblade.system.entity.Dict;
 import org.springblade.system.feign.IDictClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
+import java.math.BigDecimal;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -58,6 +64,7 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
     private final TrialSampleInfoMapper trialSampleInfoMapper;
     private final TrialSamplingRecordMapper trialSamplingRecordMapper;
     private final NewIOSSClient newIOSSClient;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public boolean mobilizationVerification(String number, String id) {
@@ -97,6 +104,11 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
         }
         List<TrialMaterialMobilization> list = new ArrayList<>();
         for (TrialMaterialMobilizationDTO trialMaterialMobilizationDTO : dto) {
+            List<TrialMaterialMobilization> query = jdbcTemplate.query("select id,material_name from u_trial_material_mobilization where material_number = '" + trialMaterialMobilizationDTO.getMaterialNumber() + "'", new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
+            if (query.size() > 0) {
+                TrialMaterialMobilization trialMaterialMobilization = query.stream().findAny().orElse(null);
+                throw new ServiceException("材料【" + trialMaterialMobilization.getMaterialName() + "】的编号重复,请重新填写");
+            }
             trialMaterialMobilizationDTO.setId(SnowFlakeUtil.getId());
             list.add(trialMaterialMobilizationDTO);
         }
@@ -145,9 +157,24 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
         if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
             throw new ServiceException("获取用户信息失败");
         }
+
+        //材料类型
+        List<Dict> materialTypes = iDictClient.getList("material_type").getData();
+
         data.forEach(excel -> {
             TrialMaterialMobilization trialMaterialMobilization = BeanUtil.copyProperties(excel, TrialMaterialMobilization.class);
-            if (trialMaterialMobilization != null){
+            if (trialMaterialMobilization != null) {
+                List<TrialMaterialMobilization> query = jdbcTemplate.query("select id,material_name from u_trial_material_mobilization where material_number = '" + trialMaterialMobilization.getMaterialNumber() + "'", new BeanPropertyRowMapper<>(TrialMaterialMobilization.class));
+                if (query.size() > 0) {
+                    TrialMaterialMobilization obj = query.stream().findAny().orElse(null);
+                    throw new ServiceException("材料【" + obj.getMaterialName() + "】的编号重复,导入失败");
+                }
+                for (Dict materialType : materialTypes) {
+                    if (excel.getMaterialType().equals(materialType.getDictValue())) {
+                        trialMaterialMobilization.setMaterialType(Integer.parseInt(materialType.getDictKey()));
+                        break;
+                    }
+                }
                 trialMaterialMobilization.setUserId(SecureUtil.getUserId());
                 trialMaterialMobilization.setContractId(contractId);
                 list.add(trialMaterialMobilization);
@@ -170,13 +197,7 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
             //构造数据
             List<TrialMaterialMobilization> list = baseMapper.selectBatchIds(Func.toLongList(ids)).stream()
                     .sorted(Comparator.comparing(TrialMaterialMobilization::getMobilizationDate, Comparator.nullsLast(Date::compareTo))).collect(Collectors.toList());
-            List<TrialMaterialMobilizationVO> pdfData = BeanUtil.copyProperties(list, TrialMaterialMobilizationVO.class);
-
-            //材料类型
-            R<List<Dict>> typeList = iDictClient.getList("material_type");
-
-            //获取所有用户信息
-            List<User> userList = iUserClient.selectUserAll();
+            //List<TrialMaterialMobilization> list = new ArrayList<>(baseMapper.selectBatchIds(Func.toLongList(ids)));
 
             //删除旧PDF
             List<String> pdfUrls = list.stream().map(TrialMaterialMobilization::getPdfUrl).distinct().collect(Collectors.toList());
@@ -255,22 +276,31 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
             document.add(tableTitle);
             document.add(new Paragraph("\n"));
 
-            String[] array = {"材料编号", "进场日期", "材料名称", "材料类型", "规格型号", "供应商单位", "材料单价", "材料数量",
-                    "计算单位", "生产批号", "上产地/厂家", "拟用部位", "记录人"};
+            String[] array = {"材料编号", "进场日期", "材料名称", "材料类型", "规格型号", "供应商单位", "材料单价", "材料数量", "计算单位", "生产批号", "上产地/厂家", "拟用部位", "记录人"};
             for (String s : array) {
                 PDFUtil.createTableCell(s, textFont, table, lineHeight, colSpan);
             }
-            for (TrialMaterialMobilizationVO pdfDatum : pdfData) {
+
+            //材料类型
+            R<List<Dict>> typeList = iDictClient.getList("material_type");
+
+            //获取所有用户信息
+            List<User> userList = iUserClient.selectUserAll();
+
+            for (TrialMaterialMobilization pdfDatum : list) {
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMaterialNumber()) ? pdfDatum.getMaterialNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMobilizationDate()) ? DateUtil.formatDate(pdfDatum.getMobilizationDate()) : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMaterialName()) ? pdfDatum.getMaterialName() : "", textFont, table, lineHeight, colSpan);
 
+                String materialTypeName = "";
                 for (Dict type : typeList.getData()) {
                     if (type.getDictKey().equals(pdfDatum.getMaterialType().toString())) {
-                        PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getMaterialType()) ? pdfDatum.getMaterialType().toString() : type.getDictValue(), textFont, table, lineHeight, colSpan);
+                        materialTypeName = type.getDictValue();
                         break;
                     }
                 }
+                PDFUtil.createTableCell(materialTypeName, textFont, table, lineHeight, colSpan);
+
 
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getSpecificationModel()) ? pdfDatum.getSpecificationModel() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getSupplierUnit()) ? pdfDatum.getSupplierUnit() : "", textFont, table, lineHeight, colSpan);
@@ -280,12 +310,16 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getBatchNumber()) ? pdfDatum.getBatchNumber() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getPlaceOfProduction()) ? pdfDatum.getPlaceOfProduction() : "", textFont, table, lineHeight, colSpan);
                 PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getProposedPosition()) ? pdfDatum.getProposedPosition() : "", textFont, table, lineHeight, colSpan);
+
+                String userName = "";
                 for (User user : userList) {
                     if (pdfDatum.getUserId().equals(user.getId())) {
-                        PDFUtil.createTableCell(ObjectUtil.isNotEmpty(pdfDatum.getUserName()) ? pdfDatum.getUserName() : user.getName(), textFont, table, lineHeight, colSpan);
+                        userName = user.getName();
                         break;
                     }
                 }
+                PDFUtil.createTableCell(userName, textFont, table, lineHeight, colSpan);
+
             }
 
             document.add(table);
@@ -353,5 +387,28 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
         return list;
     }
 
+    @Override
+    public boolean uploadFile(String id, Integer type, String url) {
+        if (type == 1) {
+            this.update(Wrappers.<TrialMaterialMobilization>lambdaUpdate()
+                    .set(TrialMaterialMobilization::getProductionCertificate, url)
+                    .eq(TrialMaterialMobilization::getId, id));
+            return true;
+        }
+        if (type == 2) {
+            this.update(Wrappers.<TrialMaterialMobilization>lambdaUpdate()
+                    .set(TrialMaterialMobilization::getQualityInspectionReport, url)
+                    .eq(TrialMaterialMobilization::getId, id));
+            return true;
+        }
+        if (type == 3) {
+            this.update(Wrappers.<TrialMaterialMobilization>lambdaUpdate()
+                    .set(TrialMaterialMobilization::getOtherAccessories, url)
+                    .eq(TrialMaterialMobilization::getId, id));
+            return true;
+        }
+        return false;
+    }
+
 
 }

+ 53 - 18
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java

@@ -2,6 +2,7 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.lowagie.text.Document;
 import com.lowagie.text.DocumentException;
@@ -38,6 +39,8 @@ import org.springblade.core.tool.utils.*;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springblade.system.user.entity.User;
 import org.springblade.system.user.feign.IUserClient;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -57,6 +60,7 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
     private final IUserClient iUserClient;
     private final NewIOSSClient newIOSSClient;
     private final TrialSamplingRecordMapper trialSamplingRecordMapper;
+    private final JdbcTemplate jdbcTemplate;
 
     @Override
     public boolean sampleVerification(String specificationNumber, String id) {
@@ -128,20 +132,29 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
                     .or().like(TrialSampleInfo::getSpecificationModel, obj.getQueryValue())
                     .or().like(TrialSampleInfo::getSpecificationNumber, obj.getQueryValue()));
         }
-        IPage<TrialSampleInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, true, TrialSampleInfo::getCreateTime));
+        IPage<TrialSampleInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TrialSampleInfo::getCreateTime));
         IPage<TrialSampleInfoVO> trialMaterialMobilizationVOIPage = TrialSampleInfoWarpper.build().pageVO(pages);
         List<TrialSampleInfoVO> records = trialMaterialMobilizationVOIPage.getRecords();
         List<TrialSamplingRecord> list = trialSamplingRecordMapper.selectAll();
         List<User> userList = iUserClient.selectUserAll();
         for (TrialSampleInfoVO record : records) {
+            if (ObjectUtils.isEmpty(record.getMaterialCount())) {
+                record.setMaterialCount(0);
+            }
+            if (ObjectUtils.isEmpty(record.getRepresentativeCount())) {
+                record.setRepresentativeCount(0);
+            }
+
             for (User user : userList) {
                 if (record.getUserId().equals(user.getId())) {
                     record.setUserName(user.getName());
+                    break;
                 }
             }
             for (TrialSamplingRecord trialSamplingRecord : list) {
                 if (record.getId().equals(trialSamplingRecord.getSampleInfoId())) {
                     record.setMobilizationId(trialSamplingRecord.getMobilizationId());
+                    break;
                 }
             }
         }
@@ -150,29 +163,32 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
 
     @Override
     public boolean sampleSubmit(TrialSampleInfoDTO obj) {
-        if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
+        /*if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
             throw new ServiceException("获取用户信息失败");
         }
-        obj.setUserId(SecureUtil.getUserId());
+        obj.setUserId(SecureUtil.getUserId());*/
+
         //如果样品编号为空,那么就自动生成
         if (ObjectUtil.isEmpty(obj.getSpecificationNumber())) {
             this.buildNumber(obj);
         }
 
-        this.saveOrUpdate(obj);
+        TrialSampleInfo trialSampleInfo = BeanUtil.copyProperties(obj, TrialSampleInfo.class);
+        if (trialSampleInfo != null) {
+            if (ObjectUtils.isEmpty(trialSampleInfo.getMaterialCount())) {
+                trialSampleInfo.setMaterialCount(0);
+            }
+            if (ObjectUtils.isEmpty(trialSampleInfo.getRepresentativeCount())) {
+                trialSampleInfo.setRepresentativeCount(0);
+            }
+            this.saveOrUpdate(trialSampleInfo);
 
-        //关联样品取样信息
-        if (obj.getId() != null && obj.getMobilizationId() != null) {
-            //获取当前选择的样品信息
-            TrialSamplingRecord trialSamplingRecord = trialSamplingRecordMapper.selectByMobilizationIdAndSampleInfoId(obj.getMobilizationId(), obj.getId());
-            if (trialSamplingRecord != null) {
-                //存在不新增
-                return true;
-            } else {
-                //删除旧记录
-                trialSamplingRecordMapper.deleteBySampleInfoId(obj.getId());
-                //新增记录
-                trialSamplingRecordMapper.insertRecord(SnowFlakeUtil.getId(), obj.getMobilizationId(), obj.getId());
+            if (obj.getId() != null && obj.getMobilizationId() != null && obj.getMobilizationId() != -1) {
+                TrialSamplingRecord trialSamplingRecord = trialSamplingRecordMapper.selectByMobilizationIdAndSampleInfoId(obj.getMobilizationId(), obj.getId());
+                if (trialSamplingRecord == null) {
+                    trialSamplingRecordMapper.deleteBySampleInfoId(obj.getId());
+                    trialSamplingRecordMapper.insertRecord(SnowFlakeUtil.getId(), obj.getMobilizationId(), obj.getId());
+                }
             }
         }
         return true;
@@ -181,7 +197,11 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
     private void buildNumber(TrialSampleInfoDTO obj) {
         StringSPUtils spUtils = new StringSPUtils();
         //获取当前合同段节点下所有样品信息
-        List<TrialSampleInfo> trialSampleInfos = baseMapper.selectList(Wrappers.<TrialSampleInfo>lambdaQuery().eq(TrialSampleInfo::getContractId, obj.getContractId()).eq(TrialSampleInfo::getNodeId, obj.getNodeId()));
+        List<TrialSampleInfo> trialSampleInfos = baseMapper.selectList(Wrappers.<TrialSampleInfo>lambdaQuery()
+                .select(TrialSampleInfo::getSpecificationNumber)
+                .isNotNull(TrialSampleInfo::getSpecificationNumber)
+                .eq(TrialSampleInfo::getContractId, obj.getContractId())
+                .eq(TrialSampleInfo::getNodeId, obj.getNodeId()));
         //获取记录表最大编号
         List<String> recordNosOld = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationNumber).collect(Collectors.toList());
 
@@ -226,6 +246,11 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
         }
         List<TrialSampleInfo> list = new ArrayList<>();
         for (TrialSampleInfoDTO trialSampleInfoDTO : dto) {
+            List<TrialSampleInfo> query = jdbcTemplate.query("select id,material_name from u_trial_sample_info where specification_number = '" + trialSampleInfoDTO.getSpecificationNumber() + "'", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+            if (query.size() > 0) {
+                TrialSampleInfo trialSampleInfo = query.stream().findAny().orElse(null);
+                throw new ServiceException("材料【" + trialSampleInfo.getMaterialName() + "】的编号重复,请重新填写");
+            }
             trialSampleInfoDTO.setId(SnowFlakeUtil.getId());
             list.add(trialSampleInfoDTO);
         }
@@ -241,6 +266,16 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
         data.forEach(excel -> {
             TrialSampleInfo trialSampleInfo = BeanUtil.copyProperties(excel, TrialSampleInfo.class);
             if (trialSampleInfo != null) {
+                List<TrialSampleInfo> query = jdbcTemplate.query("select id,material_name from u_trial_sample_info where specification_number = '" + trialSampleInfo.getSpecificationNumber() + "'", new BeanPropertyRowMapper<>(TrialSampleInfo.class));
+                if (query.size() > 0) {
+                    TrialSampleInfo obj = query.stream().findAny().orElse(null);
+                    throw new ServiceException("材料【" + obj.getMaterialName() + "】的编号重复,请重新填写后导入");
+                }
+                if ("是".equals(excel.getIsOutsourcing())) {
+                    trialSampleInfo.setIsOutsourcing(1);
+                } else {
+                    trialSampleInfo.setIsOutsourcing(0);
+                }
                 trialSampleInfo.setUserId(SecureUtil.getUserId());
                 trialSampleInfo.setContractId(contractId);
                 trialSampleInfo.setNodeId(nodeId);
@@ -282,7 +317,7 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
                 for (User user : userList) {
                     if (trialSampleInfo.getUserId().equals(user.getId())) {
                         TrialSampleInfoVO trialSampleInfoVO = BeanUtil.copyProperties(trialSampleInfo, TrialSampleInfoVO.class);
-                        if (trialSampleInfoVO != null){
+                        if (trialSampleInfoVO != null) {
                             trialSampleInfoVO.setUserName(user.getName());
                             pdfData.add(trialSampleInfoVO);
                         }

+ 76 - 66
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -593,58 +593,64 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         if (ObjectUtil.isNotEmpty(obj.getParallelProcessInstanceId())) {
             String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
             TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
-            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId()) && (new Integer(1).equals(taskParallel.getEVisaStatus()))) {
-                String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
-                if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
-                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                            .set(TrialSelfInspectionRecord::getTaskStatus, "已审批")
-                            .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
-                            .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
-                    );
-
-                    TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
-                    //此时的record.getPdfUrl()为电签后的pdf信息
-                    if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
-                        /**
-                         * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
-                         */
-                        if (StringUtils.isNotEmpty(record.getProjectPosition())) {
-                            //有pdf的节点
-                            String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
-                            List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
-                            if (collect.size() > 0) {
-                                //删除当前记录关联记录
-                                baseMapper.delSelfQuality(record.getId());
-                                for (Long pKeyId : collect) {
-                                    //新增当前记录关联信息
-                                    baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
-
-                                    //获取当前工程部位节点最新的关联试验记录ids
-                                    List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
-
-                                    //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
-                                    if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
-                                        //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
-                                        baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
-                                        continue;
-                                    }
+            if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
+                //获取当前任务的状态为以已审批status=2,再修改试验状态以及关联的pdf
+                Task task = jdbcTemplate.query("select status from u_task where process_instance_id = '" + taskParallel.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
+                if (ObjectUtils.isNotEmpty(task) && new Integer(2).equals(task.getStatus())) {
 
-                                    //如果当前工程部位节点的关联试验记录id有多条,那么合并
-                                    List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
-                                    List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+                    //试验状态
+                    String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
+                    if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(TrialSelfInspectionRecord::getTaskStatus, "已审批")
+                                .set(TrialSelfInspectionRecord::getPdfUrl, pdfUrlEVisa) //pdfUrlEVisa=电签后的pdf
+                                .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
+                        );
 
-                                    String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
-                                    String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
-                                    File tabPDF = ResourceUtil.getFile(listPdf);
-                                    if (tabPDF.exists()) {
-                                        tabPDF.delete();
-                                    }
+                        TrialSelfInspectionRecord record = baseMapper.selectById(trialSelfInspectionRecordId);
 
-                                    FileUtils.mergePdfPublicMethods(pdfS, listPdf);
-                                    BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
-                                    if (bladeFile != null) {
-                                        //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
-                                        baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
+                        /**
+                         * 在资料填报工序-预览全部pdf时再拼接合并显示,当前只做储存(如果当前资料填报工序节点有其他多个试验记录pdf关联信息,那么合并存储,否则直接存储)
+                         */
+                        if (("已审批").equals(record.getTaskStatus()) && (new Integer(1)).equals(record.getDetectionResult()) && (new Integer(1)).equals(record.getDetectionCategory())) {
+                            if (StringUtils.isNotEmpty(record.getProjectPosition())) {
+                                //有pdf的节点
+                                String sqlNodeAll = "select wbs_id from u_information_query where wbs_id in(" + record.getProjectPosition() + ") and contract_id = " + record.getContractId();
+                                List<Long> collect = jdbcTemplate.query(sqlNodeAll, new BeanPropertyRowMapper<>(InformationQuery.class)).stream().map(InformationQuery::getWbsId).collect(Collectors.toList());
+                                if (collect.size() > 0) {
+                                    //删除当前记录关联记录
+                                    baseMapper.delSelfQuality(record.getId());
+                                    for (Long pKeyId : collect) {
+                                        //新增当前记录关联信息
+                                        baseMapper.saveSelfQuality(SnowFlakeUtil.getId(), record.getId(), pKeyId);
+
+                                        //获取当前工程部位节点最新的关联试验记录ids
+                                        List<String> trialRecordIds = baseMapper.selectTrialIdByNodeId(pKeyId);
+
+                                        //如果当前工程部位节点的关联试验记录id只有一条,且等于当前关联试验记录id,那么不合并,直接存储该条试验记录的pdf
+                                        if (trialRecordIds.size() == 1 && trialRecordIds.get(0).equals(record.getId().toString())) {
+                                            //修改当前试验pdf到质检树节点的pdf_trial_url_position上存储
+                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), record.getPdfUrl());
+                                            continue;
+                                        }
+
+                                        //如果当前工程部位节点的关联试验记录id有多条,那么合并
+                                        List<TrialSelfInspectionRecord> pdfUrlList = baseMapper.selectList(Wrappers.<TrialSelfInspectionRecord>lambdaQuery().select(TrialSelfInspectionRecord::getPdfUrl).in(TrialSelfInspectionRecord::getId, trialRecordIds));
+                                        List<String> pdfS = pdfUrlList.stream().filter(f -> StringUtils.isNotEmpty(f.getPdfUrl())).map(TrialSelfInspectionRecord::getPdfUrl).collect(Collectors.toList());
+
+                                        String filePath = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+                                        String listPdf = filePath + "/pdf/" + pKeyId + ".pdf";
+                                        File tabPDF = ResourceUtil.getFile(listPdf);
+                                        if (tabPDF.exists()) {
+                                            tabPDF.delete();
+                                        }
+
+                                        FileUtils.mergePdfPublicMethods(pdfS, listPdf);
+                                        BladeFile bladeFile = this.newIOSSClient.uploadFile(pKeyId + ".pdf", listPdf);
+                                        if (bladeFile != null) {
+                                            //修改合并的试验pdf到质检树节点的pdf_trial_url_position上存储
+                                            baseMapper.updateInformationQuery(pKeyId, record.getContractId(), bladeFile.getLink());
+                                        }
                                     }
                                 }
                             }
@@ -661,14 +667,20 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             String sql = "select process_instance_id from u_task_parallel where parallel_process_instance_id = '" + obj.getParallelProcessInstanceId() + "'";
             TaskParallel taskParallel = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(TaskParallel.class)).stream().findAny().orElse(null);
             if (taskParallel != null && ObjectUtil.isNotEmpty(taskParallel.getProcessInstanceId())) {
-                String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
-                if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
-                    this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
-                            .set(TrialSelfInspectionRecord::getTaskStatus, "已废除")
-                            .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
-                    );
-                    //废除后修改电签为null
-                    jdbcTemplate.execute("update u_information_query set e_visa_pdf_url = null where wbs_id = " + trialSelfInspectionRecordId);
+
+                //获取当前任务的状态为已废除status=3,再修改试验状态
+                Task task = jdbcTemplate.query("select status from u_task where process_instance_id = '" + taskParallel.getProcessInstanceId() + "'", new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
+                if (ObjectUtils.isNotEmpty(task) && new Integer(3).equals(task.getStatus())) {
+
+                    String trialSelfInspectionRecordId = baseMapper.selectTaskByTaskId(taskParallel.getProcessInstanceId());
+                    if (StringUtils.isNotEmpty(trialSelfInspectionRecordId)) {
+                        this.update(Wrappers.<TrialSelfInspectionRecord>lambdaUpdate()
+                                .set(TrialSelfInspectionRecord::getTaskStatus, "已废除")
+                                .eq(TrialSelfInspectionRecord::getId, trialSelfInspectionRecordId)
+                        );
+                        //废除后修改电签为null
+                        jdbcTemplate.execute("update u_information_query set e_visa_pdf_url = null where wbs_id = " + trialSelfInspectionRecordId);
+                    }
                 }
             }
         }
@@ -882,6 +894,7 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     }
 
     @Async
+    @Transactional(rollbackFor = Exception.class)
     public boolean recordSampleSubmit(TrialSelfInspectionRecordDTO dto1, TrialSelfInspectionRecord obj) {
         RecordSampleSubmitDTO dto = new RecordSampleSubmitDTO();
         dto.setId(obj.getId());
@@ -899,37 +912,34 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             }
 
             //取样信息
-            List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectList(Wrappers.<TrialSampleInfo>lambdaQuery().in(TrialSampleInfo::getId, ids));
+            List<TrialSampleInfo> trialSampleInfos = trialSampleInfoMapper.selectList(Wrappers.<TrialSampleInfo>lambdaQuery()
+                    .isNotNull(TrialSampleInfo::getSamplingLocation)
+                    .isNotNull(TrialSampleInfo::getSupplierUnit)
+                    .isNotNull(TrialSampleInfo::getSpecificationNumber)
+                    .isNotNull(TrialSampleInfo::getSpecificationModel)
+                    .in(TrialSampleInfo::getId, ids));
             List<String> samplingLocations = trialSampleInfos.stream().map(TrialSampleInfo::getSamplingLocation).collect(Collectors.toList());
             String samplingLocation = samplingLocations.stream().findAny().orElse(null);
             if (samplingLocations.size() > 1 && StringUtils.isNotEmpty(samplingLocation)) {
                 samplingLocation = samplingLocation + "等" + samplingLocations.size() + "个取样地点";
-            } else if (StringUtils.isEmpty(samplingLocation)) {
-                samplingLocation = "取样地点为空";
             }
 
             List<String> supplierUnits = trialSampleInfos.stream().map(TrialSampleInfo::getSupplierUnit).collect(Collectors.toList());
             String supplierUnit = supplierUnits.stream().findAny().orElse(null);
             if (supplierUnits.size() > 1 && StringUtils.isNotEmpty(supplierUnit)) {
                 supplierUnit = supplierUnit + "等" + supplierUnits.size() + "个单位";
-            } else if (StringUtils.isEmpty(supplierUnit)) {
-                supplierUnit = "单位为空";
             }
 
             List<String> specificationNumbers = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationNumber).collect(Collectors.toList());
             String specificationNumber = supplierUnits.stream().findAny().orElse(null);
             if (specificationNumbers.size() > 1 && StringUtils.isNotEmpty(specificationNumber)) {
                 specificationNumber = specificationNumber + "等" + specificationNumbers.size() + "个样品编号";
-            } else if (StringUtils.isEmpty(specificationNumber)) {
-                specificationNumber = "样品编号为空";
             }
 
             List<String> specificationModels = trialSampleInfos.stream().map(TrialSampleInfo::getSpecificationModel).collect(Collectors.toList());
             String specificationModel = supplierUnits.stream().findAny().orElse(null);
             if (specificationModels.size() > 1 && StringUtils.isNotEmpty(specificationModel)) {
                 specificationModel = specificationModel + "等" + specificationModels.size() + "个规格类型";
-            } else if (StringUtils.isEmpty(specificationModel)) {
-                specificationModel = "规格类型为空";
             }
 
             //更新

+ 1228 - 0
blade-service/blade-business/src/main/java/org/springblade/business/utils/DateUtils.java

@@ -0,0 +1,1228 @@
+package org.springblade.business.utils;
+
+
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.TemporalAdjusters;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * @author
+ * @version 1.0
+ * @description 日期工具类
+ */
+@Slf4j
+public class DateUtils {
+    private static Calendar calendar = Calendar.getInstance();
+    private static String PATTERN = "yyyy-MM-dd HH:mm:ss";
+//    static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+//    static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    /**
+     * 一年时间的分钟数
+     */
+    public static final int ONE_YEAR_MINUTES = 52560000;
+
+    private final static String FORMAT = "yyyy-MM-dd HH:mm";
+
+    /**
+     * 时间戳转日期
+     *
+     * @param timestamp
+     * @return date
+     */
+    public static Date timestampToDate(long timestamp) {
+
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String d = format.format(timestamp);
+        Date date = null;
+        try {
+            date = format.parse(d);
+        } catch (ParseException e) {
+            throw new RuntimeException(e);
+        }
+        return date;
+    }
+
+    /**
+     * 获取日期时间字符串
+     *
+     * @param date
+     * @return yyyy-MM-dd HH:mm:ss
+     */
+    public static String getTimeStr(Date date) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        return format.format(date);
+    }
+
+    public static String getTimeStr(LocalDateTime date) {
+        return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+    }
+
+
+    public static String getTimeStr(Date date, String pattern) {
+        SimpleDateFormat format = new SimpleDateFormat(pattern);
+        return format.format(date);
+    }
+
+
+    /**
+     * 获取当天日期字符串
+     *
+     * @param date
+     * @return yyyy-MM-dd
+     */
+    public static String getDateStr(Date date) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        return format.format(date);
+    }
+
+    /**
+     * 字符串转日期
+     *
+     * @param timeStr
+     * @return
+     */
+    public static Date strToDate(String timeStr, String pattern) {
+        if (StringUtils.isEmpty(pattern)) {
+            pattern = PATTERN;
+        }
+        SimpleDateFormat format = new SimpleDateFormat(pattern);
+        try {
+            return format.parse(timeStr);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return new Date();
+    }
+
+
+    /**
+     * 获取指定日期的前一天
+     *
+     * @param currentDate
+     * @return
+     */
+    public static String getDateYesterday(String currentDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date current = format.parse(currentDate);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(current);
+            calendar.add(Calendar.DAY_OF_MONTH, -1);
+            Date yesterday = calendar.getTime();
+            return format.format(yesterday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return currentDate;
+    }
+
+    /**
+     * 获取指定日期的前一天
+     *
+     * @param currentDate
+     * @return
+     */
+    public static String getDateYesterdays(String currentDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date current = format.parse(currentDate);
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(current);
+            calendar.add(Calendar.DAY_OF_MONTH, 0);
+            Date yesterday = calendar.getTime();
+            return format.format(yesterday);
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return currentDate;
+    }
+
+
+    /**
+     * 获取指定日期的前一天
+     *
+     * @param currentDate
+     * @return
+     */
+    public static String getDateYesterday(Date currentDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(currentDate);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
+        Date yesterday = calendar.getTime();
+        return format.format(yesterday);
+    }
+
+    /**
+     * 获取指定日期的后(正)/前(负)X天的时间
+     *
+     * @param currentDate
+     * @return
+     */
+    public static DateTime getDateAdd(Date currentDate, Integer add) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(currentDate);
+        calendar.add(Calendar.DAY_OF_MONTH, add);
+        return DateTime.of(calendar.getTime());
+    }
+
+
+    /**
+     * 获取两个日期的年份差
+     *
+     * @param date1
+     * @param date2
+     * @return
+     */
+    public static String getTwoDateYears(String date1, String date2) {
+        Calendar bef = null;
+        Calendar aft = null;
+        try {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+            bef = Calendar.getInstance();
+            aft = Calendar.getInstance();
+            bef.setTime(sdf.parse(date1));
+            aft.setTime(sdf.parse(date2));
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        int surplus = aft.get(Calendar.DATE) - bef.get(Calendar.DATE);
+        int result = aft.get(Calendar.MONTH) - bef.get(Calendar.MONTH);
+        int year = aft.get(Calendar.YEAR) - bef.get(Calendar.YEAR);
+        if (result < 0) {
+            result = 1;
+        } else if (result == 0) {
+            result = surplus <= 0 ? 1 : 0;
+        } else {
+            result = 0;
+        }
+        return String.valueOf(year + result);
+    }
+
+    /**
+     * 获取日期的月和日,并用汉字表示
+     * 如2019-10-17 输出 10月17日
+     *
+     * @param dateString
+     * @return
+     */
+    public static String getChineseDateMonthAndDay(String dateString) {
+        //判断日期如果长度不符合,则返回错误null
+        if (dateString.length() != 10) {
+            return null;
+        }
+        //获取月
+        String dateMonth = dateString.substring(5, 7);
+        //获取日
+        String dateDay = dateString.substring(8, 10);
+        String chineseDate = dateMonth + "月" + dateDay + "日";
+        return chineseDate;
+    }
+
+    /**
+     * 获取日期的月和日,并用汉字表示
+     * 如2019-10-17 输出 2019年10月17日
+     *
+     * @param dateString
+     * @return
+     */
+    public static String getChineseDateYearAndMonthAndDay(String dateString) {
+        //判断日期如果长度不符合,则返回错误null
+        if (StringUtils.isEmpty(dateString) || dateString.length() != 10) {
+            return null;
+        }
+        //获取年
+        String year = dateString.substring(0, 4);
+        //获取月
+        String dateMonth = dateString.substring(5, 7);
+        //获取日
+        String dateDay = dateString.substring(8, 10);
+        String chineseDate = year + "年" + dateMonth + "月" + dateDay + "日";
+        return chineseDate;
+    }
+
+
+    /**
+     * 获取日期的月和日,并用汉字表示
+     * 如2019-10-17 输出 10月
+     *
+     * @param date
+     * @return
+     */
+    public static String getChineseDateMonth(Date date) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String dateString = format.format(date);
+        //获取月
+        String dateMonth = dateString.substring(5, 7);
+        String chineseDate = dateMonth + "月";
+        return chineseDate;
+    }
+
+    /**
+     * 获取本年最后一天
+     *
+     * @return
+     */
+    public static String getYearEnd() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        Date currYearLast = calendar.getTime();
+        return new SimpleDateFormat("yyyy-MM-dd").format(currYearLast);
+    }
+
+    /**
+     * 获取指定年最后一天
+     *
+     * @return
+     */
+    public static Date getYearEnd(Date endDate) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(endDate);
+        calendar.set(Calendar.MONTH, calendar.getActualMaximum(Calendar.MONTH));
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime();
+    }
+
+
+    /**
+     * 计算两个日期的间隔天数
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static int cacTwoDateDays(String startTime, String endTime) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        Date date1 = null;
+        Date date = null;
+        Long l = 0L;
+        try {
+            date = formatter.parse(startTime);
+            long ts = date.getTime();
+            date1 = formatter.parse(endTime);
+            long ts1 = date1.getTime();
+
+            l = (ts - ts1) / (1000 * 60 * 60 * 24);
+
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return l.intValue();
+    }
+
+    /**
+     * 计算两个日期的间隔小时数
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static int cacTwoDateHours(String startTime, String endTime) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH");
+        Date date1 = null;
+        Date date = null;
+        Long l = 0L;
+        try {
+            date = formatter.parse(startTime);
+            long ts = date.getTime();
+            date1 = formatter.parse(endTime);
+            long ts1 = date1.getTime();
+
+            l = (ts - ts1) / (1000 * 60 * 60);
+
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return l.intValue();
+    }
+
+    /**
+     * 获取下一个生日
+     *
+     * @param todayTime    当前日期
+     * @param birthdayTime 生日日期
+     * @return
+     */
+    public static String getNextBirthday(String todayTime, String birthdayTime) {
+        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+        Date date1 = null;
+        Date date = null;
+        Long l = 0L;
+        try {
+            date = formatter.parse(todayTime);
+            long ts = date.getTime();
+            date1 = formatter.parse(birthdayTime);
+            long ts1 = date1.getTime();
+            //如果生日日期在当天日期之前,则生日变为明年
+            if (ts > ts1) {
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(date1);
+                calendar.add(Calendar.YEAR, +1);
+                Date nextBirthday = calendar.getTime();
+                return getDateStr(nextBirthday);
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return birthdayTime;
+    }
+
+
+    /**
+     * 判断当前日期是星期几
+     *
+     * @param pTime 修要判断的时间
+     * @return dayForWeek 判断结果
+     * @Exception 发生异常
+     */
+    public static int dayForWeek(String pTime) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Calendar c = Calendar.getInstance();
+            c.setTime(format.parse(pTime));
+            int dayForWeek = 0;
+            if (c.get(Calendar.DAY_OF_WEEK) == 1) {
+                dayForWeek = 7;
+            } else {
+                dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
+            }
+            return dayForWeek;
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return 0;
+    }
+
+    public static String int2chineseNum(int src) {
+        final String num[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
+        final String unit[] = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千"};
+        String dst = "";
+        int count = 0;
+        while (src > 0) {
+            dst = (num[src % 10] + unit[count]) + dst;
+            src = src / 10;
+            count++;
+        }
+        return dst.replaceAll("零[千百十]", "零").replaceAll("零+万", "万")
+                .replaceAll("零+亿", "亿").replaceAll("亿万", "亿零")
+                .replaceAll("零+", "零").replaceAll("零$", "");
+    }
+
+
+    /**
+     * 获取日期对应的今年的月和日
+     *
+     * @param lunarDate 如传入2015-06-10,今年是2019,得到2019-06-10
+     * @return
+     */
+    public static String getThisYearMonthAndDay(String lunarDate) {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        //获取当前公历日期
+        String today = getDateStr(new Date());
+        //截取公历日期的年份加上传入日期的月和日
+        String year = today.substring(0, 5);
+        String date = lunarDate.substring(5, lunarDate.length());
+        String thisYearDay = year + date;
+        return thisYearDay;
+    }
+
+    /**
+     * 获取数组日期对应的日期String
+     *
+     * @param dateArray
+     * @return
+     */
+    public static String getStringDate(int[] dateArray) {
+        int year = dateArray[0];
+        int month = dateArray[1];
+        int date = dateArray[2];
+        Calendar cal = Calendar.getInstance();
+        cal.set(year, month - 1, date);
+        Date yesterday = cal.getTime();
+        return getDateStr(yesterday);
+    }
+
+
+    /**
+     * 获取过去第几天的日期
+     *
+     * @param past
+     * @return
+     */
+    public static Date getPastDate(int past) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - past);
+        Date today = calendar.getTime();
+        return today;
+    }
+
+
+    /**
+     * 获取时间多少分钟之后的时间
+     *
+     * @param date
+     * @param minutes
+     * @return
+     */
+    public static Date getDateAfterMinutes(Date date, int minutes) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.MINUTE, calendar.get(Calendar.MINUTE) + minutes);
+        Date afterDate = calendar.getTime();
+        return afterDate;
+    }
+
+    /**
+     * 获取时间多少秒之后的时间
+     *
+     * @param date
+     * @param minutes
+     * @return
+     */
+    public static Date getDateAfterSecond(Date date, int minutes) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.SECOND, calendar.get(Calendar.SECOND) + minutes);
+        Date afterDate = calendar.getTime();
+        return afterDate;
+    }
+
+    public static Date getDayEnd(Date endDate) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(endDate);
+        // calendar.setTimeInMillis(endDate.getTime());
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        Date end = calendar.getTime();
+        return end;
+    }
+
+    public static Date getDayStart(Date startDate) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(startDate);
+        // calendar.setTimeInMillis(startDate.getTime());
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date start = calendar.getTime();
+        return start;
+    }
+
+    public static Date getMonthStart(Date startDate) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(startDate);
+        // calendar.setTimeInMillis(startDate.getTime());
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date start = calendar.getTime();
+        return start;
+    }
+
+    public static Date getYearStart(Date startDate) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(startDate);
+        // calendar.setTimeInMillis(startDate.getTime());
+        calendar.set(Calendar.MONTH, 0);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        Date start = calendar.getTime();
+        return start;
+    }
+
+
+    /**
+     * 一年前的下个月开始日期
+     */
+    public static Date getOneYearTimeNextMonth(Date now) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(now);
+        //年份减1
+        c.add(Calendar.YEAR, -1);
+        c.add(Calendar.MONTH, 1);
+        c.set(Calendar.DAY_OF_MONTH, 1);
+        c.set(Calendar.HOUR, 0);
+        c.set(Calendar.MINUTE, 0);
+        c.set(Calendar.SECOND, 0);
+        return c.getTime();
+    }
+
+    /**
+     * 获取固定值之前的时间
+     *
+     * @param now
+     * @param sec
+     * @return {@link Date}
+     **/
+    public static Date getLastTime(Date now, int sec) {
+        Calendar c = Calendar.getInstance();
+        c.setTime(now);
+        c.add(Calendar.SECOND, -sec);
+        return c.getTime();
+    }
+
+
+    public static Long dateDiff(Date startTime, Date endTime) {
+        long diff;
+        long min = 0;
+        // 获得两个时间的毫秒时间差异
+        diff = endTime.getTime() - startTime.getTime();
+        min = diff / 60 / 1000;
+        return min;
+    }
+
+    /**
+     * 获取指定周的周一日期
+     *
+     * @param year        年
+     * @param month       月
+     * @param weekOfMonth 当月第n周
+     * @return {@link Date}
+     **/
+    public static Date getMonthOfWeekDate(int year, int month, int weekOfMonth) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, year);
+        calendar.set(Calendar.MONTH, month - 1);
+        calendar.set(Calendar.WEEK_OF_MONTH, weekOfMonth);
+        calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek() + 1);
+        return calendar.getTime();
+    }
+
+    /**
+     * 获取当前时间上一月 时间 YYYYMM
+     *
+     * @return
+     */
+    public static String getUpMonth() {
+        return getAddMonth(-1);
+    }
+
+    /**
+     * 获取某个月的时间 YYYYMM
+     *
+     * @return
+     */
+    public static String getAddMonth(int months) {
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.MONTH, months);
+
+        SimpleDateFormat formats = new SimpleDateFormat("yyyyMM");
+        formats.format(cal.getTime());
+        return formats.format(cal.getTime());
+    }
+
+    /**
+     * 获取当前时间上一年 时间 YYYYMM
+     *
+     * @return
+     */
+    public static String getUpYear() {
+        return getAddYear(-1);
+    }
+
+    /**
+     * 获取当前时间上一年 时间 YYYYMM
+     *
+     * @return
+     */
+    public static String getAddYear(int year) {
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.YEAR, year);
+
+        SimpleDateFormat formats = new SimpleDateFormat("yyyy");
+
+
+        return formats.format(cal.getTime());
+    }
+
+    /**
+     * 获取当年的最后一天
+     *
+     * @param year
+     * @return
+     */
+    public static String getCurrYearLast(int year) {
+
+
+        SimpleDateFormat formats = new SimpleDateFormat("yyyy-MM-dd");
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.clear();
+        calendar.set(Calendar.YEAR, year);
+        calendar.roll(Calendar.DAY_OF_YEAR, -1);
+        Date currYearLast = calendar.getTime();
+        return formats.format(currYearLast);
+    }
+
+    public static Date getYesterdayDayEnd() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH) - 1,
+                23, 59, 59);
+        Date end = calendar.getTime();
+        return end;
+    }
+
+    /**
+     * 判断时间远程时间是否大于缓存时间
+     *
+     * @param theRemoteTime 远程时间
+     * @param cacheTime     缓存时间
+     * @return
+     */
+    public static boolean twoTimeJudgment(String theRemoteTime, String cacheTime) {
+        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
+        try {
+            Date sd1 = df.parse(theRemoteTime);
+            Date sd2 = df.parse(cacheTime);
+            long long1 = sd1.getTime();
+            long long2 = sd2.getTime();
+            if (long1 > long2) {
+                return true;
+            }
+            return false;
+        } catch (ParseException e) {
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    /**
+     * 指定月份最后一天 并且加上指定天数
+     *
+     * @param month
+     * @return
+     */
+    public static String getMaxDateMonth(String month, int num) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
+        try {
+            Date nowDate = format.parse(month);
+            calendar = Calendar.getInstance();
+            calendar.setTime(nowDate);
+            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+            calendar.add(Calendar.DATE, num);// num为增加的天数,可以改变的
+            return sdf.format(calendar.getTime());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 指定月份第一天 并且加上指定天数
+     *
+     * @param month
+     * @return
+     */
+    public static String getMinDateMonth(String month, int num) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
+        try {
+            Date nowDate = format.parse(month);
+            calendar = Calendar.getInstance();
+            calendar.setTime(nowDate);
+            calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
+            calendar.add(Calendar.DATE, -num);// num为增加的天数,可以改变的
+            return sdf.format(calendar.getTime());
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+
+    /**
+     * 时间向下取整,分钟数
+     *
+     * @param timestamp 传入毫秒级时间戳
+     * @param interval  分钟向下取整周期
+     * @return
+     */
+    public static String getLowIntervalMinuetStr(Long timestamp, Integer interval) {
+        LocalDateTime dateTime;
+        if (timestamp != null) {
+            dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
+        } else {
+            dateTime = LocalDateTime.now(ZoneId.systemDefault());
+        }
+        int minute = dateTime.getMinute();
+        int lowerIntervalMinute = minute / interval * interval % 60;
+        String headTime = DateTimeFormatter.ofPattern("yyyy-MM-dd HH").withZone(ZoneId.systemDefault()).format(dateTime);
+        if (lowerIntervalMinute < 10) {
+            return new StringBuilder(headTime).append(":0").append(lowerIntervalMinute).append(":00").toString();
+        }
+        return new StringBuilder(headTime).append(":").append(lowerIntervalMinute).append(":00").toString();
+    }
+
+    /**
+     * @param timestamp
+     * @param interval
+     * @return
+     */
+    public static LocalDateTime getLowIntervalMinuetTime(Long timestamp, Integer interval) {
+        LocalDateTime dateTime;
+        if (timestamp != null) {
+            dateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
+        } else {
+            dateTime = LocalDateTime.now(ZoneId.systemDefault());
+        }
+        int minute = dateTime.getMinute();
+        int lowerIntervalMinute = minute / interval * interval % 60;
+        return dateTime.withMinute(lowerIntervalMinute).withSecond(0).withNano(0);
+    }
+
+    /**
+     * @param dateTime
+     * @param interval
+     * @return
+     */
+    public static DateTime getLowIntervalMinuetTime(Date dateTime, Integer interval) {
+        LocalDateTime localDateTime = DateUtil.toLocalDateTime(dateTime);
+        int minute = localDateTime.getMinute();
+        int lowerIntervalMinute = minute / interval * interval % 60;
+        LocalDateTime lowInterval = localDateTime.withMinute(lowerIntervalMinute).withSecond(0).withNano(0);
+        return DateUtil.parse(DateUtil.formatLocalDateTime(lowInterval));
+    }
+
+
+    /**
+     * @param localDateTime
+     * @param interval
+     * @return
+     */
+    public static DateTime getLowIntervalMinuetTime(LocalDateTime localDateTime, Integer interval) {
+        int minute = localDateTime.getMinute();
+        int lowerIntervalMinute = minute / interval * interval % 60;
+        LocalDateTime lowInterval = localDateTime.withMinute(lowerIntervalMinute).withSecond(0).withNano(0);
+        return DateUtil.parse(DateUtil.formatLocalDateTime(lowInterval));
+    }
+
+    /**
+     * 获取下一个分钟级别周期时间
+     *
+     * @param currentTime
+     * @param interval
+     * @param formatter
+     * @return
+     */
+    public static String getNextIntervalTime(String currentTime, long interval, String formatter) {
+        LocalDateTime dateTime = LocalDateTime.parse(currentTime, DateTimeFormatter.ofPattern(formatter));
+        dateTime = dateTime.plusMinutes(interval);
+        return DateTimeFormatter.ofPattern(formatter).withZone(ZoneId.systemDefault()).format(dateTime);
+    }
+
+
+    /***
+     * 获取某一时间 所在 月份 的第一天
+     *  比如 : 2020-01-20
+     *     结果为: 2020-01-01 00:00:00
+     * */
+    public static Date getFirstDateOfMonth(Date date) {
+        Calendar firstDate = Calendar.getInstance();
+        firstDate.setTime(date);
+        final int last = firstDate.getActualMinimum(Calendar.DAY_OF_MONTH);
+        firstDate.set(Calendar.DAY_OF_MONTH, last);
+        firstDate.set(Calendar.HOUR, 00);
+        firstDate.set(Calendar.MINUTE, 00);
+        firstDate.set(Calendar.SECOND, 00);
+        //当前日期 的 月份的 第一天)
+        return firstDate.getTime();
+    }
+
+    /***
+     * 获取某一时间 所在 月份 的最后一天
+     *  比如 : 2020-01-20
+     *     结果为: 2020-01-31 00:00:00
+     * */
+    public static Date getEndDayOfMonth(Date date) {
+
+        Calendar lastDateMonth = Calendar.getInstance();
+        lastDateMonth.setTime(date);
+        final int lastDay = lastDateMonth.getActualMaximum(Calendar.DAY_OF_MONTH);
+        lastDateMonth.set(Calendar.DAY_OF_MONTH, lastDay);
+        lastDateMonth.set(Calendar.HOUR, 23);
+        lastDateMonth.set(Calendar.MINUTE, 59);
+        lastDateMonth.set(Calendar.SECOND, 59);
+        //当前日期 的月份的最后一天
+        return lastDateMonth.getTime();
+    }
+
+
+    /**
+     * 获取上个月开始时间
+     *
+     * @return
+     */
+    public static String getLastMonthStartTime() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //上个月
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.MONTH, 1);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return format.format(calendar.getTime());
+    }
+
+    /**
+     * 获取上个月结束时间
+     *
+     * @return
+     */
+    public static String getNextMonthEndTime() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.add(Calendar.DATE, 0);
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return format.format(calendar.getTime());
+    }
+
+
+    /**
+     * 获取本月开始时间
+     *
+     * @return xxxx-xx-01 00:00:59
+     */
+    public static String getStartTimeOfThisMonth() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        //上个月
+        Calendar calendar = Calendar.getInstance();
+        calendar.add(Calendar.MONTH, 0);
+        calendar.set(Calendar.DAY_OF_MONTH, 1);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return format.format(calendar.getTime());
+    }
+
+    /**
+     * 获取本月结束时间
+     *
+     * @return xxxx-xx-xx 23:59:59
+     */
+    public static String getLastDayOfTheMonth() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.set(Calendar.HOUR_OF_DAY, 23);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        return format.format(calendar.getTime());
+    }
+
+
+    public static Date clearMs(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime();
+    }
+
+    public static Date clearS(Date date) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+        return calendar.getTime();
+    }
+
+
+    public static String getStartTimes() {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        //获取当天开始时间
+        String StartTime = sdf.format(getStartTime());
+        return StartTime;
+    }
+
+    public static Date getYear(int year) {
+        Calendar c = Calendar.getInstance();
+        c.set(year, 1, 1);
+        return c.getTime();
+    }
+
+    /**
+     * 开始时间
+     *
+     * @return
+     */
+    public static String getStartTime() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar todayStart = Calendar.getInstance();
+        todayStart.set(Calendar.HOUR_OF_DAY, 0);
+        todayStart.set(Calendar.MINUTE, 0);
+        todayStart.set(Calendar.SECOND, 0);
+        todayStart.set(Calendar.MILLISECOND, 0);
+        return format.format(todayStart.getTime());
+    }
+
+    /**
+     * 结束时间
+     *
+     * @return
+     */
+    public static String getEndTime() {
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        Calendar todayEnd = Calendar.getInstance();
+        todayEnd.set(Calendar.HOUR_OF_DAY, 23);
+        todayEnd.set(Calendar.MINUTE, 59);
+        todayEnd.set(Calendar.SECOND, 59);
+        todayEnd.set(Calendar.MILLISECOND, 59);
+        return format.format(todayEnd.getTime());
+    }
+
+    private final static String YEAR = "year";
+    private final static String MOUTH = "mouth";
+    private final static String DAY = "day";
+    private final static String HOUR = "hour";
+
+    /**
+     * @return
+     * @description {
+     * hour: startTime = 2022-04-15 00:00:00  、2022-04-15 01:00:00 、2022-04-15 02:00:00
+     * day: startTime = 2022-04-15 00:00:00   、2022-04-16 00:00:00 、2022-04-17 00:00:00
+     * mouth: startTime = 2022-04-01 00:00:00   、2022-05-01 00:00:00 、2022-06-01 00:00:00
+     * year: startTime = 2022-01-01 00:00:00   、2023-01-01 00:00:00 、2024-01-01 00:00:00
+     * }
+     */
+    public static Date getStartTime(String date, Date time) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(time);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        if (YEAR.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+            calendar.set(Calendar.MONTH, 0);
+            calendar.set(Calendar.DATE, 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+        }
+        if (MOUTH.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
+            calendar.set(Calendar.DATE, 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+        }
+        if (DAY.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 0);
+        }
+        if (HOUR.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE));
+            calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+        }
+        return calendar.getTime();
+    }
+
+    /**
+     * @return
+     * @description {
+     * hour: endTime = 2022-04-15 00:59:59  、2022-04-15 01:59:59 、2022-04-15 02:59:59
+     * day: endTime = 2022-04-15 23:59:59   、2022-04-16 23:59:59 、2022-04-17 23:59:59
+     * mouth: endTime = 2022-04-max 23:59:59   、2022-05-max 23:59:59 、2022-06-max 23:59:59
+     * year: endTime = 2022-12-31 23:59:59   、2023-12-31 23:59:59 、2024-12-31 23:59:59
+     * }
+     */
+    public static Date getEndTime(String date, Date time) {
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(time);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        if (YEAR.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR) - 1);
+            calendar.set(Calendar.MONTH, 11);
+            calendar.set(Calendar.DATE, 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 23);
+        }
+        if (MOUTH.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1);
+            calendar.set(Calendar.DATE, 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 23);
+        }
+        if (DAY.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE) - 1);
+            calendar.set(Calendar.HOUR_OF_DAY, 23);
+        }
+        if (HOUR.equals(date)) {
+            calendar.set(Calendar.YEAR, calendar.get(Calendar.YEAR));
+            calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
+            calendar.set(Calendar.DATE, calendar.get(Calendar.DATE));
+            calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 1);
+        }
+        LocalDateTime localDateTime = calendar.getTime().toInstant()
+                .atZone(ZoneId.systemDefault())
+                .toLocalDateTime();
+        if (YEAR.equals(date) || MOUTH.equals(date)) {
+            localDateTime = localDateTime.with(TemporalAdjusters.lastDayOfMonth());
+        }
+        return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
+    }
+
+
+
+    /**
+     * 获取两个日期之间的所有日期 (年月日)
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static List<String> getBetweenDate(String startTime, String endTime) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        // 声明保存日期集合
+        List<String> list = new ArrayList<String>();
+        try {
+            // 转化成日期类型
+            Date startDate = sdf.parse(startTime);
+            Date endDate = sdf.parse(endTime);
+
+            //用Calendar 进行日期比较判断
+            Calendar calendar = Calendar.getInstance();
+            while (startDate.getTime() <= endDate.getTime()) {
+                // 把日期添加到集合
+                list.add(sdf.format(startDate));
+                // 设置日期
+                calendar.setTime(startDate);
+                //把日期增加一天
+                calendar.add(Calendar.DATE, 1);
+                // 获取增加后的日期
+                startDate = calendar.getTime();
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return list;
+    }
+
+    /**
+     * 获取两个日期之间的所有日期 (年月日)
+     *
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    public static List<String> getBetweenMonth(String startTime, String endTime) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
+        // 声明保存日期集合
+        List<String> list = new ArrayList<String>();
+        try {
+            // 转化成日期类型
+            Date startDate = sdf.parse(startTime);
+            Date endDate = sdf.parse(endTime);
+
+            //用Calendar 进行日期比较判断
+            Calendar calendar = Calendar.getInstance();
+            while (startDate.getTime() <= endDate.getTime()) {
+                // 把日期添加到集合
+                list.add(sdf.format(startDate));
+                // 设置日期
+                calendar.setTime(startDate);
+                //把日期增加一天
+                calendar.add(Calendar.MONTH, 1);
+                // 获取增加后的日期
+                startDate = calendar.getTime();
+            }
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return list;
+    }
+
+    /**
+     * 获取指定年月的第一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getFirstDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        //清除可能存在的缓存
+        cal.clear();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month - 1);
+        //获取某月最小天数
+        int firstDay = cal.getMinimum(Calendar.DATE);
+        //设置日历中月份的最小天数
+        cal.set(Calendar.DAY_OF_MONTH, firstDay);
+        //格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+    /**
+     * 获取指定年月的最后一天
+     *
+     * @param year
+     * @param month
+     * @return
+     */
+    public static String getLastDayOfMonth(int year, int month) {
+        Calendar cal = Calendar.getInstance();
+        //清除可能存在的缓存
+        cal.clear();
+        //设置年份
+        cal.set(Calendar.YEAR, year);
+        //设置月份
+        cal.set(Calendar.MONTH, month-1);
+        //获取某月最大天数
+        int lastDay = cal.getActualMaximum(Calendar.DATE);
+        //设置日历中月份的最大天数
+        cal.set(Calendar.DAY_OF_MONTH, lastDay);
+        //格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        return sdf.format(cal.getTime());
+    }
+
+
+    /**
+     * 解析 HH:mm 格式的字符串,获得分钟数
+     *
+     * @param
+     */
+    public static Integer getMinuteValueByStr(String str) {
+        String[] split = str.split(":");
+        return Integer.parseInt(split[0]) * 60 + Integer.parseInt(split[1]);
+    }
+
+}

+ 4 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ArchiveTreeController.java

@@ -209,9 +209,9 @@ public class ArchiveTreeController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "保存立卷规则设置", notes = "传入archiveAutoType规则类型,nodeIds逗号拼接选择节点id")
     public R saveArchiveAutoRule(@ApiParam(value = "立卷规则", required = true) @RequestParam Integer archiveAutoType,
-                                 @ApiParam(value = "主键集合", required = true) @RequestParam String nodeIds,
+                                 @ApiParam(value = "主键集合", required = true) @RequestParam String selectNodeIds,
                                  @ApiParam(value = "是否wbs节点", required = true) @RequestParam Boolean iswbsNode) {
-        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,nodeIds,iswbsNode));
+        return R.status(archiveTreeService.saveArchiveAutoRule(archiveAutoType,selectNodeIds,iswbsNode));
     }
 
 
@@ -236,8 +236,8 @@ public class ArchiveTreeController extends BladeController {
      * 查看立卷规则设置
      */
     @PostMapping("/getArchiveAutoRule")
-    public R getArchiveAutoRule(Long id,boolean iswbsNode) {
-        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(id,iswbsNode);
+    public R getArchiveAutoRule(Long nodeId,boolean iswbsNode) {
+        Map<String, Object> ruleMap=archiveTreeService.getArchiveAutoRule(nodeId,iswbsNode);
         return R.data(ruleMap);
     }
 

+ 2 - 10
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ProjectInfoController.java

@@ -1,27 +1,20 @@
 package org.springblade.manager.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.google.common.collect.Lists;
 import io.swagger.annotations.*;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import lombok.AllArgsConstructor;
 
 import javax.validation.Valid;
 
-import org.apache.commons.lang.StringUtils;
-import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
-import org.springblade.core.tool.utils.Func;
-import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
 import org.springblade.manager.dto.WbsTreeContractDTO;
 import org.springblade.manager.dto.ProjectInfoDTO;
 import org.springblade.manager.entity.ContractInfo;
-import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.service.*;
 import org.springblade.manager.vo.*;
-import org.springframework.context.annotation.Bean;
 import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
@@ -30,10 +23,8 @@ import org.springblade.manager.entity.ProjectInfo;
 import org.springblade.manager.wrapper.ProjectInfoWrapper;
 import org.springblade.core.boot.ctrl.BladeController;
 
-import java.rmi.ServerException;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 @RestController
 @AllArgsConstructor
@@ -202,7 +193,8 @@ public class ProjectInfoController extends BladeController {
      * 项目、合同段私有库wbs节点Tree加载
      * (项目私有wbs设置界面,左侧加载可用,
      * 项目分配wbs初始化时,右侧展示当前项目id的私有节点,左侧则展示的是分配wbs树保存后引用的哪个项目id下的私有树
-     * 合同段分配wbs时进入默认加载左侧节点树可用)
+     * 合同段分配wbs时进入默认加载左侧节点树可用
+     * 试验设备使用管理中,检测项目使用)
      */
     @GetMapping("/tree")
     @ApiOperationSupport(order = 11)

+ 5 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.java

@@ -25,7 +25,7 @@ public interface ArchiveTreeMapper extends BaseMapper<ArchiveTree> {
 
     /**
      * 自动组卷规则设置节点下所有子节点
-     * @param tree
+     * @param
      * @return
      */
     int updateAllSonNodeIdsForArchiveAutoRule(@Param("archiveAutoType") Integer archiveAutoType,
@@ -35,7 +35,7 @@ public interface ArchiveTreeMapper extends BaseMapper<ArchiveTree> {
 
     /**
      * 删除立卷规则设置
-     * @param tree
+     * @param
      * @return
      */
     int removeAllSonNodeIdsForArchiveAutoRule_1(@Param("archiveAutoType") Integer archiveAutoType,
@@ -51,6 +51,8 @@ public interface ArchiveTreeMapper extends BaseMapper<ArchiveTree> {
      * @param groupId
      * @return
      */
-    List<ArchiveTreeAutoRuleVO> getAllSonNodeforGroupView(@Param("ancestors")String ancestors, @Param("groupId")Long groupId);
+    List<ArchiveTreeAutoRuleVO> getAllSonNodeforGroupView(@Param("ancestors")String ancestors,
+                                                          @Param("groupId")Long groupId,
+                                                          @Param("bigNodeID")Long bigNodeID);
 
 }

+ 6 - 5
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeMapper.xml

@@ -293,20 +293,20 @@
 
         update m_archive_tree
         set
-        archive_auto_type= #{archiveAutoType},
+        archive_auto_type= #{archiveAutoType}
         <if test="archiveAutoType ==2 ">
-            archive_auto_group_id=#{archiveAutoGroupId},
+            ,archive_auto_group_id=#{archiveAutoGroupId},
             archive_auto_group_select=0
         </if>
         where
         is_deleted = 0 and ancestors like concat('', #{ancestors}, '%')
         /*最高并卷规则不能覆盖 分类并卷规则,单独组卷规则*/
         <if test="archiveAutoType ==1 ">
-            and archive_auto_type != 2 and archive_auto_type != 3
+            and (archive_auto_type != 2 and archive_auto_type != 3 or archive_auto_type is null)
         </if>
         /*分类并卷规则不能覆盖单独组卷规则*/
         <if test="archiveAutoType ==2 ">
-            and archive_auto_type != 3
+            and (archive_auto_type != 3 or archive_auto_type is null)
         </if>
     </update>
 
@@ -379,10 +379,11 @@
         FROM m_archive_tree
         where is_deleted = 0
           and ancestors like concat('', #{ancestors}, '%')
-          and archive_auto_type !=3
+          and (archive_auto_type !=3 or archive_auto_type is null)
           and id not in (
                 select id from m_archive_tree where archive_auto_type=2 and archive_auto_group_id != #{groupId}
             )
+          or id=#{bigNodeID}
         order by ancestors asc,sort asc
     </select>
 

+ 46 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveAutoRuleWbsServiceImpl.java

@@ -38,4 +38,50 @@ public class ArchiveAutoRuleWbsServiceImpl extends BaseServiceImpl<ArchiveAutoRu
 		return page.setRecords(baseMapper.selectArchiveAutoRuleWbsPage(page, archiveAutoRuleWbs));
 	}
 
+	public void archiveAutoMethod(){
+		//步骤一:把项目下未锁定的案卷拆卷。
+		//步骤二:查询归档树节点。存在未归档文件的节点。
+		//步骤三:遍历归档树节点整理出 默认规则节点,分类并卷节点,单独组卷节点 三个集合。
+		//步骤四:按照单独,分类,默认的顺序执行组卷流程。
+	}
+
+	/**
+	 * 单租组卷流程  节点下的文件只在当前节点下组卷
+	 */
+	private void archiveAutoMethod3(){
+		//步骤1:遍历节点集合
+		//步骤2:获取当前节点的案卷规格
+		//步骤3:查询节点下的未归档文件
+		//步骤4:遍历未归档文件
+		//步骤5:判断文件是否存在分盒设置-》走分盒组卷流程
+		//步骤6:计算和判断待组卷文件集合是否达到组卷要求,达到要求创建案卷,案卷归属当前节点,案卷下文件改为已组卷
+	}
+
+	/**
+	 * 分类并卷组卷  设置分类的节点下只有一个案卷,节点下的所有文件都组成这个案卷。如果设置分类节点(select=1的)多个,案卷归属排序第一个节点。
+	 */
+	private void archiveAutoMethod2(){
+		//步骤1:遍历节点集合
+		//步骤2:查询节点下的未归档文件
+		//步骤4:遍历未归档文件
+		//步骤5:判断文件是否存在分盒设置-》走分盒组卷流程
+		//步骤6:将文件按照<groupId,List<文件>>放入集合
+		//步骤7:将文件按照<groupId,List<文件>>放入集合
+		//步骤8:按集合创建案卷,每个group类的案卷归属顺序排第一个节点
+	}
+
+	/**
+	 * 默认组卷流程 文件可以跨节点组卷,受最高并卷节点限制范围,跨节点文件组卷时,案卷规格按照第一个文件所在的节点规格 组卷。
+	 */
+	private void archiveAutoMethod1(){
+		//步骤1:遍历节点集合
+		//步骤2:保存当前节点的最高并卷节点archiveAutoNodeId到变量A,用来限制向上级跨节点组卷。
+		//步骤3:判断变量A是否与当前节点archiveAutoNodeId相同,不同的话(相当于当前节点已跳出最高并卷节点)直接将内存中文件集合List中的文件组卷(这些是属于上一个最高并卷节点的文件),并清空list文件集合
+		//步骤4:获取当前节点的组卷规格
+		//步骤5:查询节点下的未归档文件
+		//步骤6:遍历未归档文件
+		//步骤7:判断文件是否存在分盒设置-》走分盒组卷流程
+		//步骤8:计算和判断文件集合list里是否达到组卷规格,达到创建案卷 并清空集合list。 跨节点文件组卷,案卷归属于当前list中第一个文件所在节点
+	}
+
 }

+ 24 - 13
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeServiceImpl.java

@@ -413,6 +413,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                 continue;
             }
             ArchiveTreeVO2 archiveTree = new ArchiveTreeVO2();
+            archiveTree.setIswbsNode(true);
             archiveTree.setId(wbsTreeVO2.getId());
             archiveTree.setParentId(wbsTreeVO2.getParentId());
             archiveTree.setTitle(wbsTreeVO2.getTitle());
@@ -458,7 +459,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
             //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
                 double v = Math.random() * 10000;
-                int ran = (int)v;
+                long ran = (long)v;
                 archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
 
@@ -483,7 +484,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                         archiveTree.getArchiveAutoType(),
                         archiveTree.getArchiveAutoNodeId(),
                         archiveTree.getArchiveAutoGroupId(),
-                        archiveTree.getAncestors()
+                        archiveTree.getAncestors()+","+archiveTree.getId()
                 );
             }
 
@@ -506,7 +507,8 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
             Long archiveAutoGroupId=null;
             //分类并卷规则的需要生成个随机数,作为同一个分类赋值archiveAutoNodeId
             if(archiveAutoType==2){
-                double ran=(Math.random()*100000000) + 1;
+                double v = Math.random() * 10000;
+                long ran = (long)v;
                 archiveAutoGroupId=Long.parseLong(System.currentTimeMillis()+""+ran);
             }
 
@@ -555,7 +557,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                 if(archiveAutoType==2){
                     Long groupId = dto.getArchiveAutoGroupId();
                     String selectNodeIds = dto.getSelectNodeIds();
-                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds);
+                    List<String> selectNodeIdlist = Arrays.asList(selectNodeIds.split(","));
                     //先将同一分组的节点删除配置,。
                     baseMapper.removeNodeForArchiveAutoRule_Group(groupId);
                     //然后再按照选择节点保存新的设置
@@ -572,7 +574,7 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                                 archiveTree.getArchiveAutoType(),
                                 archiveTree.getArchiveAutoNodeId(),
                                 archiveTree.getArchiveAutoGroupId(),
-                                archiveTree.getAncestors()
+                                archiveTree.getAncestors()+","+archiveTree.getId()
                         );
                     }
                 }
@@ -650,9 +652,10 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                             // 因为分类并卷规则影响范围包括下面所有子节点,如果给archive_auto_group_select=0的节点也就是范围内的子节点单独取消规则,会造成案卷归属节点错乱。
                             // (不理那么多,就这样限制先 。如业务非要发神经就要 TODO 验证节点的父节点是否为分类并卷规则,如是则取消。若无其他兄弟节点,继续往上验证。)
                             baseMapper.removeAllSonNodeIdsForArchiveAutoRule_2(node.getArchiveAutoType(),node.getAncestors());
+                        }else{
+                            returnMap.put("code","0");
+                            returnMap.put("msg","只能取消设置的节点,不能取消设置节点范围下节点");
                         }
-                        returnMap.put("code","0");
-                        returnMap.put("msg","只能取消设置的节点,不能取消设置节点范围下节点");
                     }
                     //删除节点及所有子节点 单独并卷规则
                     if(archiveAutoType==3){
@@ -677,9 +680,9 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
     public Map<String,Object> getArchiveAutoRule(Long id,boolean iswbsNode) {
 
         if(iswbsNode){
-            return getArchiveAutoRule_ArchiveTreeNode(id);
-        }else{
             return getArchiveAutoRule_WbsTreeNode(id);
+        }else{
+            return getArchiveAutoRule_ArchiveTreeNode(id);
         }
     }
 
@@ -702,6 +705,9 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                     String ancestors = archiveAutoNode.getAncestors();
                     String[] ancestorssplit = ancestors.split(",");//全路径ID
                     for(String pId:ancestorssplit){
+                        if(pId.equals("0")){
+                            continue;
+                        }
                         long pIdLong = Long.parseLong(pId);
                         ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
                         allName.append(pIdNode.getNodeName()+"/");
@@ -720,9 +726,10 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                     //找出当前节点大类
                     String ancestors = archiveTree.getAncestors();
                     String[] ancestorssplit = ancestors.split(",");//全路径ID
-                    String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]; //大类的ancestors
+                    String nodeAncestors = ancestorssplit[0]+","+ancestorssplit[1]+","+ancestorssplit[2]; //大类的ancestors
+                    Long bigNodeID =Long.parseLong(ancestorssplit[2]); //大类节点ID
                     //获取大类下所有节点,过滤单独规则,其他分类并卷规则组节点
-                    List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId()));
+                    List<ArchiveTreeAutoRuleVO> nodetree = ForestNodeMerger.merge(baseMapper.getAllSonNodeforGroupView(nodeAncestors, archiveTree.getArchiveAutoNodeId(),bigNodeID));
                     //获取与当前节点设置同一分类分组的节点
                     List<ArchiveTree> listGroup= baseMapper.selectList(Wrappers.<ArchiveTree>lambdaQuery()
                             .eq(ArchiveTree::getArchiveAutoGroupId, archiveTree.getArchiveAutoGroupId())
@@ -733,9 +740,10 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                     for(ArchiveTree node:listGroup){
                         nodeSelect.append(node.getId()+",");
                     }
-                    map.put("type",archiveAutoType);
+                    map.put("archiveAutoType",archiveAutoType);
+                    map.put("archiveAutoGroupId",archiveTree.getArchiveAutoGroupId());
                     map.put("tree",nodetree);
-                    map.put("data",nodeSelect.toString());
+                    map.put("selectNodeIds",nodeSelect.toString());
                     return map;
                 }
                 if(archiveAutoType==3){
@@ -744,6 +752,9 @@ public class ArchiveTreeServiceImpl extends BaseServiceImpl<ArchiveTreeMapper, A
                     String ancestors = archiveTree.getAncestors();
                     String[] ancestorssplit = ancestors.split(",");//全路径ID
                     for(String pId:ancestorssplit){
+                        if(pId.equals("0")){
+                            continue;
+                        }
                         long pIdLong = Long.parseLong(pId);
                         ArchiveTree pIdNode = baseMapper.selectById(pIdLong);
                         allName.append(pIdNode.getNodeName()+"/");

+ 9 - 2
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreePrivateServiceImpl.java

@@ -15,6 +15,7 @@ import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
 import org.jsoup.select.Elements;
 import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -1478,13 +1479,19 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
                 File file_in = ResourceUtil.getFile(tree.getHtmlUrl());
                 String fileCode = SnowFlakeUtil.getId() + "";
                 String htmlUrl = file_path + "/privateUrlCopy/" + fileCode + ".html";
-//                String htmlUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrlCopy\\" + fileCode + ".html";
                 File file_out = ResourceUtil.getFile(htmlUrl);
                 FileUtil.copy(file_in, file_out);
                 tree.setHtmlUrl(htmlUrl);
             }
             //批量修改
-            baseMapper.updateBatchByPKeyId(wbsTreePrivateList);
+            if (wbsTreePrivateList.size() > 1000){
+                List<List<WbsTreePrivate>> splitList = CommonUtil.splitList(wbsTreePrivateList, 1000);
+                for (List<WbsTreePrivate> list : splitList) {
+                    baseMapper.updateBatchByPKeyId(list);
+                }
+            }else {
+                baseMapper.updateBatchByPKeyId(wbsTreePrivateList);
+            }
         }
     }