Browse Source

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

liyuan 5 months ago
parent
commit
a5360fcabe

+ 11 - 6
blade-service/blade-los/src/main/java/org/springblade/los/Util/BigDecimalUtils.java

@@ -17,13 +17,18 @@ public class BigDecimalUtils {
 	public static String convertToEnglish(BigDecimal number) {
 		BigDecimal integerPart = number.setScale(0, BigDecimal.ROUND_DOWN);
 		String decimal = number.toString();
-		BigDecimal decimalAmount = new BigDecimal(decimal.substring(decimal.indexOf(".") + 1));
-		long integralPart = integerPart.longValue();
-		String uppercaseInteger = convert(integralPart).trim();
-		if (new BigDecimal("0.00").compareTo(decimalAmount) != 0) {
-			uppercaseInteger = uppercaseInteger + " POINT " + convert(decimalAmount.longValue()).trim();
+		if (decimal.indexOf(".") > 0) {
+			BigDecimal decimalAmount = new BigDecimal(decimal.substring(decimal.indexOf(".") + 1));
+			long integralPart = integerPart.longValue();
+			String uppercaseInteger = convert(integralPart).trim();
+			if (new BigDecimal("0.00").compareTo(decimalAmount) != 0) {
+				uppercaseInteger = uppercaseInteger + " POINT " + convert(decimalAmount.longValue()).trim();
+			}
+			return uppercaseInteger;
+		} else {
+			long integralPart = integerPart.longValue();
+            return convert(integralPart).trim();
 		}
-		return uppercaseInteger;
 	}
 
 	private static String convert(long number) {

+ 63 - 0
blade-service/blade-los/src/main/java/org/springblade/los/Util/BoxNumUtils.java

@@ -0,0 +1,63 @@
+package org.springblade.los.Util;
+
+import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
+
+/**
+ * @author :jixinyuan
+ * @date : 2025/6/12
+ */
+public class BoxNumUtils {
+
+
+	/**
+	 * 集装箱箱号验证
+	 *
+	 * @param cntrNo 箱号
+	 * @return 结果
+	 */
+	public static String containerNumberVerification(String cntrNo){
+
+//		result.setAck(EnumAck.Failure);
+		if (StringUtils.isEmpty(cntrNo)) {
+			return null;
+		}
+		int length = cntrNo.length();
+		if (length != 11) {
+			throw new RuntimeException("总长度非11位长!");
+		}
+		String sub1 = StringUtils.substring(cntrNo, 0, 4);
+		if (!sub1.matches("[A-Z]+")) {
+			throw new RuntimeException("第一部分非大写字母!");
+		}
+		String sub2 = StringUtils.substring(cntrNo, 4, length - 1);
+		if (!sub2.matches("[0-9]*")) {
+			throw new RuntimeException("第二部分非数字!");
+
+		}
+		String sub3 = StringUtils.substring(cntrNo, length - 1, length);
+		if (!sub3.matches("[0-9]*")) {
+			throw new RuntimeException("第二部分非数字!");
+
+		}
+		//定义一个字符串,集装箱编号的每个字符必定出自这串字符,其中11,22,33用?代替,获取对应值,满足0-38
+		String charCode = "0123456789A?BCDEFGHIJK?LMNOPQRSTU?VWXYZ";
+		char[] codeChars = cntrNo.toCharArray();//将接收到的字符串转换为字符数组,方便后续遍历
+		int num = 0;//初始化用于规则计算后累计的变量,用于计算结束后%第11位
+
+		for (int i = 0; i < 10; i++) {
+			int idx = charCode.indexOf(codeChars[i]);//遍历取出第i个字符,并从charCode字符串中查找这个字符所在位置,这个位置的值就是对应值
+			if (idx == -1 || charCode.charAt(idx) == '?') {//如果查找不到或者找到替代符号(?)一样,那么这个字符不是规则中所要求的字符,需要校验的字符串不符合集装箱号的规则,退出循环
+				throw new RuntimeException("不符合集装箱号的规则");
+			}
+			idx = (int) (idx * Math.pow(2, i));//这里的意思应该是说对应值*2的(n-1)次方;原文表达(2、第N位的箱号对应值再分别乘以2N-1 (N=1,2,3………..10))是误导的关键
+			num += idx;//累加
+		}
+		num = (num % 11) % 10;//取模11
+
+		if (!(Integer.parseInt(String.valueOf(codeChars[10])) == num)) {
+			throw new RuntimeException("第11位校验码未通过验证");
+		}
+		return null;
+	}
+
+}

+ 14 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/controller/BillsController.java

@@ -931,5 +931,19 @@ public class BillsController extends BladeController {
 	public R<String> updateBatchField(@RequestBody @Validated UpdateBillsFieldVo updateBillsFieldVo) {
 		return billsService.updateBatchField(updateBillsFieldVo);
 	}
+
+	/**
+	 * 批量修改提单类型
+	 *
+	 * @param ids      单据ids
+	 * @param billType 提单类型
+	 */
+	@GetMapping("/updateBillType")
+	@RepeatSubmit
+	public R updateBillType(@RequestParam("ids") String ids,
+							@RequestParam(value = "billType") String billType) {
+		return billsService.updateBillType(ids, billType);
+	}
+
 }
 

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/IBillsService.java

@@ -183,4 +183,6 @@ public interface IBillsService extends IService<Bills> {
 	 * @return 结果
 	 */
 	R<String> updateBatchField(UpdateBillsFieldVo updateBillsFieldVo);
+
+	R updateBillType(String ids, String billType);
 }

+ 42 - 14
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/BillsServiceImpl.java

@@ -29,10 +29,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.StringUtil;
-import org.springblade.los.Util.BigDecimalUtils;
-import org.springblade.los.Util.IDeptUtils;
-import org.springblade.los.Util.StringTools;
-import org.springblade.los.Util.ZrUtil;
+import org.springblade.los.Util.*;
 import org.springblade.los.basic.business.entity.BusinessType;
 import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.corps.entity.BCorps;
@@ -162,10 +159,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 	private final ZrUtil zrUtil;
 
 
-
-
-
-
 	@Override
 	public IPage<BillsVO> selectBillsPage(IPage<BillsVO> page, BillsVO bills) {
 		return page.setRecords(baseMapper.selectBillsPage(page, bills));
@@ -304,15 +297,14 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			// 初始创建为1
 			bills.setVersion("1");
 			this.save(bills);
-		}
-		else {
+		} else {
 			Bills dataSourceBill = baseMapper.selectOne(new LambdaQueryWrapper<Bills>().select(Bills::getId, Bills::getVersion).eq(Bills::getId, bills.getId()));
 			if (!Objects.equals(dataSourceBill.getVersion(), bills.getVersion())) {
 				return R.fail(601, "数据已被其他用户更新,请等待刷新后重试");
 			}
 			// 每更新一次往上累加一次版本
 			// 旧数据处理
-			int version = StringUtil.isBlank(dataSourceBill.getVersion()) ? 1 :Integer.parseInt(dataSourceBill.getVersion());
+			int version = StringUtil.isBlank(dataSourceBill.getVersion()) ? 1 : Integer.parseInt(dataSourceBill.getVersion());
 			bills.setVersion(String.valueOf(version + 1));
 			List<Long> ids = count.stream().map(Bills::getId).distinct().collect(Collectors.toList());
 			if (!"MH".equals(bills.getBillType())) {
@@ -568,6 +560,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 					.eq(Containers::getIsDeleted, 0));
 				if (!containersList.isEmpty()) {
 					for (Containers item : containersList) {
+						BoxNumUtils.containerNumberVerification(item.getCntrNo());
 						item.setUpdateUser(AuthUtil.getUserId());
 						item.setUpdateUserName(AuthUtil.getUserName());
 						item.setUpdateTime(new Date());
@@ -587,7 +580,7 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 						.distinct().filter(Objects::nonNull).collect(Collectors.joining(",")));
 				}
 			}
-		}else{
+		} else {
 			bills.setQuantityCntrDescr(null);
 		}
 		bills.setQuantityV20(V20);
@@ -754,7 +747,8 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				measurement = measurement.add(details.stream().map(Bills::getMeasurement).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
 
 			}
-		} else if ("MH".equals(bills.getBillType()) && ObjectUtils.isNotNull(bills.getId())) {
+		}
+		else if ("MH".equals(bills.getBillType()) && ObjectUtils.isNotNull(bills.getId())) {
 			Bills details = baseMapper.selectOne(new LambdaQueryWrapper<Bills>()
 				.select(Bills::getAmountDr, Bills::getAmountCr, Bills::getAmountProfit, Bills::getAmountDrUsd, Bills::getAmountCrUsd
 					, Bills::getAmountProfitUsd, Bills::getAmountDrLoc, Bills::getAmountCrLoc, Bills::getAmountProfitLoc
@@ -899,7 +893,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 			}
 			hmmEdiService.saveOrUpdate(bills.getHmmEdi());
 		}
-
 		if (ObjectUtils.isNotNull(bills.getFilesList())) {
 			for (FilesCenter item : bills.getFilesList()) {
 				item.setPid(bills.getId());
@@ -3901,4 +3894,39 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		return null;
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public R updateBillType(String ids, String billType) {
+		if (ObjectUtils.isNull(ids)) {
+			throw new RuntimeException("缺少必要参数");
+		}
+		List<Bills> billsList = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
+			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(Bills::getIsDeleted, 0)
+			.in(Bills::getId, Func.toLongList(ids)));
+		if (billsList.isEmpty()) {
+			throw new SecurityException("未查到单据信息");
+		}
+		List<Long> idList = billsList.stream().map(Bills::getId).collect(Collectors.toList());
+		List<Bills> billsLists = baseMapper.selectList(new LambdaQueryWrapper<Bills>()
+			.eq(Bills::getTenantId, AuthUtil.getTenantId())
+			.eq(Bills::getIsDeleted, 0)
+			.in(Bills::getMasterId, idList));
+		for (Bills item : billsList) {
+			if ("MH".equals(item.getBillType()) && "DD,MM".contains(billType)) {
+				if (ObjectUtils.isNotNull(item.getMasterBillNo())) {
+					throw new RuntimeException("提单号:" + item.getMblno() + "已填加到主单");
+				}
+			} else if ("MM".equals(item.getBillType()) && "DD,MH".contains(billType)) {
+				List<Bills> bills = billsLists.stream().filter(e -> e.getMasterId().equals(item.getId())).collect(Collectors.toList());
+				if (!bills.isEmpty()) {
+					throw new RuntimeException("提单号:" + item.getMblno() + "中存在分单");
+				}
+			}
+			item.setBillType(billType);
+		}
+		this.updateBatchById(billsList);
+		return R.data("操作成功");
+	}
+
 }

+ 3 - 2
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/ContainersServiceImpl.java

@@ -24,6 +24,7 @@ import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.los.Util.BoxNumUtils;
 import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.business.sea.dto.WaitingBox;
 import org.springblade.los.business.sea.entity.Bills;
@@ -89,9 +90,8 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
 				deptName = String.join(",", res.getData());
 			}
-
 		}
-
+		BoxNumUtils.containerNumberVerification(containers.getCntrNo());
 		String sealNo = ObjectUtils.isNotNull(containers.getSealNo()) ? containers.getSealNo().toUpperCase() : "";
 		// 普柜可以设定为,铅封不能重复,但框架 FR  FH这一类的,HMM要求录入NIL,MSK要求录入000000
 		Boolean isNilSealNo = "".equals(sealNo) || "NIL".equals(sealNo) || "000000".equals(sealNo);
@@ -503,6 +503,7 @@ public class ContainersServiceImpl extends ServiceImpl<ContainersMapper, Contain
 		List<ContainersBills> subtractContainersBillsList = new ArrayList<>();
 		List<ContainersCommodity> containersCommodityList = new ArrayList<>();
 		for (Containers containers : list) {
+			BoxNumUtils.containerNumberVerification(containers.getCntrNo());
 			String sealNo = ObjectUtils.isNotNull(containers.getSealNo()) ? containers.getSealNo().toUpperCase() : "";
 			// 普柜可以设定为,铅封不能重复,但框架 FR  FH这一类的,HMM要求录入NIL,MSK要求录入000000
 			Boolean isNilSealNo = "".equals(sealNo) || "NIL".equals(sealNo) || "000000".equals(sealNo);

+ 2 - 0
blade-service/blade-los/src/main/java/org/springblade/los/business/sea/service/impl/PreContainersServiceImpl.java

@@ -23,6 +23,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.los.Util.BoxNumUtils;
 import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.Util.RegularUtils;
 import org.springblade.los.basic.cntr.entity.BCntrTypes;
@@ -329,6 +330,7 @@ public class PreContainersServiceImpl extends ServiceImpl<PreContainersMapper, P
 			.eq(Containers::getIsDeleted, 0));
 		if (!containersList.isEmpty()) {
 			for (Containers item : containersList) {
+				BoxNumUtils.containerNumberVerification(item.getCntrNo());
 				item.setUpdateUser(AuthUtil.getUserId());
 				item.setUpdateUserName(AuthUtil.getUserName());
 				item.setUpdateTime(new Date());