From 8bb87e050d73924843552f73563469711c833d03 Mon Sep 17 00:00:00 2001
From: 李旭东 <woaiguo66@sina.com>
Date: 星期三, 08 十一月 2023 08:56:14 +0800
Subject: [PATCH] Merge branch 'master' of http://111.30.93.211:10101/r/supipe

---
 hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java
index 0f80f09..5b466ae 100644
--- a/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java
+++ b/hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/pipeoutplan/service/impl/PipeOutPlanServiceImpl.java
@@ -29,6 +29,8 @@
 	@Autowired
 	private PipeOutPlanMapper pipeOutPlanMapper;
 
+	public static final Object LOCK = new Object();
+
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	public BasicResult insert(PipeOutPlanEntity pipeOutPlanEntity) {
@@ -60,7 +62,7 @@
 	@Transactional(rollbackFor = Exception.class)
 	public BasicResult update(PipeOutPlanEntity pipeOutPlanEntity) {
 		PipeOutPlanEntity isExit = pipeOutPlanMapper.selectInfoByProIdAndYear(pipeOutPlanEntity.getProId(), pipeOutPlanEntity.getPlanYear());
-		if (!pipeOutPlanEntity.getPlanOutId().equals(isExit.getPlanOutId()) && isExit != null){
+		if (isExit != null && !pipeOutPlanEntity.getPlanOutId().equals(isExit.getPlanOutId()) ){
 			return BasicResult.faild("500","同一项目、年份有且只有一个计划",null);
 		}
 		pipeOutPlanMapper.update(pipeOutPlanEntity);
@@ -97,9 +99,11 @@
 			String planOutId = obj.getPlanOutId();
 			List<PipeOutPlanMothEntity> mothListByProIdAndYear = pipeOutPlanMapper.findMothListByProIdAndYear(proId, planYear.toString(), planOutId);
 			Integer completePlanProductNum = 0;
-			for (PipeOutPlanMothEntity pipeOutPlanMothEntity : mothListByProIdAndYear) {
-				Integer completePlanProduct = pipeOutPlanMothEntity.getCompletePlanProduct();
-				completePlanProductNum+=completePlanProduct;
+			synchronized (this.LOCK){
+				for (PipeOutPlanMothEntity pipeOutPlanMothEntity : mothListByProIdAndYear) {
+					Integer completePlanProduct = pipeOutPlanMothEntity.getCompletePlanProduct();
+					completePlanProductNum+=completePlanProduct;
+				}
 			}
 			obj.setMonthList(mothListByProIdAndYear);
 			obj.setCompletePipeNum(completePlanProductNum);

--
Gitblit v1.9.3