Browse Source

1.箱管单据大保存增加版本号锁
2.付费申请增加判断申请金额是否超出应付金额
3.所欲费用明细一键保存所属公司中文名称不显示修改
4.箱池动态,四个导入更新箱轨迹日期不对修改
5.箱池动态导入接口增加判断,动态日期必填
6.计算起运港,目的港超期箱使费

纪新园 7 months ago
parent
commit
53eb2af3d4

+ 1 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/EmptyContainerAppearance.java

@@ -63,7 +63,7 @@ public class EmptyContainerAppearance {
 	/**
 	 * 动态日期
 	 */
-	@ExcelProperty(value = "动态日期")
+	@ExcelProperty(value = "动态日期*")
 	private Date boxStatusDate;
 
 }

+ 1 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/EmptyContainerEntry.java

@@ -63,7 +63,7 @@ public class EmptyContainerEntry {
 	/**
 	 * 动态日期
 	 */
-	@ExcelProperty(value = "动态日期")
+	@ExcelProperty(value = "动态日期*")
 	private Date boxStatusDate;
 
 }

+ 1 - 1
blade-service-api/blade-los-api/src/main/java/org/springblade/los/box/excel/GiveAnEncore.java

@@ -63,7 +63,7 @@ public class GiveAnEncore {
 	/**
 	 * 动态日期
 	 */
-	@ExcelProperty(value = "动态日期")
+	@ExcelProperty(value = "动态日期*")
 	private Date boxStatusDate;
 
 }

+ 259 - 6
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/PutBoxServiceImpl.java

@@ -27,14 +27,22 @@ import org.springblade.core.oss.model.BladeFile;
 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.CurrencyUtils;
 import org.springblade.los.basic.business.entity.BusinessType;
 import org.springblade.los.basic.business.service.IBusinessTypeService;
 import org.springblade.los.basic.cntr.entity.BCntrTypes;
 import org.springblade.los.basic.cntr.service.IBCntrTypesService;
 import org.springblade.los.basic.corps.entity.BCorps;
 import org.springblade.los.basic.corps.service.IBCorpsService;
+import org.springblade.los.basic.cur.entity.BCurExrate;
+import org.springblade.los.basic.fees.entity.BFees;
+import org.springblade.los.basic.fees.service.IBFeesService;
 import org.springblade.los.basic.ports.entity.BPorts;
 import org.springblade.los.basic.ports.service.IBPortsService;
+import org.springblade.los.basic.storage.entity.StorageFees;
+import org.springblade.los.basic.storage.entity.StorageFeesItems;
+import org.springblade.los.basic.storage.service.IStorageFeesItemsService;
+import org.springblade.los.basic.storage.service.IStorageFeesService;
 import org.springblade.los.billno.entity.BusinessBillNo;
 import org.springblade.los.billno.service.IBusinessBillNoService;
 import org.springblade.los.box.dto.BoxPoolContainerNumberDTO;
@@ -52,9 +60,10 @@ import org.springblade.los.box.vo.PutBoxVO;
 import org.springblade.los.business.sea.entity.Bills;
 import org.springblade.los.business.sea.entity.Containers;
 import org.springblade.los.business.sea.mapper.BillsMapper;
-import org.springblade.los.business.sea.service.IBillsService;
 import org.springblade.los.business.sea.service.IContainersService;
 import org.springblade.los.excel.RouteCostProfitExcel;
+import org.springblade.los.finance.fee.entity.FeeCenter;
+import org.springblade.los.finance.fee.service.IFeeCenterService;
 import org.springblade.resource.feign.IOssClient;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.stereotype.Service;
@@ -62,7 +71,11 @@ import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
+import java.math.BigDecimal;
 import java.rmi.RemoteException;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -107,6 +120,16 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 
 	private final IContainersService containersService;
 
+	private final IStorageFeesService storageFeesService;
+
+	private final IStorageFeesItemsService storageFeesItemsService;
+
+	private final IBFeesService bFeesService;
+
+	private final CurrencyUtils currencyUtils;
+
+	private final IFeeCenterService feeCenterService;
+
 	@Override
 	public IPage<PutBoxVO> selectPutBoxPage(IPage<PutBoxVO> page, PutBoxVO putBox) {
 		return null;
@@ -716,6 +739,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		List<PutBox> putBoxes = new ArrayList<>();
 		List<TradingBox> tradingBoxes = new ArrayList<>();
 		for (EmptyContainerAppearance item : excelList) {
+			if (ObjectUtils.isNull(item.getBoxStatusDate())) {
+				throw new RemoteException("动态日期不能为空");
+			}
 			BCntrTypes cntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
 			if (cntrTypes == null) {
 				throw new RemoteException("请先维护箱型:" + item.getBoxType() + "基础资料");
@@ -1065,7 +1091,6 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					archivesTrajectory.setBoxEastName(item.getBoxEastName());
 					archivesTrajectory.setMblno(item.getMblno());
 					archivesTrajectory.setBoxDynamics("空箱出场");
-					archivesTrajectory.setNewDate(tradingBox.getRentDate());
 					if ("OW-N".equals(tradingBox.getType())) {
 						archivesTrajectory.setStatus("OW-拿");
 					} else if ("OW-F".equals(tradingBox.getType())) {
@@ -1230,6 +1255,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			throw new RuntimeException("未找到可用业务类型");
 		}
 		for (GiveAnEncore item : excelList) {
+			if (ObjectUtils.isNull(item.getBoxStatusDate())) {
+				throw new RemoteException("动态日期不能为空");
+			}
 			BPorts ports = portsList.stream().filter(e -> e.getCnName().equals(item.getPortName())).findFirst().orElse(null);
 			if (ports == null) {
 				throw new RemoteException("请先维护港口:" + item.getPortName() + "基础资料");
@@ -1243,7 +1271,7 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			if (archives == null) {
 				throw new RemoteException("箱号:" + item.getBoxCode() + "未查到数据");
 			}
-			if (!archives.getBoxType().equals(item.getBoxType())) {
+			if (!archives.getTypeName().equals(item.getBoxType())) {
 				throw new RemoteException("箱号:" + item.getBoxCode() + "与箱档案中箱型不符");
 			}
 			if (ObjectUtils.isNotNull(archives.getContainerNumberTypeOw()) && "OW(放)".equals(archives.getContainerNumberTypeOw())) {
@@ -1445,6 +1473,8 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		if (!tradingBoxItemOldList.isEmpty()) {
 			tradingBoxItemService.updateBatchById(tradingBoxItemOldList);
 		}
+		//计算超期箱使费
+		this.countOverdueFee(tradingBoxList, tradingBoxItemOldList, "2");
 		ArchivesFiles archivesFiles = new ArchivesFiles();
 		archivesFiles.setCreateUser(AuthUtil.getUserId());
 		archivesFiles.setCreateTime(new Date());
@@ -1461,6 +1491,222 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		return R.data("操作成功");
 	}
 
+	private void countOverdueFee(List<TradingBox> tradingBoxList, List<TradingBoxItem> tradingBoxItemOldList,
+								 String type) {
+		List<FeeCenter> feeCenterList = new ArrayList<>();
+		List<String> mblnoList = tradingBoxItemOldList.stream().map(TradingBoxItem::getMblno).collect(Collectors.toList());
+		if (!mblnoList.isEmpty()) {
+			//海运进出口单据
+			List<Bills> billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
+				.eq(Bills::getTenantId, AuthUtil.getTenantId())
+				.eq(Bills::getIsDeleted, 0)
+				.in(Bills::getMblno, mblnoList)
+				.apply("find_in_set(bill_type,'DD,MH')")
+			);
+			if (billsList.isEmpty()) {
+				throw new RuntimeException("未查到对应提单号海运进出口单据");
+			}
+			List<String> branchIdList = billsList.stream().map(Bills::getBranchId).distinct().collect(Collectors.toList());
+			//超期标准
+			List<StorageFees> storageFeesList = storageFeesService.list(new LambdaQueryWrapper<StorageFees>()
+				.eq(StorageFees::getTenantId, AuthUtil.getTenantId())
+				.eq(StorageFees::getIsDeleted, 0)
+				.in(StorageFees::getBranchId, branchIdList));
+			if (storageFeesList.isEmpty()) {
+				throw new RuntimeException("请先维护基础资料-超期标准");
+			}
+			List<Long> idList = storageFeesList.stream().map(StorageFees::getId).collect(Collectors.toList());
+			//超期标准明细
+			List<StorageFeesItems> storageFeesItemsList = storageFeesItemsService.list(new LambdaQueryWrapper<StorageFeesItems>()
+				.eq(StorageFeesItems::getTenantId, AuthUtil.getTenantId())
+				.eq(StorageFeesItems::getIsDeleted, 0)
+				.in(StorageFeesItems::getPid, idList));
+			if (storageFeesItemsList.isEmpty()) {
+				throw new RuntimeException("请先维护基础资料-超期标准");
+			}
+			//超期箱使费
+			BFees fees = bFeesService.getOne(new LambdaQueryWrapper<BFees>()
+				.eq(BFees::getTenantId, AuthUtil.getTenantId())
+				.eq(BFees::getIsDeleted, 0)
+				.eq(BFees::getCode, "CQXSF"));
+			if (fees == null) {
+				throw new RuntimeException("请先维护费用基础信息");
+			}
+			for (TradingBoxItem item : tradingBoxItemOldList) {
+				//查找OW明细对应主表
+				TradingBox tradingBox = tradingBoxList.stream().filter(e -> e.getId().equals(item.getPid())).findFirst().orElse(null);
+				if (tradingBox == null) {
+					throw new RuntimeException("未查到OW单据");
+				}
+				//查找OW明细提单号对应海运进出口单据
+				Bills bills = billsList.stream().filter(e -> e.getMblno().equals(item.getMblno())).findFirst().orElse(null);
+				if (bills == null) {
+					throw new RuntimeException("未查到提单号:" + item.getMblno() + "海运进出口单据");
+				}
+				//对应海运进出口单据所属公司本位币
+				String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
+				//对应海运进出口单据所属公司所有币别
+				List<BCurExrate> curExrateList = currencyUtils.obtainRate(new Date(), "1", bills.getBranchId());
+				//所属公司具体超期标准
+				StorageFees storageFees = new StorageFees();
+				if ("SE".equals(bills.getBusinessType())) {
+					storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
+						"出口超期箱".equals(e.getType())).findFirst().orElse(null);
+				} else if ("SI".equals(bills.getBusinessType())) {
+					storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
+						"进口超期箱".equals(e.getType())).findFirst().orElse(null);
+				} else {
+					storageFees = storageFeesList.stream().filter(e -> e.getBranchId().equals(bills.getBranchId()) &&
+						"退关、无货返空箱".equals(e.getType())).findFirst().orElse(null);
+				}
+				if (storageFees == null) {
+					throw new RuntimeException("请先维护基础资料-超期标准");
+				}
+				StorageFees finalStorageFees = storageFees;
+				//所属公司具体超期标准明细
+				List<StorageFeesItems> storageFeesItems = storageFeesItemsList.stream().filter(e -> e.getPid().equals(finalStorageFees.getId()))
+					.collect(Collectors.toList());
+				if (storageFeesItems.isEmpty()) {
+					throw new RuntimeException("请先维护基础资料-超期标准");
+				}
+				//超期天数
+				int overdueDays = 0;
+				if ("1".equals(type)) {
+					//起运港超期天数
+					if (ObjectUtils.isNotNull(item.getPolPickUpDate()) && ObjectUtils.isNotNull(bills.getEtd())) {
+						LocalDateTime ldt1 = bills.getEtd().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+						LocalDateTime ldt2 = item.getPolPickUpDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+						long days = ChronoUnit.DAYS.between(ldt1, ldt2);
+						if (ObjectUtils.isNull(bills.getPolFreeBoxUseDays()) || 0 == bills.getPolFreeBoxUseDays() ||
+							days > bills.getPolFreeBoxUseDays()) {
+							overdueDays = (int) (days - bills.getPolFreeBoxUseDays());
+						}
+					}
+				} else if ("2".equals(type)) {
+					//目的港超期天数
+					if (ObjectUtils.isNotNull(item.getPodEmptyContainerReturnDate()) &&
+						ObjectUtils.isNotNull(bills.getEta())) {
+						LocalDateTime ldt1 = item.getPodEmptyContainerReturnDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+						LocalDateTime ldt2 = bills.getEta().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+						long days = ChronoUnit.DAYS.between(ldt1, ldt2);
+						if (ObjectUtils.isNull(bills.getPodFreeBoxUseDays()) || 0 == bills.getPodFreeBoxUseDays() ||
+							days > bills.getPodFreeBoxUseDays()) {
+							overdueDays = (int) (days - bills.getPodFreeBoxUseDays());
+						}
+					}
+				} else {
+					throw new RuntimeException("业务类型错误,请联系管理员");
+				}
+				if (overdueDays != 0) {
+					FeeCenter feeCenter = new FeeCenter();
+					feeCenter.setBillType("箱东");
+					feeCenter.setCorpId(tradingBox.getPurchaseCompanyId());
+					feeCenter.setCorpCnName(tradingBox.getPurchaseCompanyName());
+					feeCenter.setCorpEnName(tradingBox.getPurchaseCompanyName());
+					feeCenter.setCreateTime(new Date());
+					feeCenter.setCreateUser(AuthUtil.getUserId());
+					feeCenter.setCreateUserName(AuthUtil.getUserName());
+					feeCenter.setPid(item.getPid());
+					if ("OW(拿)".equals(tradingBox.getType())) {
+						feeCenter.setDc("C");
+					} else {
+						feeCenter.setDc("D");
+					}
+					feeCenter.setFeeId(fees.getId());
+					feeCenter.setFeeCode(fees.getCode());
+					feeCenter.setFeeCnName(fees.getCnName());
+					feeCenter.setFeeEnName(fees.getEnName());
+					feeCenter.setCurCode(storageFeesItems.get(0).getCurCode());
+					feeCenter.setCntrNo(item.getCode());
+					feeCenter.setUnitNo(item.getBoxType());
+					//计算天数
+					int days = overdueDays + 1;
+					int earlySumDays = 0;
+					String text = "";
+					int dayLength;
+					BigDecimal amount = new BigDecimal("0.00");
+					for (StorageFeesItems term : storageFeesItems) {
+						BigDecimal rate;
+						//根据箱型获取具体超期单价
+						if ("20GP".equals(item.getBoxType())) {
+							rate = term.getPrice20gp();
+						} else if ("40HC".equals(item.getBoxType())) {
+							rate = term.getPrice40hc();
+						} else if ("40GP".equals(item.getBoxType())) {
+							rate = term.getPrice40gp();
+						} else {
+							continue;
+						}
+						dayLength = term.getEndDay() - term.getStartDay() + 1;
+						if (earlySumDays >= dayLength) {
+							earlySumDays -= dayLength;
+							continue;
+						}
+						if (earlySumDays + days > dayLength) {
+							int tempDays = dayLength - earlySumDays;
+							earlySumDays = 0;
+							days -= tempDays;
+							BigDecimal calculate = rate.multiply(new BigDecimal(tempDays + ""));
+							amount = amount.add(calculate);
+							text = text + tempDays + "天*" + rate + "元=" + calculate + "元,";
+						} else {
+							BigDecimal calculate = rate.multiply(new BigDecimal(days + ""));
+							amount = amount.add(calculate);
+							text = text + days + "天*" + rate + "元=" + calculate + "元";
+							days = 0;
+							break;
+						}
+					}
+					if (days != 0) {
+						if ("20GP".equals(item.getBoxType())) {
+							BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp().multiply(new BigDecimal(days + ""));
+							amount = amount.add(calculate);
+							text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice20gp() + "元=" + calculate + "元,";
+						} else if ("40HC".equals(item.getBoxType())) {
+							BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice40hc().multiply(new BigDecimal(days + ""));
+							amount = amount.add(calculate);
+							text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice40hc() + "元=" + calculate + "元,";
+						} else if ("40GP".equals(item.getBoxType())) {
+							BigDecimal calculate = storageFeesItems.get(storageFeesItems.size() - 1).getPrice40gp().multiply(new BigDecimal(days + ""));
+							amount = amount.add(calculate);
+							text = text + "超出费用:" + days + "天*" + storageFeesItems.get(storageFeesItems.size() - 1).getPrice40gp() + "元=" + calculate + "元,";
+						} else {
+							continue;
+						}
+					}
+					if (exrateType.equals(feeCenter.getCurCode())) {
+						feeCenter.setExrate(new BigDecimal("1.00"));
+					} else {
+						feeCenter.setExrate(currencyUtils.obtainExrate("C", curExrateList, feeCenter.getCurCode(), "1"));
+					}
+					feeCenter.setAmount(amount);
+					feeCenter.setAmountLoc(amount.multiply(feeCenter.getExrate()));
+					feeCenter.setPrice(amount);
+					feeCenter.setRemarks(text);
+					feeCenter.setQuantity(new BigDecimal("1"));
+					feeCenter.setOutboundDate(tradingBox.getRentDate());
+					feeCenter.setBillNo(tradingBox.getSysNo());
+					feeCenter.setBusinessType(tradingBox.getType());
+					feeCenter.setBillDate(tradingBox.getPurchaseDate());
+					feeCenter.setBillCorpId(tradingBox.getPurchaseCompanyId());
+					feeCenter.setBillCorpCnName(tradingBox.getPurchaseCompanyName());
+					feeCenter.setBillCorpEnName(tradingBox.getPurchaseCompanyName());
+					feeCenter.setBillShortName(tradingBox.getPurchaseCompanyName());
+					feeCenter.setMblno(tradingBox.getContainerNumber());
+					feeCenter.setPolId(tradingBox.getPolId());
+					feeCenter.setPolCode(tradingBox.getPolCode());
+					feeCenter.setPolCnName(tradingBox.getPolCname());
+					feeCenter.setPolEnName(tradingBox.getPolEname());
+					feeCenter.setAutomaticGenerated("1");
+					feeCenterList.add(feeCenter);
+				}
+			}
+		}
+		if (!feeCenterList.isEmpty()) {
+			feeCenterService.saveBatch(feeCenterList);
+		}
+	}
+
 	private Archives updateArchives(Archives archives, GiveAnEncore item, BPorts ports, BCorps corps) {
 		archives.setUpdateTime(new Date());
 		archives.setUpdateUser(AuthUtil.getUserId());
@@ -1812,6 +2058,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			throw new RuntimeException("未找到可用业务类型");
 		}
 		for (GiveAnEncore item : excelList) {
+			if (ObjectUtils.isNull(item.getBoxStatusDate())) {
+				throw new RemoteException("动态日期不能为空");
+			}
 			BPorts ports = portsList.stream().filter(e -> e.getCnName().equals(item.getPortName())).findFirst().orElse(null);
 			if (ports == null) {
 				throw new RemoteException("请先维护港口:" + item.getPortName() + "基础资料");
@@ -2012,14 +2261,14 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 			archivesService.removeByIds(archivesDateleList);
 		}
 		if (!putBoxItemsOldList.isEmpty()) {
-			for (PutBoxItems item : putBoxItemsOldList){
+			for (PutBoxItems item : putBoxItemsOldList) {
 				item.setPolReturnDate(item.getPodEmptyContainerReturnDate());
 				item.setPodEmptyContainerReturnDate(null);
 			}
 			putBoxItemsService.updateBatchById(putBoxItemsOldList);
 		}
 		if (!tradingBoxItemOldList.isEmpty()) {
-			for (TradingBoxItem item : tradingBoxItemOldList){
+			for (TradingBoxItem item : tradingBoxItemOldList) {
 				item.setPolReturnDate(item.getPodEmptyContainerReturnDate());
 				item.setPodEmptyContainerReturnDate(null);
 			}
@@ -2150,6 +2399,9 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 		List<PutBox> putBoxes = new ArrayList<>();
 		List<TradingBox> tradingBoxes = new ArrayList<>();
 		for (EmptyContainerAppearance item : excelList) {
+			if (ObjectUtils.isNull(item.getBoxStatusDate())) {
+				throw new RemoteException("动态日期不能为空");
+			}
 			BCntrTypes cntrTypes = cntrTypesList.stream().filter(e -> e.getCnName().equals(item.getBoxType())).findFirst().orElse(null);
 			if (cntrTypes == null) {
 				throw new RemoteException("请先维护箱型:" + item.getBoxType() + "基础资料");
@@ -2485,7 +2737,6 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 					archivesTrajectory.setBoxEastName(item.getBoxEastName());
 					archivesTrajectory.setMblno(item.getMblno());
 					archivesTrajectory.setBoxDynamics("空箱提箱进场");
-					archivesTrajectory.setNewDate(tradingBox.getRentDate());
 					if ("OW-N".equals(tradingBox.getType())) {
 						archivesTrajectory.setStatus("OW-拿");
 					} else if ("OW-F".equals(tradingBox.getType())) {
@@ -2507,6 +2758,8 @@ public class PutBoxServiceImpl extends ServiceImpl<PutBoxMapper, PutBox> impleme
 				}
 			}
 		}
+		//计算超期箱使费
+		this.countOverdueFee(tradingBoxList, tradingBoxItemList, "1");
 		ArchivesFiles archivesFiles = new ArchivesFiles();
 		archivesFiles.setCreateUser(AuthUtil.getUserId());
 		archivesFiles.setCreateTime(new Date());

+ 14 - 0
blade-service/blade-los/src/main/java/org/springblade/los/box/service/impl/TradingBoxServiceImpl.java

@@ -374,7 +374,20 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 			BigDecimal amountCUsd = new BigDecimal("0.00");
 			BigDecimal amountLocD = new BigDecimal("0.00");
 			BigDecimal amountLocC = new BigDecimal("0.00");
+			List<Long> idList = tradingBox.getFeeCenterList().stream().map(FeeCenter::getId).filter(Objects::nonNull).collect(Collectors.toList());
+			List<FeeCenter> feeCenterList1 = new ArrayList<>();
+			if (!idList.isEmpty()) {
+				feeCenterList1 = feeCenterService.list(new LambdaQueryWrapper<FeeCenter>()
+					.in(FeeCenter::getId, idList));
+			}
 			for (FeeCenter item : tradingBox.getFeeCenterList()) {
+				if (item.getId() != null && !feeCenterList1.isEmpty()) {
+					FeeCenter feeCenter1 = feeCenterList1.stream().filter(e -> e.getId().equals(item.getId()))
+						.findFirst().orElse(null);
+					if (feeCenter1 != null && !item.getVersion().equals(feeCenter1.getVersion())) {
+						throw new RuntimeException("数据已被其他用户更新,请等待刷新后重试");
+					}
+				}
 				item.setAmountLoc(item.getAmount().multiply(item.getExrate()));
 				if (exrateType.equals(item.getCurCode())) {
 					if ("D".equals(item.getDc())) {
@@ -2197,6 +2210,7 @@ public class TradingBoxServiceImpl extends ServiceImpl<TradingBoxMapper, Trading
 				feeCenter.setExrate(currencyUtils.obtainExrate("C", curExrateList, feeCenter.getCurCode(), "1"));
 			}
 			feeCenter.setAmount(amount);
+			feeCenter.setAmountLoc(amount.multiply(feeCenter.getExrate()));
 			feeCenter.setPrice(amount);
 			feeCenter.setRemarks(text);
 			feeCenter.setQuantity(new BigDecimal("1"));

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

@@ -420,12 +420,6 @@ public class BillsServiceImpl extends ServiceImpl<BillsMapper, Bills> implements
 		BigDecimal amountCrLoc = new BigDecimal("0.00");
 		BigDecimal amountProfitLoc;
 		List<FeeCenter> feeCenterListAll = new ArrayList<>();
-		Date date;
-		if ("SE".equals(bills.getBusinessType())) {
-			date = bills.getEtd();
-		} else {
-			date = bills.getEta();
-		}
 		//应付
 		int statusC = 0;
 		if (ObjectUtils.isNotNull(bills.getFeeCenterListC())) {

+ 33 - 2
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FeeCenterServiceImpl.java

@@ -113,6 +113,13 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 			deptId = feeCenter.getBranchId();
 			branchId = feeCenter.getBranchId();
 		}
+		//获取部门ids对应中文名
+		if (ObjectUtils.isNotNull(branchId)) {
+			R<String> res = sysClient.getDeptName(Long.parseLong(branchId));
+			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+				deptName = res.getData();
+			}
+		}
 		String exrateType = currencyUtils.standardCurrency(branchId);
 		if (ObjectUtils.isNotNull(feeCenter.getBillCorpId())) {
 			BCorps corps = bCorpsService.getById(feeCenter.getBillCorpId());
@@ -133,6 +140,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 				feeCenter.setCreateDept(deptId);
 				feeCenter.setBranchId(branchId);
+				feeCenter.setBranchName(deptName);
 				feeCenter.setCreateDeptName(deptName);
 			}
 		} else {
@@ -395,6 +403,13 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				deptId = bills.getBranchId();
 				branchId = bills.getBranchId();
 			}
+			//获取部门ids对应中文名
+			if (ObjectUtils.isNotNull(branchId)) {
+				R<String> res = sysClient.getDeptName(Long.parseLong(branchId));
+				if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+					deptName = res.getData();
+				}
+			}
 			String exrateType = currencyUtils.standardCurrency(bills.getBranchId());
 			List<BCorps> bCorpsList = bCorpsService.list(new LambdaQueryWrapper<BCorps>()
 				.eq(BCorps::getTenantId, AuthUtil.getTenantId())
@@ -417,6 +432,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 						feeCenter.setCreateDept(deptId);
 						feeCenter.setBranchId(branchId);
+						feeCenter.setBranchName(deptName);
 						feeCenter.setCreateDeptName(deptName);
 					}
 				} else {
@@ -590,7 +606,13 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				deptId = list.get(0).getBranchId();
 				branchId = list.get(0).getBranchId();
 			}
-			Date date = list.get(0).getBillDate();
+			//获取部门ids对应中文名
+			if (ObjectUtils.isNotNull(branchId)) {
+				R<String> res = sysClient.getDeptName(Long.parseLong(branchId));
+				if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+					deptName = res.getData();
+				}
+			}
 			String exrateType = currencyUtils.standardCurrency(branchId);
 			List<Long> idList = list.stream().map(FeeCenter::getId).filter(Objects::nonNull).collect(Collectors.toList());
 			List<FeeCenter> feeCenters = new ArrayList<>();
@@ -606,6 +628,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 						feeCenter.setCreateDept(deptId);
 						feeCenter.setBranchId(branchId);
+						feeCenter.setBranchName(deptName);
 						feeCenter.setCreateDeptName(deptName);
 					}
 					int version = StringUtil.isBlank(feeCenter.getVersion()) ? 1 : Integer.parseInt(feeCenter.getVersion());
@@ -774,6 +797,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 			if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 				feeCenter.setCreateDept(deptId);
 				feeCenter.setBranchId(branchId);
+				feeCenter.setBranchName(deptName);
 				feeCenter.setCreateDeptName(deptName);
 			}
 		} else {
@@ -815,6 +839,12 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				deptId = list.get(0).getBranchId();
 				branchId = list.get(0).getBranchId();
 			}
+			if (ObjectUtils.isNotNull(branchId)) {
+				R<String> res = sysClient.getDeptName(Long.parseLong(branchId));
+				if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
+					deptName = res.getData();
+				}
+			}
 			String exrateType = currencyUtils.standardCurrency(branchId);
 			List<Long> idList = list.stream().map(FeeCenter::getId).filter(Objects::nonNull).collect(Collectors.toList());
 			List<FeeCenter> feeCenterList1 = new ArrayList<>();
@@ -826,7 +856,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 				if (feeCenter.getId() != null && !feeCenterList1.isEmpty()) {
 					FeeCenter feeCenter1 = feeCenterList1.stream().filter(e -> e.getId().equals(feeCenter.getId()))
 						.findFirst().orElse(null);
-					if (feeCenter1 != null && !feeCenter.getVersion().equals(feeCenter1.getVersion())) {
+					if (feeCenter1 != null && ObjectUtils.isNotNull(feeCenter.getVersion()) && !feeCenter.getVersion().equals(feeCenter1.getVersion())) {
 						throw new RuntimeException("数据已被其他用户更新,请等待刷新后重试");
 					}
 				}
@@ -878,6 +908,7 @@ public class FeeCenterServiceImpl extends ServiceImpl<FeeCenterMapper, FeeCenter
 					if (ObjectUtils.isNotNull(AuthUtil.getDeptId())) {
 						feeCenter.setCreateDept(deptId);
 						feeCenter.setBranchId(branchId);
+						feeCenter.setBranchName(deptName);
 						feeCenter.setCreateDeptName(deptName);
 					}
 				} else {

+ 10 - 16
blade-service/blade-los/src/main/java/org/springblade/los/finance/fee/service/impl/FinAccBillsServiceImpl.java

@@ -148,9 +148,7 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 			throw new RuntimeException("未找到可用业务类型");
 		}
 		List<FeeCenter> reducelList = finAccBills.getFeeCenterList().stream().filter(distinctByKey(FeeCenter::getBillKey)).collect(Collectors.toList());
-		String deptId = AuthUtil.getDeptId();
-		String deptName = "";
-		String branchId = AuthUtil.getDeptId();
+		String branchId = "";
 		if (ObjectUtils.isNotNull(ids) && !ids.isEmpty()) {
 			billsList = billsMapper.selectList(new LambdaQueryWrapper<Bills>()
 				.eq(Bills::getTenantId, AuthUtil.getTenantId())
@@ -160,16 +158,12 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 				for (Bills item : billsList) {
 					item.setBillingStatus(item.getBillingStatus() + reducelList.size());
 					billsMapper.updateById(item);
+					branchId = item.getBranchId();
 				}
-				deptId = billsList.get(0).getBranchId();
 			}
 		}
-		//获取部门ids对应中文名
-		if (ObjectUtils.isNotNull(deptId)) {
-			R<List<String>> res = sysClient.getDeptNames(deptId);
-			if (res.isSuccess() && ObjectUtils.isNotNull(res.getData())) {
-				deptName = String.join(",", res.getData());
-			}
+		if (ObjectUtils.isNull(branchId)) {
+			branchId = AuthUtil.getDeptId();
 		}
 		String exrateType = currencyUtils.standardCurrency(branchId);
 		for (FeeCenter item : reducelList) {
@@ -185,12 +179,12 @@ public class FinAccBillsServiceImpl extends ServiceImpl<FinAccBillsMapper, FinAc
 			data.setCreateTime(new Date());
 			data.setCreateUser(AuthUtil.getUserId());
 			data.setCreateUserName(AuthUtil.getUserName());
-			data.setCreateDept(deptId);
-			data.setCreateDeptName(deptName);
-			data.setBranchId(branchId);
-			data.setBranchName(deptName);
-			data.setDeptId(Long.parseLong(branchId));
-			data.setDeptName(deptName);
+			data.setCreateDept(item.getCreateDept());
+			data.setCreateDeptName(item.getCreateDeptName());
+			data.setBranchId(item.getBranchId());
+			data.setBranchName(item.getBranchName());
+			data.setDeptId(Long.parseLong(item.getCreateDept()));
+			data.setDeptName(item.getCreateDeptName());
 			BusinessBillNo businessBillNo = new BusinessBillNo();
 			businessBillNo.setBusinessTypeId(businessType.getId());
 			businessBillNo.setCode(finAccBills.getBillNoFormat());

+ 7 - 4
blade-service/blade-los/src/main/java/org/springblade/los/finance/invoices/service/impl/FinInvoicesServiceImpl.java

@@ -427,7 +427,7 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 				invoiceAmount = invoiceAmount.add(item.getAmount());
 			}
 		}
-		if (new BigDecimal("0.00").compareTo(finInvoices.getAmountLoc()) == 0) {
+		if (new BigDecimal("0.00").compareTo(finInvoices.getAmountLoc()) >= 0) {
 			throw new RuntimeException("开票失败:开票金额不能小于等于0");
 		}
 		if (invoiceAmount.compareTo(finInvoices.getAmountLoc()) > 0) {
@@ -865,9 +865,12 @@ public class FinInvoicesServiceImpl extends ServiceImpl<FinInvoicesMapper, FinIn
 				invoiceAmount = invoiceAmount.add(item.getAmount());
 			}
 		}
-		/*if (invoiceAmount.compareTo(finInvoices.getAmountLoc()) > 0) {
-			throw new RuntimeException("开票金额为负数,保存失败");
-		}*/
+		if (new BigDecimal("0.00").compareTo(finInvoices.getAmountLoc()) >= 0) {
+			throw new RuntimeException("开票失败:开票金额不能小于等于0");
+		}
+		if (invoiceAmount.compareTo(finInvoices.getAmountLoc()) > 0) {
+			throw new RuntimeException("开票失败:开票金额大于合计金额,保存失败");
+		}
 		detail.setStatus(3);
 		baseMapper.updateById(detail);
 		return R.data(detail);