liuyc há 2 anos atrás
pai
commit
8b5305626d
26 ficheiros alterados com 1663 adições e 179 exclusões
  1. 2 2
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDetectionData.java
  2. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialDeviceInfo.java
  3. 3 3
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialLaboratoryUserArchives.java
  4. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialMaterialMobilization.java
  5. 5 3
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialSampleInfo.java
  6. 5 6
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialSamplingRecordVO.java
  7. 14 4
      blade-service-api/blade-user-api/pom.xml
  8. 8 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDeviceInfoController.java
  9. 8 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java
  10. 5 3
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialDeviceInfoExcel.java
  11. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialMaterialMobilizationExcel.java
  12. 3 3
      blade-service/blade-business/src/main/java/org/springblade/business/excel/TrialSampleInfoExcel.java
  13. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialDeviceUseMapper.xml
  14. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialDeviceUseService.java
  15. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialMaterialMobilizationService.java
  16. 5 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialContainerClassificationServiceImpl.java
  17. 65 25
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceInfoServiceImpl.java
  18. 23 6
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceOverhaulServiceImpl.java
  19. 71 12
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialDeviceUseServiceImpl.java
  20. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialLaboratoryUserArchivesServiceImpl.java
  21. 70 13
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java
  22. 53 18
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java
  23. 76 66
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  24. 1228 0
      blade-service/blade-business/src/main/java/org/springblade/business/utils/DateUtils.java
  25. 2 2
      blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java
  26. 2 10
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ProjectInfoController.java

+ 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;
 
     /**

+ 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;
 
     /**

+ 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>

+ 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;
 
 }

+ 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]);
+    }
+
+}

+ 2 - 2
blade-service/blade-manager/src/main/java/com/mixsmart/utils/CustomFunction.java

@@ -2796,10 +2796,10 @@ public class CustomFunction {
 		return "";
 	}
 
-	public static void main(String[] args) {
+	/*public static void main(String[] args) {
 		String s="边坡或仰坡坡度_不大于设计_尺量:每洞口检查10处_实测";
 		System.out.println(s.split("[((].+[))]|_")[0]);
-	}
+	}*/
 
 
 }

+ 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)