Browse Source

计量期

qianxb 1 year ago
parent
commit
beefae2590

+ 3 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/controller/ContractMeterPeriodController.java

@@ -36,6 +36,7 @@ import org.springblade.meter.entity.InterimPayCertificate;
 import org.springblade.meter.entity.MeterPeriod;
 import org.springblade.meter.service.IContractMaterialAdjustService;
 import org.springblade.meter.service.IInterimPayCertificateService;
+import org.springblade.meter.utils.StringUtils;
 import org.springblade.meter.vo.ContractMeterPeriodVO;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -109,6 +110,7 @@ public class ContractMeterPeriodController extends BladeController {
 					return R.fail("有计量期已经关联材料调差,无法删除");
 				}
 			}
+			String contractNumber = contractMeterPeriodService.getContractNumber(dto.getContractId());
 			//存在数据,先删再存,循环排序
 			contractMeterPeriodService.removeByContrId(dto.getContractId());
 			LocalDate lastDate = null;
@@ -130,6 +132,7 @@ public class ContractMeterPeriodController extends BladeController {
 				}
 				lastDate = period.getEndDate();
 				period.setSort(i);
+				period.setPayNumber(contractNumber + "-" +StringUtils.padZeroToFront(period.getPeriodNumber(),3));
 
 				InterimPayCertificate interimPayCertificate = this.interimPayCertificateService.getOne(Wrappers.<InterimPayCertificate>lambdaQuery().eq(InterimPayCertificate::getContractPeriodId, period.getId()));
 				if (interimPayCertificate != null) {

+ 25 - 0
blade-service/blade-meter/src/main/java/org/springblade/meter/utils/StringUtils.java

@@ -0,0 +1,25 @@
+package org.springblade.meter.utils;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2024/6/18 13:47
+ **/
+public class StringUtils {
+    public static String padZeroToFront(String originalStr, int minLength) {
+        if (originalStr == null) {
+            originalStr = "";
+        }
+        int strLen = originalStr.length();
+        if (strLen < minLength) {
+            StringBuilder sb = new StringBuilder(minLength);
+            for (int i = 0; i < minLength - strLen; i++) {
+                sb.append('0');
+            }
+            sb.append(originalStr);
+            return sb.toString();
+        } else {
+            return originalStr;
+        }
+    }
+}