From c5ea85558fea4d82b5368073c598a30f905c4bdc Mon Sep 17 00:00:00 2001
From: shiyunteng <shiyunteng@example.com>
Date: 星期五, 23 十月 2026 17:11:49 +0800
Subject: [PATCH] feat:新增统计标注功能

---
 platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/dto/ContractSubjectMatterAnnotateDTO.java          |   22 +++++
 platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/Contract.java                               |    4 +
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java       |   85 ++++++++++++--------
 platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml                                                     |    1 
 platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPageVo.java                             |    2 
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractSubjectMatterService.java          |    3 
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java      |    5 +
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractInvoiceController.java          |   10 ++
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractSubjectMatterServiceImpl.java |   28 +++++++
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractSubjectMatterController.java    |   14 +++
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java              |   16 +++
 platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractSubjectMatter.java                  |   11 ++
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java              |   18 ++++
 platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractInvoiceService.java                |    2 
 14 files changed, 182 insertions(+), 39 deletions(-)

diff --git a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/dto/ContractSubjectMatterAnnotateDTO.java b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/dto/ContractSubjectMatterAnnotateDTO.java
new file mode 100644
index 0000000..49f3127
--- /dev/null
+++ b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/dto/ContractSubjectMatterAnnotateDTO.java
@@ -0,0 +1,22 @@
+package com.by4cloud.platformx.business.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class ContractSubjectMatterAnnotateDTO {
+
+	private Long id;
+
+	private Long contractId;
+
+	@Schema(description = "浜у搧鏉垮潡")
+	private String productSection;
+
+	@Schema(description = "涓氬姟椤圭洰")
+	private String businessProject;
+
+	@Schema(description = "浜у搧鍚嶇О")
+	private String productCategory;
+
+}
diff --git a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/Contract.java b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/Contract.java
index f16f5f6..37c1104 100644
--- a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/Contract.java
+++ b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/Contract.java
@@ -454,4 +454,8 @@
 	@Schema(description = "鍚堝悓鏉℃鍙婁富瑕佸唴瀹�")
 	@Column(columnDefinition = "text comment '鍚堝悓鏉℃鍙婁富瑕佸唴瀹�'")
 	private String summary;
+
+	@Schema(description = "缁熻鏍囪")
+	@Column(columnDefinition = "tinyint(1) default 0 comment '缁熻鏍囪'")
+	private String annotateFlag;
 }
diff --git a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractSubjectMatter.java b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractSubjectMatter.java
index ffd628d..b5802b5 100644
--- a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractSubjectMatter.java
+++ b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/entity/ContractSubjectMatter.java
@@ -186,4 +186,15 @@
 	@Column(columnDefinition = "VARCHAR(64) comment '鏁版嵁id宸ヤ笟娉电敤'")
 	private String dataId;
 
+	@Schema(description = "浜у搧鏉垮潡")
+	@Column(columnDefinition = "VARCHAR(64) comment '浜у搧鏉垮潡'")
+	private String productSection;
+
+	@Schema(description = "涓氬姟椤圭洰")
+	@Column(columnDefinition = "VARCHAR(64) comment '涓氬姟椤圭洰'")
+	private String businessProject;
+
+	@Schema(description = "浜у搧鍚嶇О")
+	@Column(columnDefinition = "VARCHAR(64) comment '浜у搧鍚嶇О'")
+	private String productCategory;
 }
\ No newline at end of file
diff --git a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPageVo.java b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPageVo.java
index 88b7633..fb8c9e7 100644
--- a/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPageVo.java
+++ b/platformx-business-finance-api/src/main/java/com/by4cloud/platformx/business/vo/ContractPageVo.java
@@ -201,6 +201,8 @@
 
 	private String afterChange;
 
+	private String annotateFlag;
+
 	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
 	@Schema(description = "鍙樻洿鏃堕棿")
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractInvoiceController.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractInvoiceController.java
index 2190a3d..794db86 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractInvoiceController.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractInvoiceController.java
@@ -257,6 +257,16 @@
 	}
 
 	/**
+	 * 閫氳繃key鏌ヨzb瀛楀吀
+	 * @return R
+	 */
+	@Operation(summary = "閫氳繃key鏌ヨzb瀛楀吀" , description = "閫氳繃key鏌ヨzb瀛楀吀" )
+	@GetMapping("/selectZbByKey/{dictKey}" )
+	public R selectZbByKey(@PathVariable("dictKey" ) String dictKey) {
+		return contractInvoiceService.selectZbByKey(dictKey);
+	}
+
+	/**
 	 * 鎵嬪姩閫氳繃鍙戠エ
 	 * @return
 	 */
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractSubjectMatterController.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractSubjectMatterController.java
index d3a7c29..3ffa3ea 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractSubjectMatterController.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/controller/ContractSubjectMatterController.java
@@ -5,6 +5,7 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.by4cloud.platformx.business.dto.ContractSubjectMatterAnnotateDTO;
 import com.by4cloud.platformx.business.entity.ContractSubjectMatter;
 import com.by4cloud.platformx.business.vo.ProductExcelVO;
 import com.by4cloud.platformx.business.vo.SubjectMatterExcelVO;
@@ -158,4 +159,17 @@
 	public R smjProduct(@PathVariable("erpCode" ) String erpCode) {
 		return contractSubjectMatterService.smjProduct(erpCode);
 	}
+
+	/**
+	 * 淇敼鍚堝悓鏍囩殑鐗╂槑缁嗚〃
+	 * @param annotateDTOList 鍚堝悓鏍囩殑鐗╂槑缁嗚〃
+	 * @return R
+	 */
+	@Operation(summary = "鍚堝悓鏍囩殑鐗╃粺璁℃爣娉�" , description = "鍚堝悓鏍囩殑鐗╃粺璁℃爣娉�" )
+	@SysLog("鍚堝悓鏍囩殑鐗╃粺璁℃爣娉�" )
+	@PostMapping("/annotate")
+	public R annotate(@RequestBody List<ContractSubjectMatterAnnotateDTO> annotateDTOList) {
+		return contractSubjectMatterService.annotate(annotateDTOList);
+	}
+
 }
\ No newline at end of file
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractInvoiceService.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractInvoiceService.java
index 75a750b..093380c 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractInvoiceService.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractInvoiceService.java
@@ -53,4 +53,6 @@
 	R genMergeInvoiceInfo(GenMergeInvoiceDTO mergeInvoiceDTO);
 
 	R toMergeInvoice(ToMergeInvoiceDTO toMergeInvoiceDTO);
+
+	R selectZbByKey(String dictKey);
 }
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractSubjectMatterService.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractSubjectMatterService.java
index 358d133..6868db2 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractSubjectMatterService.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/ContractSubjectMatterService.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.by4cloud.platformx.business.dto.ContractSubjectMatterAnnotateDTO;
 import com.by4cloud.platformx.business.entity.ContractSubjectMatter;
 import com.by4cloud.platformx.business.vo.SubjectMatterExcelVO;
 import com.by4cloud.platformx.common.core.util.R;
@@ -20,4 +21,6 @@
 	R smjProduct(String erpCode);
 
 	JSONObject syncProductBySMJ(String tenant1, String materialCode);
+
+    R annotate(List<ContractSubjectMatterAnnotateDTO> annotateDTOList);
 }
\ No newline at end of file
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
index 19e3f92..d901caa 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/BusinessCustomerServiceImpl.java
@@ -16,6 +16,7 @@
 import com.by4cloud.platformx.business.vo.*;
 import com.by4cloud.platformx.common.core.util.R;
 import com.by4cloud.platformx.common.excel.vo.ErrorMessage;
+import com.by4cloud.platformx.common.security.util.SecurityUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -124,7 +125,9 @@
 			return R.failed("瀹㈠晢鍚嶇О鎴栫ぞ浼氫俊鐢ㄤ唬鐮佷笉鑳戒负绌�");
 		}
 		BusinessCustomer bc = baseMapper.selectOne(Wrappers.<BusinessCustomer>lambdaQuery().eq(BusinessCustomer::getCompanyName,addDTO.getCompanyName())
-				.eq(BusinessCustomer::getCreditCode,addDTO.getCreditCode()).last("limit 1"));
+				.eq(BusinessCustomer::getCreditCode,addDTO.getCreditCode())
+				.eq(BusinessCustomer::getCompId, SecurityUtils.getUser().getCompId())
+				.last("limit 1"));
 		if (ObjUtil.isNotNull(bc)){
 			return R.failed("瀹㈠晢宸插瓨鍦�");
 		}
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
index eb81cc1..306072c 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractInvoiceServiceImpl.java
@@ -234,12 +234,8 @@
 				}
 				List<String> smjList = new ArrayList<>();
 				smjList.add(smj);
-				smjList.add(smjsc);
-				smjList.add(smjzt);
 				smjList.add(smjhw);
-				if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-						("" + SecurityUtils.getUser().getCompId()).equals(smjzt) ||
-						("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+				if (("" + SecurityUtils.getUser().getCompId()).equals(smj)||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 					Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode())
 							.in(Product::getCompId, smjList).last("limit 1"));
 					if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) {
@@ -288,12 +284,8 @@
 			ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
 			List<String> smjList = new ArrayList<>();
 			smjList.add(smj);
-			smjList.add(smjsc);
-			smjList.add(smjzt);
 			smjList.add(smjhw);
-			if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-					("" + SecurityUtils.getUser().getCompId()).equals(smjzt)||
-					("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+			if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 				Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
 						.in(Product::getCompId, smjList).last("limit 1"));
 				if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) {
@@ -351,12 +343,8 @@
 			ContractOutBound contractOutBound = contractOutBoundMapper.selectById(contractOutBoundInvoiceVo.getContractOutBoundId());
 			List<String> smjList = new ArrayList<>();
 			smjList.add(smj);
-			smjList.add(smjsc);
-			smjList.add(smjzt);
 			smjList.add(smjhw);
-			if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-					("" + SecurityUtils.getUser().getCompId()).equals(smjzt) ||
-					("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+			if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 				Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
 						.in(Product::getCompId, smjList).last("limit 1"));
 				if (ObjUtil.isNull(product) || StrUtil.isBlank(product.getTaxClass()) || StrUtil.isBlank(product.getTaxCode())) {
@@ -414,12 +402,8 @@
 					Product product = new Product();
 					List<String> smjList = new ArrayList<>();
 					smjList.add(smj);
-					smjList.add(smjsc);
-					smjList.add(smjzt);
 					smjList.add(smjhw);
-					if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-							("" + SecurityUtils.getUser().getCompId()).equals(smjzt) ||
-							("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+					if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 						product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
 								.in(Product::getCompId, smjList).last("limit 1"));
 					} else {
@@ -619,12 +603,8 @@
 				Product product = new Product();
 				List<String> smjList = new ArrayList<>();
 				smjList.add(smj);
-				smjList.add(smjsc);
-				smjList.add(smjzt);
 				smjList.add(smjhw);
-				if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-						("" + SecurityUtils.getUser().getCompId()).equals(smjzt)||
-						("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+				if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 					product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
 							.in(Product::getCompId, smjList).last("limit 1"));
 				} else {
@@ -690,12 +670,8 @@
 						Product product = new Product();
 						List<String> smjList = new ArrayList<>();
 						smjList.add(smj);
-						smjList.add(smjsc);
-						smjList.add(smjzt);
 						smjList.add(smjhw);
-						if (("" + SecurityUtils.getUser().getCompId()).equals(smj) || ("" + SecurityUtils.getUser().getCompId()).equals(smjsc) ||
-								("" + SecurityUtils.getUser().getCompId()).equals(smjzt)||
-								("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+						if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
 							product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractOutBound.getSubjectMatterCode())
 									.in(Product::getCompId, smjList).last("limit 1"));
 						} else {
@@ -761,14 +737,24 @@
 						mergeVo.setMaterialInternalName(schedule.getSubjectMatterName());
 						mergeVo.setPriceAndTax(schedule.getPlannedAmount());
 						mergeVo.setQuantity(schedule.getInvoiceNum());
-						Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode())
-								.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+						List<String> smjList = new ArrayList<>();
+						smjList.add(smj);
+						smjList.add(smjhw);
+						Product product = null;
+						if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+							product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode())
+									.in(Product::getCompId, smjList).last("limit 1"));
+						} else {
+							product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, schedule.getSubjectMatterCode())
+									.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+						}
 						if (ObjUtil.isNotNull(product)) {
 							mergeVo.setTaxClass(product.getTaxClass());
 							mergeVo.setSpecification(product.getProductType());
 							mergeVo.setTaxRate(new BigDecimal(product.getTaxRate()));
 							mergeVo.setTaxCode(product.getTaxCode());
 						}
+
 						ContractSubjectMatter subjectMatter = subjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
 								.eq(ContractSubjectMatter::getMaterialCode, schedule.getSubjectMatterCode())
 								.eq(ContractSubjectMatter::getContractId, contract.getId()).last("limit 1"));
@@ -846,8 +832,17 @@
 						mergeVo.setMaterialCode(subjectMatter.getMaterialCode());
 						mergeVo.setMaterialInternalName(subjectMatter.getMaterialName());
 						mergeVo.setQuantity(contractOutBoundInvoiceVo.getInvoiceNum());
-						Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode())
-								.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+						List<String> smjList = new ArrayList<>();
+						smjList.add(smj);
+						smjList.add(smjhw);
+						Product product = null;
+						if (("" + SecurityUtils.getUser().getCompId()).equals(smj) ||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+							product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode())
+									.in(Product::getCompId, smjList).last("limit 1"));
+						} else {
+							product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, subjectMatter.getMaterialCode())
+									.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+						}
 						if (ObjUtil.isNotNull(product)) {
 							mergeVo.setTaxClass(product.getTaxClass());
 							mergeVo.setSpecification(product.getProductType());
@@ -2380,6 +2375,28 @@
 	}
 
 	@Override
+	public R selectZbByKey(String dictKey) {
+		List<BipDict> bipDictList = bipDictMapper.selectList(Wrappers.<BipDict>lambdaQuery().eq(BipDict::getDictKey, dictKey)
+				.eq(BipDict::getCompId,SecurityUtils.getUser().getCompId()));
+		if (CollUtil.isNotEmpty(bipDictList)) {
+			// 鏉冮檺鍐呴儴闂�
+			List<TreeNode<Long>> collect = bipDictList.stream()
+					.map(dict -> {
+						TreeNode<Long> treeNode = new TreeNode<>();
+						treeNode.setId(dict.getId());
+						treeNode.setParentId(dict.getParentId());
+						treeNode.setName(dict.getDictName());
+						treeNode.setWeight(dict.getDictCode());
+						return treeNode;
+					})
+					.collect(Collectors.toList());
+
+			return R.ok(TreeUtil.build(collect, 0L));
+		}
+		return R.failed("瀛楀吀鑾峰彇澶辫触");
+	}
+
+	@Override
 	public R saveAndPush(ContractInvoiceUpateDTO upateDTO) {
 		ContractInvoice invoice = baseMapper.selectById(upateDTO.getId());
 		invoice.setInvoicePreview(upateDTO.getInvoicePreview());
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
index 4019a40..bb9ee24 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractServiceImpl.java
@@ -794,7 +794,8 @@
 					baseMapper.updateById(contract);
 
 				}
-				if ((StrUtil.equals(contract.getPartyBId() + "", smj) ||
+				if ((StrUtil.equals(contract.getPartyBId() + "", smj) ||StrUtil.equals(contract.getPartyBId() + "", smjsc) ||
+						StrUtil.equals(contract.getPartyBId() + "", smjzt) ||
 						StrUtil.equals(contract.getPartyBId() + "", smjhw)) && StrUtil.isNotEmpty(smjErp)) {
 					request.put("customerCode", customer.getErpCompanyCode());
 					request.put("currencyId", "RMB");
@@ -812,8 +813,17 @@
 							subjectMatterItem.put("salePrice", contractSubjectMatter.getUnitPrice());
 							subjectMatterItem.put("qtyRequired", contractSubjectMatter.getQuantity());
 							subjectMatterItem.put("money", contractSubjectMatter.getQuantity().multiply(contractSubjectMatter.getUnitPrice()));
-							Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getCompId, contract.getCompId())
-									.eq(Product::getErpCode, contractSubjectMatter.getMaterialCode()));
+							Product product = null;
+							List<String> smjList = new ArrayList<>();
+							smjList.add(smj);
+							smjList.add(smjhw);
+							if (("" + SecurityUtils.getUser().getCompId()).equals(smj)||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+								 product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractSubjectMatter.getMaterialCode())
+										.in(Product::getCompId, smjList).last("limit 1"));
+							} else {
+								 product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, contractSubjectMatter.getMaterialCode())
+										.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+							}
 							if (ObjUtil.isNotNull(product)) {
 								subjectMatterItem.put("taxRate", new BigDecimal(product.getTaxRate()).divide(new BigDecimal("100")));
 							}
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractSubjectMatterServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractSubjectMatterServiceImpl.java
index 022e1ae..fe0192c 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractSubjectMatterServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/ContractSubjectMatterServiceImpl.java
@@ -13,9 +13,12 @@
 import com.by4cloud.platformx.admin.api.entity.SysDept;
 import com.by4cloud.platformx.admin.api.vo.DeptExcelVO;
 import com.by4cloud.platformx.business.dto.ContractSubjectMatterAddDTO;
+import com.by4cloud.platformx.business.dto.ContractSubjectMatterAnnotateDTO;
+import com.by4cloud.platformx.business.entity.Contract;
 import com.by4cloud.platformx.business.entity.ContractSubjectMatter;
 import com.by4cloud.platformx.business.entity.Product;
 import com.by4cloud.platformx.business.entity.TaxCode;
+import com.by4cloud.platformx.business.mapper.ContractMapper;
 import com.by4cloud.platformx.business.mapper.ContractSubjectMatterMapper;
 import com.by4cloud.platformx.business.mapper.ProductMapper;
 import com.by4cloud.platformx.business.mapper.TaxCodeMapper;
@@ -50,6 +53,8 @@
 @RequiredArgsConstructor
 @Slf4j
 public class ContractSubjectMatterServiceImpl extends ServiceImpl<ContractSubjectMatterMapper, ContractSubjectMatter> implements ContractSubjectMatterService {
+
+	private final ContractMapper contractMapper;
 
 	private final ProductMapper productMapper;
 
@@ -376,4 +381,27 @@
 		log.info("鐭崇叅鏈衡�斺�攖enant1鍚堝悓鏂板浜у搧瀵煎叆鏌ヨ鍥炲弬锛歿}", response.body());
 		return R.ok(response.body());
 	}
+
+	@Override
+	public R annotate(List<ContractSubjectMatterAnnotateDTO> annotateDTOList) {
+		if (CollUtil.isNotEmpty(annotateDTOList)){
+			Long contractId = annotateDTOList.get(0).getContractId();
+			annotateDTOList.stream().forEach(annotateDTO->{
+				ContractSubjectMatter subjectMatter = baseMapper.selectById(annotateDTO.getId());
+				subjectMatter.setProductSection(annotateDTO.getProductSection());
+				subjectMatter.setBusinessProject(annotateDTO.getBusinessProject());
+				subjectMatter.setProductCategory(annotateDTO.getProductCategory());
+				baseMapper.updateById(subjectMatter);
+			});
+			List<ContractSubjectMatter> subjectMatterList = baseMapper.selectList(Wrappers.<ContractSubjectMatter>lambdaQuery()
+					.eq(ContractSubjectMatter::getContractId,contractId)
+					.and(wrapper -> wrapper.isNull(ContractSubjectMatter::getProductSection)
+							.or().isNull(ContractSubjectMatter::getBusinessProject)
+							.or().isNull(ContractSubjectMatter::getProductCategory)));
+			if (CollUtil.isEmpty(subjectMatterList)){
+				contractMapper.update(Wrappers.<Contract>lambdaUpdate().eq(Contract::getId,contractId).set(Contract::getAnnotateFlag,"1"));
+			}
+		}
+		return R.ok();
+	}
 }
\ No newline at end of file
diff --git a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
index 29eaa91..131e904 100644
--- a/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
+++ b/platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
@@ -43,7 +43,7 @@
 	private final ContractSubjectMatterMapper contractSubjectMatterMapper;
 	private final PaymentConfirmMapper paymentConfirmMapper;
 	private final ContractMapper contractMapper;
-	private final ContractPaymentScheduleProcessMapper scheduleProcessMapper;
+	private final ProductMapper productMapper;
 	private final ContractOutBoundMapper contractOutBoundMapper;
 	private final DeliveryOverdueMapper deliveryOverdueMapper;
 	private final StringRedisTemplate redisTemplate;
@@ -616,6 +616,22 @@
 		outBound.setOutBoundTime(ObjUtil.isNotNull(addDTO.getOutBoundTime()) ? addDTO.getOutBoundTime() : new Date());
 		outBound.setSubjectMatterCode(outSubjectMatterAddDTO.getSubjectMatterCode());
 		outBound.setSubjectMatterName(outSubjectMatterAddDTO.getSubjectMatterName());
+		List<String> smjList = new ArrayList<>();
+		smjList.add(smj);
+		smjList.add(smjhw);
+		if (("" + SecurityUtils.getUser().getCompId()).equals(smj)||("" + SecurityUtils.getUser().getCompId()).equals(smjhw)) {
+			Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, outSubjectMatterAddDTO.getSubjectMatterCode())
+					.in(Product::getCompId, smjList).last("limit 1"));
+			if (ObjUtil.isNotNull(product) ) {
+				outBound.setSubjectMatterName(outSubjectMatterAddDTO.getSubjectMatterName());
+			}
+		} else {
+			Product product = productMapper.selectOne(Wrappers.<Product>lambdaQuery().eq(Product::getErpCode, outSubjectMatterAddDTO.getSubjectMatterCode())
+					.eq(Product::getCompId, SecurityUtils.getUser().getCompId()).last("limit 1"));
+			if (ObjUtil.isNotNull(product) ) {
+				outBound.setSubjectMatterName(outSubjectMatterAddDTO.getSubjectMatterName());
+			}
+		}
 		outBound.setOutBoundType("1");
 		if (StrUtil.isEmpty(addDTO.getOutBoundType())) {
 			outBound.setOutBoundType("0");
diff --git a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
index 9c908d7..a8d0ad9 100644
--- a/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
+++ b/platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
@@ -1119,6 +1119,7 @@
 		    c.warranty_schedule_id,
 			c.comp_id,
 			c.center_push_flag,
+			c.annotate_flag,
 			c.last_attachment_url,
 			(select sum(delivered_quantity*unit_price) from contract_subject_matter csm where csm.contract_id = c.id) outAmount
 			FROM

--
Gitblit v1.9.1