From 3be630d678dd60603e557514a203a1f544034a4d Mon Sep 17 00:00:00 2001
From: xieb <vip_xiaobin810@163.com>
Date: Mon, 11 Mar 2024 17:09:34 +0800
Subject: [PATCH] 水库白蚁普查增加年度

---
 skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java
index 2ee9243..b789d17 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sjztmd/service/impl/TbResGeneralInvestigationServiceImpl.java
@@ -8,6 +8,8 @@
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -22,29 +24,39 @@
 @Transactional(rollbackFor = Exception.class)
 public class TbResGeneralInvestigationServiceImpl extends ServiceImpl<TbResGeneralInvestigationMapper, TbResGeneralInvestigation> implements ITbResGeneralInvestigationService {
 
+	@Autowired
 	private ITbResGeneralInvestigationStateService tbResGeneralInvestigationStateService;
 
 	@Override
 	@Transactional
-	public boolean saveOrUpdateBy(TbResGeneralInvestigation entity) {
+	public R saveOrUpdateBy(TbResGeneralInvestigation entity) {
 
 		QueryWrapper queryWrapper = new QueryWrapper();
-		queryWrapper.eq("res_guid",entity.getResGuid());
-		queryWrapper.eq("tb_year",entity.getTbYear());
-		queryWrapper.eq("tb_quarter",entity.getTbYear());
+		queryWrapper.eq("\"res_guid\"",entity.getResGuid());
+		queryWrapper.eq("\"tb_year\"",entity.getTbYear());
+		queryWrapper.eq("\"tb_quarter\"",entity.getTbQuarter());
 		TbResGeneralInvestigationState state = tbResGeneralInvestigationStateService.getOne(queryWrapper);
 		if (null == state) {
 			state = new TbResGeneralInvestigationState();
 			state.setResGuid(entity.getResGuid());
 			state.setTbQuarter(entity.getTbQuarter());
 			state.setTbYear(entity.getTbYear());
+			state.setCreateTime(entity.getCreateTime());
+			state.setCreateUser(entity.getCreateUser());
+		} else {
+			if (state.getCheckState() == 1 || state.getCheckState() == 2) {
+				return R.fail(entity.getResName() + "本年度已经普查完成,不能在提交了。");
+			}
 		}
 
 		// 是否普查完成 1是 0否
-		state.setCheckState(entity.getIsInvCom());
+		if (entity.getCheckState() != 0) {
+			state.setCheckState(entity.getIsInvCom());
+		}
 
 		tbResGeneralInvestigationStateService.saveOrUpdate(state);
 
-		return this.saveOrUpdate(entity);
+		entity.setTbStateId(state.getGuid());
+		return R.status(this.saveOrUpdate(entity));
 	}
 }

--
Gitblit v1.9.3