Browse Source

试验编号模块

chenr 2 tháng trước cách đây
mục cha
commit
c725e61e46
30 tập tin đã thay đổi với 1406 bổ sung20 xóa
  1. 34 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialAutoNumberDTO.java
  2. 6 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialMaterialMobilizationDTO.java
  3. 37 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialNumberRuleDTO.java
  4. 6 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSampleInfoDTO.java
  5. 11 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSelfInspectionRecordDTO.java
  6. 56 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialAutoNumber.java
  7. 77 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialNumberRule.java
  8. 34 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialAutoNumberVO.java
  9. 36 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialNumberRuleVO.java
  10. 17 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialNumberRuleVO1.java
  11. 129 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialAutoNumberController.java
  12. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialDetectionController.java
  13. 3 1
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialMaterialController.java
  14. 250 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialNumberRuleController.java
  15. 44 0
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialAutoNumberMapper.java
  16. 22 0
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialAutoNumberMapper.xml
  17. 46 0
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialNumberRuleMapper.java
  18. 34 0
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialNumberRuleMapper.xml
  19. 41 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialAutoNumberService.java
  20. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialMaterialMobilizationService.java
  21. 55 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialNumberRuleService.java
  22. 1 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialSelfInspectionRecordService.java
  23. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java
  24. 14 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/EntrustInfoServiceImpl.java
  25. 45 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialAutoNumberServiceImpl.java
  26. 18 2
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialMaterialMobilizationServiceImpl.java
  27. 336 0
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialNumberRuleServiceImpl.java
  28. 12 4
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java
  29. 36 10
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java
  30. 1 1
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TableInfoServiceImpl.java

+ 34 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialAutoNumberDTO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.dto;
+
+import org.springblade.business.entity.TrialAutoNumber;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TrialAutoNumberDTO extends TrialAutoNumber {
+	private static final long serialVersionUID = 1L;
+
+}

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialMaterialMobilizationDTO.java

@@ -26,4 +26,10 @@ public class TrialMaterialMobilizationDTO extends TrialMaterialMobilization {
     @ApiModelProperty("数据序号")
     private Integer dataNumber;
 
+    @ApiModelProperty("旧编号")
+    private String trialAutoNumber;
+
+    @ApiModelProperty("自增流水号")
+    private String autoIncrementNumber;
+
 }

+ 37 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialNumberRuleDTO.java

@@ -0,0 +1,37 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.dto;
+
+import org.springblade.business.entity.TrialNumberRule;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 数据传输对象实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TrialNumberRuleDTO extends TrialNumberRule {
+	private static final long serialVersionUID = 1L;
+
+    private Long nodeId;
+
+
+}

+ 6 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/TrialSampleInfoDTO.java

@@ -21,5 +21,11 @@ public class TrialSampleInfoDTO extends TrialSampleInfo {
     @ApiModelProperty("数据序号")
     private Integer dataNumber;
 
+    @ApiModelProperty("旧编号")
+    private String trialAutoNumber;
+
+    @ApiModelProperty("自增流水号")
+    private String autoIncrementNumber;
+
 
 }

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

@@ -29,4 +29,15 @@ public class TrialSelfInspectionRecordDTO extends TrialSelfInspectionRecord {
     @ApiModelProperty(value = "是否批量保存 0=单保存,1=批量保存")
     private Integer isBatchSave;
 
+    @ApiModelProperty(value = "记录表自增流水号")
+    private String recordAutoNumber;
+
+    @ApiModelProperty(value = "报告单自增流水号")
+    private String reportAutoNumber;
+
+    @ApiModelProperty(value = "旧记录编号")
+    private String oldRecordNumber;
+    @ApiModelProperty(value = "旧报告编号")
+    private String oldReportNumber;
+
 }

+ 56 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialAutoNumber.java

@@ -0,0 +1,56 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@TableName("u_trial_auto_number")
+@EqualsAndHashCode(callSuper = true)
+public class TrialAutoNumber extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 自增的流水号
+	*/
+		private String autoIncrementNumber;
+	/**
+	* 来源主表的主键ID
+	*/
+		private Long formDataId;
+	/**
+	* 1材料 2样品 3委托单 4记录表 5报告表
+	*/
+		private Integer type;
+    /**
+     * 试验编号规则ID
+      */
+        private Long numberRuleId;
+
+
+}

+ 77 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/TrialNumberRule.java

@@ -0,0 +1,77 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.springblade.core.mp.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@TableName("u_trial_number_rule")
+@EqualsAndHashCode(callSuper = true)
+public class TrialNumberRule extends BaseEntity {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	* 项目ID
+	*/
+    @ApiModelProperty("项目ID")
+		private Long projectId;
+	/**
+	* 合同段ID
+	*/
+    @ApiModelProperty("合同段ID")
+		private Long contractId;
+	/**
+	* 编号规则 1材料 2样品 3委托单 4记录表 5报告表
+	*/
+    @ApiModelProperty("编号规则 1材料 2样品 3委托单 4记录表 5报告表")
+		private Integer type;
+	/**
+	* 编号规则
+	*/
+    @ApiModelProperty("编号规则")
+		private Integer rule;
+	/**
+	* 数据填充
+	*/
+    @ApiModelProperty("数据填充")
+		private String data;
+	/**
+	* 是否自增
+	*/
+    @ApiModelProperty("是否自增0否1是")
+		private Integer isAutoIncrement;
+    /**
+     * 排序
+      */
+    @ApiModelProperty("排序")
+        private Integer sort;
+
+
+}

+ 34 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialAutoNumberVO.java

@@ -0,0 +1,34 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.vo;
+
+import org.springblade.business.entity.TrialAutoNumber;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TrialAutoNumberVO extends TrialAutoNumber {
+	private static final long serialVersionUID = 1L;
+
+}

+ 36 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialNumberRuleVO.java

@@ -0,0 +1,36 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.vo;
+
+import org.springblade.business.entity.TrialNumberRule;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 视图实体类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class TrialNumberRuleVO extends TrialNumberRule {
+	private static final long serialVersionUID = 1L;
+
+    private String trialNumber;
+
+}

+ 17 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/TrialNumberRuleVO1.java

@@ -0,0 +1,17 @@
+package org.springblade.business.vo;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springblade.business.entity.TrialNumberRule;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class TrialNumberRuleVO1 {
+    private List<TrialNumberRule> list=new ArrayList<>();
+    private String trialNumber;
+}

+ 129 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialAutoNumberController.java

@@ -0,0 +1,129 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.controller;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+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.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.business.entity.TrialAutoNumber;
+import org.springblade.business.vo.TrialAutoNumberVO;
+import org.springblade.business.service.ITrialAutoNumberService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/trialautonumber")
+@Api(value = "试验编号自增", tags = "试验编号自增")
+public class TrialAutoNumberController extends BladeController {
+
+	private final ITrialAutoNumberService trialAutoNumberService;
+
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 1)
+	@ApiOperation(value = "详情", notes = "传入trialAutoNumber")
+	public R<TrialAutoNumber> detail(TrialAutoNumber trialAutoNumber) {
+		TrialAutoNumber detail = trialAutoNumberService.getOne(Condition.getQueryWrapper(trialAutoNumber));
+		return R.data(detail);
+	}
+
+	/**
+	 * 分页
+	 */
+	@GetMapping("/list")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "分页", notes = "传入trialAutoNumber")
+	public R<IPage<TrialAutoNumber>> list(TrialAutoNumber trialAutoNumber, Query query) {
+		IPage<TrialAutoNumber> pages = trialAutoNumberService.page(Condition.getPage(query), Condition.getQueryWrapper(trialAutoNumber));
+		return R.data(pages);
+	}
+
+	/**
+	 * 自定义分页
+	 */
+	@GetMapping("/page")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "分页", notes = "传入trialAutoNumber")
+	public R<IPage<TrialAutoNumberVO>> page(TrialAutoNumberVO trialAutoNumber, Query query) {
+		IPage<TrialAutoNumberVO> pages = trialAutoNumberService.selectTrialAutoNumberPage(Condition.getPage(query), trialAutoNumber);
+		return R.data(pages);
+	}
+
+	/**
+	 * 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入trialAutoNumber")
+	public R save(@Valid @RequestBody TrialAutoNumber trialAutoNumber) {
+		return R.status(trialAutoNumberService.save(trialAutoNumber));
+	}
+
+	/**
+	 * 修改
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入trialAutoNumber")
+	public R update(@Valid @RequestBody TrialAutoNumber trialAutoNumber) {
+		return R.status(trialAutoNumberService.updateById(trialAutoNumber));
+	}
+
+	/**
+	 * 新增或修改
+	 */
+	@PostMapping("/submit")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "新增或修改", notes = "传入trialAutoNumber")
+	public R submit(@Valid @RequestBody TrialAutoNumber trialAutoNumber) {
+		return R.status(trialAutoNumberService.saveOrUpdate(trialAutoNumber));
+	}
+
+
+	/**
+	 * 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+		return R.status(trialAutoNumberService.deleteLogic(Func.toLongList(ids)));
+	}
+
+
+
+
+}

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

@@ -25,6 +25,7 @@ import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.ResourceUtil;
@@ -174,6 +175,8 @@ public class TrialDetectionController extends BladeController {
         jdbcTemplate.execute(sql5);
         String sql6 = "delete from u_information_query where wbs_id in(" + ids + ") and type = 2";
         jdbcTemplate.execute(sql6);
+        String sql7="update u_trial_auto_number set is_deleted=0 where form_data_id in ("+ids+")";
+        jdbcTemplate.execute(sql7);
         return R.status(true);
     }
 

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

@@ -90,7 +90,7 @@ public class TrialMaterialController extends BladeController {
     @PostMapping("/mobilization/submit")
     @ApiOperationSupport(order = 5)
     @ApiOperation(value = "进场材料新增或修改", notes = "传入TrialMaterialMobilization对象")
-    public R<Object> mobilizationSubmit(@Valid @RequestBody TrialMaterialMobilization obj) {
+    public R<Object> mobilizationSubmit(@Valid @RequestBody TrialMaterialMobilizationDTO obj) {
         return R.status(iTrialMaterialMobilizationService.mobilizationSubmit(obj));
     }
 
@@ -153,8 +153,10 @@ public class TrialMaterialController extends BladeController {
         if(b){
             //删除关联表中的额数据
             String sqlForDelTrailSampleRecord = "delete from u_trial_sampling_record where sample_info_id in ("+ids+")";
+            String update="update u_trial_auto_number set is_deleted=1 where form_data_id in ("+ids+")";
             try {
                 jdbcTemplate.execute(sqlForDelTrailSampleRecord);
+                jdbcTemplate.update(update);
             } catch (DataAccessException e) {
                 log.error("删除关联表中的额数据失败", e);
                 throw new RuntimeException(e);

+ 250 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/TrialNumberRuleController.java

@@ -0,0 +1,250 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.controller;
+
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.models.auth.In;
+import lombok.AllArgsConstructor;
+import javax.validation.Valid;
+
+import org.springblade.business.dto.TrialNumberRuleDTO;
+import org.springblade.business.mapper.TrialNumberRuleMapper;
+import org.springblade.business.vo.TrialNumberRuleVO1;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.mp.support.Condition;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.manager.entity.WbsTreePrivate;
+import org.springframework.beans.BeanUtils;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestParam;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.business.entity.TrialNumberRule;
+import org.springblade.business.vo.TrialNumberRuleVO;
+import org.springblade.business.service.ITrialNumberRuleService;
+import org.springblade.core.boot.ctrl.BladeController;
+
+import java.io.FileNotFoundException;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ *  控制器
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/trialnumberrule")
+@Api(value = "试验编号规则", tags = "试验编号规则")
+public class TrialNumberRuleController extends BladeController {
+
+	private final ITrialNumberRuleService trialNumberRuleService;
+    private final TrialNumberRuleMapper  trialNumberRuleMapper;
+
+	/**
+	 * 详情
+	 */
+//	@GetMapping("/detail")
+//	@ApiOperationSupport(order = 1)
+//	@ApiOperation(value = "详情", notes = "传入trialNumberRule")
+//	public R<TrialNumberRule> detail(TrialNumberRule trialNumberRule) {
+//		TrialNumberRule detail = trialNumberRuleService.getOne(Condition.getQueryWrapper(trialNumberRule));
+//		return R.data(detail);
+//	}
+//
+//	/**
+//	 * 分页
+//	 */
+//	@GetMapping("/list")
+//	@ApiOperationSupport(order = 2)
+//	@ApiOperation(value = "分页", notes = "传入trialNumberRule")
+//	public R<IPage<TrialNumberRule>> list(TrialNumberRule trialNumberRule, Query query) {
+//		IPage<TrialNumberRule> pages = trialNumberRuleService.page(Condition.getPage(query), Condition.getQueryWrapper(trialNumberRule));
+//		return R.data(pages);
+//	}
+
+	/**
+	 * 自定义分页
+	 */
+//	@GetMapping("/page")
+//	@ApiOperationSupport(order = 3)
+//	@ApiOperation(value = "分页", notes = "传入trialNumberRule")
+//	public R<IPage<TrialNumberRuleVO>> page(TrialNumberRuleVO trialNumberRule, Query query) {
+//		IPage<TrialNumberRuleVO> pages = trialNumberRuleService.selectTrialNumberRulePage(Condition.getPage(query), trialNumberRule);
+//		return R.data(pages);
+//	}
+
+	/**
+	 * 新增
+	 */
+	@PostMapping("/save")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "新增", notes = "传入trialNumberRule")
+	public R<String> save(@Valid @RequestBody TrialNumberRule trialNumberRule) {
+        Integer maxSort=trialNumberRuleMapper.selectMaxSort(trialNumberRule.getProjectId(),trialNumberRule.getContractId(),trialNumberRule.getType());
+        trialNumberRule.setSort(maxSort+1);
+        if(trialNumberRule.getContractId()==null||trialNumberRule.getContractId()==0L){
+            trialNumberRule.setStatus(1);
+        }else {
+            trialNumberRule.setStatus(2);
+        }
+        trialNumberRuleService.save(trialNumberRule);
+        trialNumberRuleService.clearTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(),trialNumberRule.getType());
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(), trialNumberRule.getType(), null, false);
+		return R.data(map.get("trialNumber"));
+	}
+
+	/**
+	 * 修改
+	 */
+	@PostMapping("/update")
+	@ApiOperationSupport(order = 5)
+	@ApiOperation(value = "修改", notes = "传入trialNumberRule")
+	public R<String> update(@Valid @RequestBody TrialNumberRule trialNumberRule) {
+        if(trialNumberRule.getRule()==6){
+            TrialNumberRule trialNumberRule1 = trialNumberRuleService.getById(trialNumberRule.getId());
+            if(trialNumberRule.getContractId()!=null&&trialNumberRule.getContractId()!=0L){
+                if(!StringUtils.equals(trialNumberRule1.getData(),trialNumberRule.getData())){
+                    trialNumberRuleMapper.updateAutoIncrement(trialNumberRule.getId());
+                }
+            }
+        }
+        trialNumberRuleService.updateById(trialNumberRule);
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(), trialNumberRule.getType(), null, false);
+		return R.data(map.get("trialNumber"));
+	}
+
+	/**
+	 * 调整排序
+	 */
+	@PostMapping("/sort")
+	@ApiOperationSupport(order = 6)
+	@ApiOperation(value = "调整排序", notes = "传入List<TrialNumberRule>")
+	public R<String> sort(@Valid @RequestBody List<TrialNumberRule> trialNumberRules) {
+        for (int i = 0; i < trialNumberRules.size(); i++) {
+            trialNumberRules.get(i).setSort(i+1);
+        }
+        trialNumberRuleService.saveOrUpdateBatch(trialNumberRules);
+        trialNumberRuleService.clearTrialNumber(trialNumberRules.get(0).getProjectId(),trialNumberRules.get(0).getContractId(),trialNumberRules.get(0).getType());
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(trialNumberRules.get(0).getProjectId(),trialNumberRules.get(0).getContractId(), trialNumberRules.get(0).getType(), null, false);
+        return R.data(map.get("trialNumber"));
+	}
+
+
+    /**
+     * 新增或修改
+     */
+//    @PostMapping("/submit")
+//    @ApiOperationSupport(order = 6)
+//    @ApiOperation(value = "新增或修改", notes = "传入trialNumberRule")
+//    public R<String> submit(@Valid @RequestBody TrialNumberRule trialNumberRule,BladeUser bladeUser) {
+//
+//
+//
+//
+//        return null;
+//    }
+
+
+	/**
+	 * 删除
+	 */
+	@PostMapping("/remove")
+	@ApiOperationSupport(order = 7)
+	@ApiOperation(value = "逻辑删除", notes = "传入ids")
+	public R<String> remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
+        String[] idss = ids.split(",");
+        TrialNumberRule trialNumberRule = trialNumberRuleService.getById(idss[0]);
+        trialNumberRuleService.clearTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(),trialNumberRule.getType());
+        trialNumberRuleService.deleteLogic(Func.toLongList(ids));
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(), trialNumberRule.getType(), null, false);
+		return R.data(map.get("trialNumber"));
+	}
+
+
+
+
+    /**
+     * type 1材料 2样品  4记录表 5报告表
+     * 委托单另外一个方法单独获取
+     */
+    @GetMapping("/getTrialNumber")
+    @ApiOperationSupport(order = 8)
+    @ApiOperation(value = "获取试验编号", notes = "传入projectId,contractId,type,nodeId")
+    public R<String> getTrialNumber(Long projectId,Long contractId, Integer type, Long nodeId){
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId,contractId, type, nodeId, true);
+        return  R.data(map.get("trialNumber"));
+    }
+    @GetMapping("/getEntrustNumber")
+    @ApiOperationSupport(order = 11)
+    @ApiOperation(value = "获取委托单编号")
+    public R<Map<String, String>>getEntrustNumber(Long pkeyId,Long contractId) throws FileNotFoundException {
+        return R.data(trialNumberRuleService.getEntrustNumber(pkeyId,contractId));
+    }
+
+    /**
+     * 获取试验编号规则
+     * @param
+     * @param contractId
+     * @param type
+     * @return
+     */
+    @GetMapping("/getTrialNumberRule")
+    @ApiOperationSupport(order = 9)
+    @ApiOperation(value = "获取试验编号规则", notes = "传入projectId,contractId(后管查询传0),type")
+    public R<TrialNumberRuleVO1> getTrialNumberRule(Long projectId,Long contractId, Integer type){
+        return R.data(trialNumberRuleService.getTrialNumberRule(projectId,contractId,type));
+    }
+
+    @GetMapping("/reTrialNumberRule")
+    @ApiOperationSupport(order = 10)
+    @ApiOperation(value = "重置试验编号规则")
+    public R<String> reTrialNumberRule(Long projectId, Long contractId, Integer type){
+        List<TrialNumberRule> trialNumberRules = trialNumberRuleService.getBaseMapper().selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getProjectId, projectId).eq(TrialNumberRule::getContractId, contractId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,2).orderByAsc(TrialNumberRule::getSort));
+        String ids = trialNumberRules.stream()
+            .map(o -> o.getId().toString())
+            .collect(Collectors.joining(","));
+        TrialNumberRule trialNumberRule = trialNumberRules.get(0);
+        trialNumberRuleService.clearTrialNumber(trialNumberRule.getProjectId(),trialNumberRule.getContractId(),trialNumberRule.getType());
+        trialNumberRuleService.deleteLogic(Func.toLongList(ids));
+        List<TrialNumberRule> rules = trialNumberRuleService.getBaseMapper().selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getProjectId, projectId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus, 1).orderByAsc(TrialNumberRule::getSort));
+        for (TrialNumberRule rule : rules) {
+            rule.setId(SnowFlakeUtil.getId());
+            rule.setStatus(2);
+            rule.setContractId(contractId);
+        }
+        trialNumberRuleService.saveOrUpdateBatch(rules);
+        Map<String, String> map = trialNumberRuleService.getTrialNumber(projectId,contractId, type, null, false);
+        return R.data(map.get("trialNumber"));
+    }
+
+
+
+
+}

+ 44 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialAutoNumberMapper.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.springblade.business.entity.TrialAutoNumber;
+import org.springblade.business.vo.TrialAutoNumberVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+public interface TrialAutoNumberMapper extends BaseMapper<TrialAutoNumber> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param trialAutoNumber
+	 * @return
+	 */
+	List<TrialAutoNumberVO> selectTrialAutoNumberPage(IPage page, TrialAutoNumberVO trialAutoNumber);
+
+    void clearTrialAutoNumber(@Param("nameRuleId") Long nameRuleId);
+}

+ 22 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialAutoNumberMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.business.mapper.TrialAutoNumberMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="trialAutoNumberResultMap" type="org.springblade.business.entity.TrialAutoNumber">
+        <result column="id" property="id"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="auto_increment_number" property="autoIncrementNumber"/>
+        <result column="form_data_id" property="formDataId"/>
+        <result column="type" property="type"/>
+    </resultMap>
+    <update id="clearTrialAutoNumber">
+        update u_trial_auto_number set is_deleted = 1 where name_rule_id = #{nameRuleId}
+    </update>
+
+
+    <select id="selectTrialAutoNumberPage" resultMap="trialAutoNumberResultMap">
+        select * from u_trial_auto_number where is_deleted = 0
+    </select>
+
+</mapper>

+ 46 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialNumberRuleMapper.java

@@ -0,0 +1,46 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.mapper;
+
+import org.apache.ibatis.annotations.Param;
+import org.springblade.business.entity.TrialNumberRule;
+import org.springblade.business.vo.TrialNumberRuleVO;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import java.util.List;
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+public interface TrialNumberRuleMapper extends BaseMapper<TrialNumberRule> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param trialNumberRule
+	 * @return
+	 */
+	List<TrialNumberRuleVO> selectTrialNumberRulePage(IPage page, TrialNumberRuleVO trialNumberRule);
+
+    Integer selectMaxSort(@Param("projectId") Long projectId, @Param("contractId") Long contractId, @Param("type") Integer type);
+
+    void updateAutoIncrement(@Param("id") Long id);
+}

+ 34 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TrialNumberRuleMapper.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.business.mapper.TrialNumberRuleMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="trialNumberRuleResultMap" type="org.springblade.business.entity.TrialNumberRule">
+        <result column="id" property="id"/>
+        <result column="create_time" property="createTime"/>
+        <result column="create_user" property="createUser"/>
+        <result column="create_dept" property="createDept"/>
+        <result column="update_user" property="updateUser"/>
+        <result column="update_time" property="updateTime"/>
+        <result column="status" property="status"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="project_id" property="projectId"/>
+        <result column="contract_id" property="contractId"/>
+        <result column="type" property="type"/>
+        <result column="rule" property="rule"/>
+        <result column="data" property="data"/>
+        <result column="is_auto_increment" property="isAutoIncrement"/>
+    </resultMap>
+    <update id="updateAutoIncrement">
+        update u_trial_number_rule set is_deleted=0 where number_rule_id = #{id}
+    </update>
+
+
+    <select id="selectTrialNumberRulePage" resultMap="trialNumberRuleResultMap">
+        select * from u_trial_number_rule where is_deleted = 0
+    </select>
+    <select id="selectMaxSort" resultType="java.lang.Integer">
+        select IFNULL(MAX(sort), 0) from u_trial_number_rule where project_id = #{projectId} and contract_id = #{contractId} and type = #{type}
+    </select>
+
+</mapper>

+ 41 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialAutoNumberService.java

@@ -0,0 +1,41 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service;
+
+import org.springblade.business.entity.TrialAutoNumber;
+import org.springblade.business.vo.TrialAutoNumberVO;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+public interface ITrialAutoNumberService extends BaseService<TrialAutoNumber> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param trialAutoNumber
+	 * @return
+	 */
+	IPage<TrialAutoNumberVO> selectTrialAutoNumberPage(IPage<TrialAutoNumberVO> page, TrialAutoNumberVO trialAutoNumber);
+
+}

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

@@ -17,7 +17,7 @@ public interface ITrialMaterialMobilizationService extends BaseService<TrialMate
 
     boolean mobilizationVerification(String number, String id, String contractId);
 
-    boolean mobilizationSubmit(TrialMaterialMobilization obj);
+    boolean mobilizationSubmit(TrialMaterialMobilizationDTO obj);
 
     TrialMaterialMobilization mobilizationDetail(Long id);
 

+ 55 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITrialNumberRuleService.java

@@ -0,0 +1,55 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service;
+
+import cn.hutool.core.lang.hash.Hash;
+import org.springblade.business.entity.TrialNumberRule;
+import org.springblade.business.vo.TrialNumberRuleVO;
+import org.springblade.business.vo.TrialNumberRuleVO1;
+import org.springblade.core.mp.base.BaseService;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springblade.core.secure.BladeUser;
+
+import java.io.FileNotFoundException;
+import java.util.Map;
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+public interface ITrialNumberRuleService extends BaseService<TrialNumberRule> {
+
+	/**
+	 * 自定义分页
+	 *
+	 * @param page
+	 * @param trialNumberRule
+	 * @return
+	 */
+	IPage<TrialNumberRuleVO> selectTrialNumberRulePage(IPage<TrialNumberRuleVO> page, TrialNumberRuleVO trialNumberRule);
+
+    Map<String,String> getTrialNumber(Long projectId,Long contractId, Integer type, Long nodeId, Boolean isSaveRedis);
+
+    TrialNumberRuleVO1 getTrialNumberRule(Long project,Long contractId, Integer type);
+    //编号规则发生改变,清空对应的编号
+    boolean clearTrialNumber(Long projectId, Long contractId, Integer type);
+
+
+    Map<String, String> getEntrustNumber(Long pkeyId,Long contractId) throws FileNotFoundException;
+}

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

@@ -5,6 +5,7 @@ import org.springblade.business.dto.*;
 import org.springblade.business.entity.TrialSelfInspectionRecord;
 import org.springblade.business.vo.*;
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springframework.web.multipart.MultipartFile;
 

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

@@ -42,7 +42,7 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
 
     private ExecutorService executorService;
     private final ArchiveInspectionInfoClient archiveInspectionInfoClient;
-    private final JdbcTemplate   jdbcTemplate;
+    private final JdbcTemplate  jdbcTemplate;
 
 
     @Override

+ 14 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/EntrustInfoServiceImpl.java

@@ -34,6 +34,7 @@ import org.springblade.business.vo.LoadDataInfoVO;
 import org.springblade.business.vo.TrialSampleDataInfoVO;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.Func;
@@ -68,6 +69,8 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
 	private final EntrustInfoMapper entrustInfoMapper;
     private final IInformationQueryService informationQueryService;
 	private final OperationLogClient operationLogClient;
+    private final TrialNumberRuleServiceImpl trialNumberRuleService;
+    private final BladeRedis bladeRedis;
 
     @Override
 	public IPage<EntrustInfoVO> selectEntrustInfoPage(IPage<EntrustInfoVO> page, EntrustInfoVO entrustInfo) {
@@ -194,6 +197,15 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
             entrustInfo.setId(Long.parseLong(dataInfo.get("id").toString()));
         }
         this.saveOrUpdate(entrustInfo);
+        String autoIncrementNumber=dataInfo.get("autoIncrementNumber")==null?"":dataInfo.get("autoIncrementNumber").toString();
+        String trialAutoNumber=dataInfo.get("trialAutoNumber")==null?"":dataInfo.get("trialAutoNumber").toString();
+        String entrustNo=entrustInfo.getEntrustNo()==null?"":entrustInfo.getEntrustNo();
+        if(StringUtils.isNotEmpty(autoIncrementNumber)){
+            if(trialAutoNumber.equals(entrustNo)){
+                trialNumberRuleService.checkSave(Long.parseLong(entrustInfo.getContractId()), 3, entrustInfo.getId(), autoIncrementNumber);
+            }
+            bladeRedis.del("trialAutoNumber:" + entrustInfo.getContractId() + ":" + 3 + ":" + entrustInfo.getId() + ":" + "lock:" + autoIncrementNumber);
+        }
 		dataInfo.put("groupId",entrustInfo.getId());
 		dataInfo.put("pkeyId", dataInfo.getString("nodeErTreeId"));
         if(StringUtils.isEmpty(entrustInfo.getEntrustNo())){
@@ -203,6 +215,8 @@ public class EntrustInfoServiceImpl extends BaseServiceImpl<EntrustInfoMapper, E
             entrustInfo.setEntrustName("");
         }
         dataInfo.put("entrustInfoName",entrustInfo.getEntrustNo()+entrustInfo.getEntrustName());
+        dataInfo.remove("autoIncrementNumber");
+        dataInfo.remove("trialAutoNumber");
         String pdfUrl = excelTabClient.saveEntrustTabData(dataInfo);
         return R.data(200,pdfUrl,"操作成功");
 	}

+ 45 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialAutoNumberServiceImpl.java

@@ -0,0 +1,45 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service.impl;
+
+import org.springblade.business.entity.TrialAutoNumber;
+import org.springblade.business.vo.TrialAutoNumberVO;
+import org.springblade.business.mapper.TrialAutoNumberMapper;
+import org.springblade.business.service.ITrialAutoNumberService;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Service
+public class TrialAutoNumberServiceImpl extends BaseServiceImpl<TrialAutoNumberMapper, TrialAutoNumber> implements ITrialAutoNumberService {
+
+	@Override
+	public IPage<TrialAutoNumberVO> selectTrialAutoNumberPage(IPage<TrialAutoNumberVO> page, TrialAutoNumberVO trialAutoNumber) {
+		return page.setRecords(baseMapper.selectTrialAutoNumberPage(page, trialAutoNumber));
+	}
+
+    public void clearTrialAutoNumber(Long nameRuleId){
+        baseMapper.clearTrialAutoNumber(nameRuleId);
+    }
+
+}

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

@@ -15,6 +15,7 @@ import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.time.DateUtils;
 import org.springblade.business.dto.TrialMaterialMobilizationDTO;
 import org.springblade.business.entity.TrialMaterialMobilization;
+import org.springblade.business.entity.TrialNumberRule;
 import org.springblade.business.entity.TrialSampleInfo;
 import org.springblade.business.entity.TrialSamplingRecord;
 import org.springblade.business.excel.TrialMaterialMobilizationExcel;
@@ -33,6 +34,7 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
@@ -66,6 +68,8 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
     private final TrialSamplingRecordMapper trialSamplingRecordMapper;
     private final NewIOSSClient newIOSSClient;
     private final JdbcTemplate jdbcTemplate;
+    private final TrialNumberRuleServiceImpl trialNumberRuleService;
+    private final BladeRedis bladeRedis;
 
     @Override
     public boolean mobilizationVerification(String number, String id, String contractId) {
@@ -86,12 +90,20 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
     }
 
     @Override
-    public boolean mobilizationSubmit(TrialMaterialMobilization obj) {
+    public boolean mobilizationSubmit(TrialMaterialMobilizationDTO obj) {
         if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
             throw new ServiceException("获取用户信息失败");
         }
         obj.setUserId(SecureUtil.getUserId());
-        return this.saveOrUpdate(obj);
+        this.saveOrUpdate(obj);
+        if(obj.getAutoIncrementNumber()!=null){
+            if(obj.getTrialAutoNumber().equals(obj.getMaterialNumber())){
+                trialNumberRuleService.checkSave(obj.getContractId(), 1, obj.getId(), obj.getAutoIncrementNumber());
+            }
+            bladeRedis.del("trialAutoNumber:" + obj.getContractId() + ":" + 1 + ":" + obj.getId() + ":" + "lock:" + obj.getAutoIncrementNumber());
+        }
+
+        return true;
     }
 
     @Override
@@ -452,6 +464,10 @@ public class TrialMaterialMobilizationServiceImpl extends BaseServiceImpl<TrialM
             return R.fail("所选数据均存在取样记录,不允许删除");
         }
         boolean b = super.deleteLogic(newIdList);
+        if(b){
+          String update="update u_trial_auto_number set is_deleted=1 where form_data_id in ("+ids+")";
+          jdbcTemplate.update(update);
+        }
         return  b?R.success("删除成功"):R.fail("删除失败");
     }
 }

+ 336 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialNumberRuleServiceImpl.java

@@ -0,0 +1,336 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.business.service.impl;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springblade.business.entity.TrialAutoNumber;
+import org.springblade.business.entity.TrialNumberRule;
+import org.springblade.business.vo.TrialNumberRuleVO;
+import org.springblade.business.mapper.TrialNumberRuleMapper;
+import org.springblade.business.service.ITrialNumberRuleService;
+import org.springblade.business.vo.TrialNumberRuleVO1;
+import org.springblade.common.constant.CommonConstant;
+import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SnowFlakeUtil;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.secure.BladeUser;
+import org.springblade.core.tool.utils.IoUtil;
+import org.springblade.core.tool.utils.ResourceUtil;
+import org.springblade.manager.entity.WbsTreePrivate;
+import org.springblade.system.cache.ParamCache;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.SingleColumnRowMapper;
+import org.springframework.stereotype.Service;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.time.LocalDate;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ *  服务实现类
+ *
+ * @author BladeX
+ * @since 2025-06-10
+ */
+@Service
+public class TrialNumberRuleServiceImpl extends BaseServiceImpl<TrialNumberRuleMapper, TrialNumberRule> implements ITrialNumberRuleService {
+
+    @Resource
+    private JdbcTemplate jdbcTemplate;
+    @Resource
+    private BladeRedis bladeRedis;
+    @Resource
+    private  TrialAutoNumberServiceImpl trialAutoNumberService;
+
+
+    @Override
+	public IPage<TrialNumberRuleVO> selectTrialNumberRulePage(IPage<TrialNumberRuleVO> page, TrialNumberRuleVO trialNumberRule) {
+		return page.setRecords(baseMapper.selectTrialNumberRulePage(page, trialNumberRule));
+	}
+
+    @Override
+    public Map<String,String> getTrialNumber(Long projectId,Long contractId, Integer type,Long nodeId,Boolean isSaveRedis) {
+        HashMap<String, String> map = new HashMap<>();
+        StringBuilder trialNumber = new StringBuilder();
+        List<TrialNumberRule> rules;
+        if(contractId==null||contractId==0L){
+            rules = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getProjectId, projectId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,1).orderByAsc(TrialNumberRule::getSort));
+        }else {
+             rules = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getContractId, contractId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,2).orderByAsc(TrialNumberRule::getSort));
+        }
+        for (TrialNumberRule rule : rules) {
+            if(rule.getRule()==1){
+                trialNumber.append(rule.getData());
+            } else if (rule.getRule()==2) {
+                if(contractId!=null&&contractId!=0L){
+                    String sql1="select contract_number from m_contract_info where id="+contractId;
+                    String result = jdbcTemplate.query(sql1, rs -> {
+                        if (rs.next()) {
+                            return rs.getString(1);
+                        } else {
+                            return "";
+                        }
+                    });
+                    trialNumber.append(result);
+                }else {
+                    trialNumber.append("合同段编号");
+                }
+            } else if (rule.getRule()==3) {
+                if (nodeId!=null) {
+                    String sql2="select unique_code from m_wbs_tree_private where p_key_id="+nodeId+" and is_deleted=0";
+                    String  result = jdbcTemplate.query(sql2, rs -> {
+                        if (rs.next()) {
+                            return rs.getString(1);
+                        } else {
+                            return "";
+                        }
+                    });
+                    trialNumber.append(result);
+                }
+            } else if (rule.getRule()==4) {
+                String currentYearStr = String.valueOf(LocalDate.now().getYear());
+                trialNumber.append(currentYearStr);
+            } else if (rule.getRule()==5) {
+                int currentMonthValue = LocalDate.now().getMonthValue();
+                String currentMonthStr = String.format("%02d", currentMonthValue);
+                trialNumber.append(currentMonthStr);
+            } else if (rule.getRule()==6) {
+                if(rule.getIsAutoIncrement()!=null&&rule.getIsAutoIncrement()==1){
+                    String autoIncrementNumber="";
+                    //如果是需要自增的 先要查出当前数据库中自增编号的最大值
+                    String sql3 = "SELECT MAX(auto_increment_number) FROM u_trial_auto_number where is_deleted=0";
+                    String maxNumber = jdbcTemplate.query(sql3, rs -> {
+                        if (rs.next()) {
+                            return rs.getObject(1, String.class);
+                        } else {
+                            return rule.getData();
+                        }
+                    });
+                    String sql4="select auto_increment_number FROM u_trial_auto_number where is_deleted=0  ORDER BY auto_increment_number ASC";
+                    List<String> autoNumbers = jdbcTemplate.query(sql4, new SingleColumnRowMapper<>(String.class));
+                    //判断自增的流水号是否是连续的 是连续的就在最大值加1,不是连续的先使用缺失的编号
+                    List<String> missingNumbers = findMissingNumberPatterns(autoNumbers);
+                    if(missingNumbers.isEmpty()){
+                        while (true){
+                            maxNumber=incrementFormattedNumberWithCheck(maxNumber);
+                            Object o = bladeRedis.get("trialAutoNumber:" + contractId + ":" + type + ":" + nodeId + ":" + "lock:" + maxNumber);
+                            if(o==null){
+                                break;
+                            }
+                        }
+                        autoIncrementNumber=maxNumber;
+
+                    }else {
+                        for (int i = 0; i < missingNumbers.size(); i++) {
+                            autoIncrementNumber=missingNumbers.get(i);
+                            Object o = bladeRedis.get("trialAutoNumber:" + contractId + ":" + type + ":" + nodeId + ":" + "lock:" + autoIncrementNumber);
+                            if(o==null){
+                                break;
+                            }
+                            autoIncrementNumber="";
+                        }
+                        if(autoIncrementNumber.equals("")){
+                            while (true){
+                                maxNumber=incrementFormattedNumberWithCheck(maxNumber);
+                                Object o = bladeRedis.get("trialAutoNumber:" + contractId + ":" + type + ":" + nodeId + ":" + "lock:" + maxNumber);
+                                if(o==null){
+                                    break;
+                                }
+                            }
+                            autoIncrementNumber=String.valueOf(maxNumber);
+                        }
+                    }
+                      if (isSaveRedis) {
+                        bladeRedis.setEx("trialAutoNumber:" + contractId + ":" + type + ":" + nodeId + ":" + "lock:" + autoIncrementNumber , autoIncrementNumber,30 * 60 * 1000L);
+                      }
+                    map.put("autoIncrementNumber",autoIncrementNumber);
+                    trialNumber.append(autoIncrementNumber);
+                }
+                else {
+                    trialNumber.append(rule.getData());
+                }
+            }
+        }
+        map.put("trialNumber",trialNumber.toString());
+        return map;
+    }
+
+    public String incrementFormattedNumberWithCheck(String data) {
+        if (data == null || data.isEmpty()) {
+            return "0";
+        }
+
+        int length = data.length();
+        int number = Integer.parseInt(data);
+        number += 1;
+
+        // 检查自增后的数字位数是否超过原始数据的长度
+        if (String.valueOf(number).length() > length) {
+            throw new ServiceException("自增后的编号超出原始格式位数限制:" + data);
+        }
+
+        return String.format("%0" + length + "d", number);
+    }
+
+    public List<String> findMissingNumberPatterns(List<String> autoNumbersStr) {
+        if (autoNumbersStr == null || autoNumbersStr.size() <= 1) {
+            return Collections.emptyList();
+        }
+
+        // 提取数字和最大长度
+        List<Long> numbers = new ArrayList<>();
+        int maxLength = 0;
+
+        for (String s : autoNumbersStr) {
+            try {
+                Long num = Long.parseLong(s);
+                numbers.add(num);
+                maxLength = Math.max(maxLength, s.length());
+            } catch (NumberFormatException ignored) {
+            }
+        }
+
+        if (numbers.size() <= 1) {
+            return Collections.emptyList();
+        }
+
+        // 排序
+        numbers.sort(Long::compareTo);
+
+        long start = numbers.get(0);
+        long end = numbers.get(numbers.size() - 1);
+        Set<Long> numberSet = new HashSet<>(numbers);
+
+        List<String> missing = new ArrayList<>();
+
+        for (long i = start; i <= end; i++) {
+            if (!numberSet.contains(i)) {
+                // 使用原始最长字符串的长度进行格式化
+                String formatted = String.format("%0" + maxLength + "d", i);
+                missing.add(formatted);
+            }
+        }
+
+        return missing;
+    }
+
+    @Override
+    public TrialNumberRuleVO1 getTrialNumberRule(Long projectId,Long contractId, Integer type) {
+        TrialNumberRuleVO1 vo1 = new TrialNumberRuleVO1();
+        List<TrialNumberRule> trialNumberRules;
+        if(contractId==0L){
+            trialNumberRules = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getProjectId, projectId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,1).orderByAsc(TrialNumberRule::getSort));
+        }else {
+            trialNumberRules = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getContractId, contractId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,2).orderByAsc(TrialNumberRule::getSort));
+        }
+        Map<String, String> map = getTrialNumber(projectId,contractId, type, null, false);
+        vo1.setList(trialNumberRules);
+        vo1.setTrialNumber(map.get("trialNumber"));
+        return vo1;
+    }
+
+    /**
+     * type 1材料 2样品 3委托单 4记录表 5报告表
+     * @param projectId
+     * @param contractId
+     * @param type
+     * @return
+     */
+    @Override
+    public boolean clearTrialNumber(Long projectId, Long contractId, Integer type) {
+        if(contractId!=null&&contractId!=0L){
+            String update;
+            if(type==1){
+                update="update u_trial_material_mobilization set material_number IS NULL where contract_id="+contractId;
+            } else if (type==2) {
+                update="update u_trial_sample_info set specification_number IS NULL where contract_id="+contractId;
+            } else if (type==3) {
+                update="update u_entrust_info set entrust_no IS NULL where contract_id="+contractId+" and status=1";
+            } else if (type==4) {
+                update="update u_trial_self_inspection_record set record_no IS NULL where contract_id="+contractId+" and task_status='未上报'";
+            }else{
+                update="update u_trial_self_inspection_record set report_no IS NULL where contract_id="+contractId+" and task_status='未上报'";
+            }
+            jdbcTemplate.execute(update);
+        }
+        return true;
+    }
+
+    @Override
+    public Map<String, String> getEntrustNumber(Long pkeyId,Long contractId) throws FileNotFoundException {
+        String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
+        String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
+        String sql="Select html_url from m_wbs_tree_private where p_key_id="+pkeyId;
+        WbsTreePrivate wbsTreePrivate = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<>(WbsTreePrivate.class));
+        String fileUrl = wbsTreePrivate.getHtmlUrl();
+        File file1 = ResourceUtil.getFile(fileUrl);
+        InputStream fileInputStream;
+        if (file1.exists()) {
+            fileInputStream = new FileInputStream(file1);
+        } else {
+            String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+            fileInputStream = CommonUtil.getOSSInputStream(path);
+        }
+        String htmlString = IoUtil.readToString(fileInputStream);
+        htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
+        htmlString = htmlString.replaceAll("title", "titlexx");
+        Document doc = Jsoup.parse(htmlString);
+        Elements elementsWithPlaceholderxx = doc.select("el-input[placeholder~=.*委托单编号.*]");
+        if(!elementsWithPlaceholderxx.isEmpty()){
+            Element first = elementsWithPlaceholderxx.first();
+            String key = first.attr("id");
+            Map<String, String> map = getTrialNumber(Long.valueOf(wbsTreePrivate.getProjectId()),contractId, 3, pkeyId, true);
+            map.put(key,map.get("trialNumber"));
+            return map;
+        }
+        return null;
+    }
+
+
+    public void checkSave(Long contractId,Integer type,Long formDataId,String autoNumber){
+        List<TrialNumberRule> list = baseMapper.selectList(Wrappers.<TrialNumberRule>query().lambda().eq(TrialNumberRule::getContractId, contractId).eq(TrialNumberRule::getType, type).eq(TrialNumberRule::getStatus,2).orderByAsc(TrialNumberRule::getSort));
+            if(list!=null&&list.size()>0){
+                List<TrialNumberRule> collect = list.stream().filter(o -> o.getRule() == 6 && o.getIsAutoIncrement() == 1).collect(Collectors.toList());
+                if(!collect.isEmpty()){
+                    TrialAutoNumber one = trialAutoNumberService.getOne(Wrappers.lambdaQuery(TrialAutoNumber.class).eq(TrialAutoNumber::getFormDataId, formDataId).eq(TrialAutoNumber::getType, 4));
+                    if(one==null){
+                        TrialAutoNumber trialAutoNumber = new TrialAutoNumber();
+                        trialAutoNumber.setId(SnowFlakeUtil.getId());
+                        trialAutoNumber.setType(type);
+                        trialAutoNumber.setNumberRuleId(collect.get(0).getId());
+                        trialAutoNumber.setFormDataId(formDataId);
+                        trialAutoNumber.setAutoIncrementNumber(autoNumber);
+                        trialAutoNumberService.save(trialAutoNumber);
+                    }
+                }
+            }
+    }
+
+}

+ 12 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSampleInfoServiceImpl.java

@@ -37,6 +37,7 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.redis.cache.BladeRedis;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.utils.*;
 import org.springblade.resource.feign.NewIOSSClient;
@@ -65,6 +66,8 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
     private final TrialSamplingRecordMapper trialSamplingRecordMapper;
     private final JdbcTemplate jdbcTemplate;
     private final IEntrustInfoService entrustInfoService;
+    private final TrialNumberRuleServiceImpl trialNumberRuleService;
+    private final BladeRedis bladeRedis;
 
     @Override
     public boolean sampleVerification(String specificationNumber, String id, String contractId, String nodeId) {
@@ -133,10 +136,9 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
     @Override
     public boolean sampleSubmit(TrialSampleInfoDTO obj) {
         //如果样品编号为空,那么就自动生成
-        if (ObjectUtil.isEmpty(obj.getSpecificationNumber())) {
-            this.buildNumber(obj);
-        }
-
+//        if (ObjectUtil.isEmpty(obj.getSpecificationNumber())) {
+//            this.buildNumber(obj);
+//        }
         TrialSampleInfo trialSampleInfo = BeanUtil.copyProperties(obj, TrialSampleInfo.class);
         if (trialSampleInfo != null) {
             if (ObjectUtils.isEmpty(trialSampleInfo.getMaterialCount())) {
@@ -146,6 +148,12 @@ public class TrialSampleInfoServiceImpl extends BaseServiceImpl<TrialSampleInfoM
                 trialSampleInfo.setRepresentativeCount("0");
             }
             this.saveOrUpdate(trialSampleInfo);
+            if(obj.getAutoIncrementNumber()!=null){
+                if(obj.getTrialAutoNumber().equals(obj.getSpecificationNumber())){
+                    trialNumberRuleService.checkSave(obj.getContractId(), 2, obj.getId(), obj.getAutoIncrementNumber());
+                }
+                bladeRedis.del("trialAutoNumber:" + obj.getContractId() + ":" + 2 + ":" + obj.getId() + ":" + "lock:" + obj.getAutoIncrementNumber());
+            }
 
             if (trialSampleInfo.getId() != null && obj.getMobilizationId() != null && obj.getMobilizationId() != -1) {
                 TrialSamplingRecord trialSamplingRecord = trialSamplingRecordMapper.selectByMobilizationIdAndSampleInfoId(obj.getMobilizationId(), trialSampleInfo.getId());

+ 36 - 10
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TrialSelfInspectionRecordServiceImpl.java

@@ -39,6 +39,8 @@ import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.oss.model.BladeFile;
+import org.springblade.core.redis.cache.BladeRedis;
+import org.springblade.core.secure.BladeUser;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.*;
@@ -92,7 +94,9 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
     private final TrialDeviceUseServiceImpl trialDeviceUseService;
     private final InformationQueryServiceImpl informationQueryService;
     private final TrialDetectionDataServiceImpl trialDetectionDataService;
-    private final IEntrustInfoService entrustInfoService;
+    private final BladeRedis bladeRedis;
+    private final TrialAutoNumberServiceImpl trialAutoNumberService;
+    private final TrialNumberRuleServiceImpl trialNumberRuleService;
 
     @Override
     public IPage<TrialSelfInspectionRecordVO> selfPage(IPage<TrialSelfInspectionRecord> page, TrialSelfInspectionRecordPageDTO dto) throws FileNotFoundException {
@@ -1087,21 +1091,21 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
         //------初始当前填报的表pKeyIds------
         this.initTrialTabIds(dto);
 
-        if(!this.judgingParameters(dto)){
-            //------初始编号信息------
-            this.initBuildNumber(dto);
-        }
+//        if(!this.judgingParameters(dto)){
+//            //------初始编号信息------
+//            this.initBuildNumber(dto);
+//        }
         this.saveOrUpdate(dto);
+
         if (ObjectUtil.isNotEmpty(dto.getId())) {
             //------获取最新试验记录------
             TrialSelfInspectionRecord obj = baseMapper.selectById(dto.getId());
             //如果传递了编号就修改对应记录的值 以第一张表的数据为准
             this.updateRecordNoOrReportNo(obj, dto);
             //------编辑时记录表编号或报告单编号为Null的重新生成------
-            if(!this.judgingParameters(dto)){
-                this.reBuildNumber(obj, dto);
-            }
-
+//            if(!this.judgingParameters(dto)){
+//                this.reBuildNumber(obj, dto);
+//            }
             //------保存实体表数据、试验记录信息、生成PDF------
             this.submitTrialData(obj, dto);
 
@@ -1114,12 +1118,34 @@ public class TrialSelfInspectionRecordServiceImpl extends BaseServiceImpl<TrialS
             //------关联新增设备使用记录信息------
             this.trialDeviceUseService.addDeviceUseInfo(dto);
         }
-
         // ---- 修改样品单号信息 --------
         if(dto!=null && Func.isNotEmpty(dto.getEntrustId())){
             //修改项目节点基础信息
             jdbcTemplate.update("update u_entrust_info set sample_status=4 where id ='"+dto.getEntrustId()+"'");
         }
+        String[] strings = dto.getTableType().split(",");
+        if(dto.getRecordAutoNumber()!=null||dto.getReportAutoNumber()!=null){
+            if (dto.getOldRecordNumber()!=null&&dto.getOldRecordNumber().equals(dto.getRecordNo())||dto.getOldReportNumber()!=null&&dto.getOldReportNumber().equals(dto.getReportNo())) {
+                if(strings.length==1){
+                    if(strings[0].equals("1")){
+                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
+                    }else {
+                        trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                    }
+                }else {
+                    trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),4,dto.getId(),dto.getRecordAutoNumber());
+                    trialNumberRuleService.checkSave(Long.valueOf(dto.getProjectId()),5,dto.getId(),dto.getReportAutoNumber());
+                }
+            }
+            if(strings.length==1&&strings[0].equals("1")){
+                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
+            }else if(strings.length==1&&strings[0].equals("2")){
+                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
+            }else {
+                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 4 + ":" + dto.getId() + ":" + "lock:" + dto.getRecordAutoNumber());
+                bladeRedis.del("trialAutoNumber:" + dto.getContractId() + ":" + 5 + ":" + dto.getId() + ":" + "lock:" + dto.getReportAutoNumber());
+            }
+        }
         return dto.getId().toString();
     }
 

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/TableInfoServiceImpl.java

@@ -56,7 +56,7 @@ public class TableInfoServiceImpl extends BaseServiceImpl<TableInfoMapper, Table
      * 十分钟执行一次
      * 替换动态表中的阿里云地址
      */
-    @Scheduled(cron = "0 */10 * * * ?")
+    //@Scheduled(cron = "0 */10 * * * ?")
 //    @Scheduled(fixedDelay = 60000)
     public void aliyunUrlReplace() {
         System.out.println("执行阿里云地址替换-----------------------------开始");