Browse Source

海运出口修改是增加版本判断

liyuan 7 months ago
parent
commit
e459591cef

+ 0 - 16
blade-service-api/blade-los-api/src/main/java/org/springblade/los/business/sea/entity/Bills.java

@@ -1,19 +1,3 @@
-/*
- *      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.los.business.sea.entity;
 
 import com.baomidou.mybatisplus.annotation.FieldStrategy;

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

@@ -28,6 +28,7 @@ import org.springblade.core.secure.utils.AuthUtil;
 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.IDeptUtils;
 import org.springblade.los.Util.StringTools;
 import org.springblade.los.Util.ZrUtil;
@@ -41,7 +42,6 @@ import org.springblade.los.basic.cur.entity.BCurrency;
 import org.springblade.los.basic.cur.service.IBCurrencyService;
 import org.springblade.los.basic.vessels.entity.BVessels;
 import org.springblade.los.basic.vessels.mapper.VesselsMapper;
-import org.springblade.los.basic.zr.entity.ZrLog;
 import org.springblade.los.billno.entity.BusinessBillNo;
 import org.springblade.los.billno.service.IBusinessBillNoService;
 import org.springblade.los.business.amends.entity.Amends;
@@ -297,9 +297,19 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 				bills.setCreateDept(deptId);
 				bills.setCreateDeptName(deptName);
 			}
+			// 初始创建为1
+			bills.setVersion("1");
 			this.save(bills);
 		}
 		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());
+			bills.setVersion(String.valueOf(version + 1));
 			List<Long> ids = count.stream().map(Bills::getId).distinct().collect(Collectors.toList());
 			if (!"MH".equals(bills.getBillType())) {
 				if (ObjectUtils.isNotNull(bills.getMblno())) {

+ 7 - 0
blade-service/blade-los/src/main/java/org/springblade/los/check/service/impl/AuditProecessServiceImpl.java

@@ -28,6 +28,7 @@ import org.springblade.client.entity.Message;
 import org.springblade.client.feign.IMessageClient;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.StringUtil;
 import org.springblade.los.Util.IDeptUtils;
 import org.springblade.los.basic.acc.entity.Accounts;
 import org.springblade.los.basic.acc.service.IAccountsService;
@@ -393,6 +394,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 						throw new SecurityException("审批通过失败");
 					}
 					detail.setStatus(2);
+					int version = StringUtil.isBlank(detail.getVersion()) ? 1 :Integer.parseInt(detail.getVersion());
+					detail.setVersion(String.valueOf(version + 1));
 					int count = billsMapper.updateById(detail);
 					if (count == 0) {
 						throw new SecurityException("审批开始修改审核状态失败");
@@ -476,6 +479,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				if (detail == null) {
 					throw new SecurityException("审批通过失败");
 				}
+				int version = StringUtil.isBlank(detail.getVersion()) ? 1 :Integer.parseInt(detail.getVersion());
+				detail.setVersion(String.valueOf(version + 1));
 				detail.setStatus(4);
 				int count = billsMapper.updateById(detail);
 				if (count == 0) {
@@ -514,6 +519,8 @@ public class AuditProecessServiceImpl extends ServiceImpl<AuditProecessMapper, L
 				if (bills == null) {
 					throw new SecurityException("审批通过失败");
 				}
+				int version = StringUtil.isBlank(detail.getVersion()) ? 1 :Integer.parseInt(detail.getVersion());
+				detail.setVersion(String.valueOf(version + 1));
 				detail.setStatus(3);
 				detail.setBillStatus(3);
 				detail.setApprovedDate(new Date());