From 710c6a4d568237016a70b74aa3769b89e336725c Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期二, 13 五月 2025 15:48:21 +0800
Subject: [PATCH] 1、实现功能码92、93命令web后端接口定义与逻辑代码实现; 2、修改原来功能逻辑实现的逻辑,增加回调; 3、表阀一体机协议命令结果数据库存储补充实现。
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java | 184 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 173 insertions(+), 11 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
index 8b4d90a..e2ef915 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/project/ProjectSv.java
@@ -2,16 +2,24 @@
import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoIr.IrProjectGroupMapper;
import com.dy.pipIrrGlobal.daoIr.IrProjectMapper;
import com.dy.pipIrrGlobal.pojoIr.IrProject;
+import com.dy.pipIrrGlobal.pojoIr.IrProjectGroup;
import com.dy.pipIrrGlobal.voIr.VoProject;
-import com.dy.pipIrrGlobal.voPr.VoIntake;
+import com.dy.pipIrrGlobal.voIr.VoProjectDetail;
+import com.dy.pipIrrGlobal.voIr.VoProjectOne;
+import com.dy.pipIrrGlobal.voIr.VoProjectSimple;
+import com.dy.pipIrrIrrigate.project.dto.IrrigateProject;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -27,14 +35,16 @@
@Autowired
private IrProjectMapper irProjectMapper;
+ @Autowired
+ private IrProjectGroupMapper irProjectGroupMapper;
+
/**
- * 娣诲姞椤圭洰
- *
+ * 娣诲姞椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
* @param po
* @return
*/
public Integer addProject(IrProject po) {
- po.setOperateDt(new Date());
+ po.setOperateTime(new Date());
po.setDeleted((byte) 0);
if (po.getVillageId() != null) {
po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
@@ -62,8 +72,121 @@
}
/**
- * 鍒犻櫎椤圭洰
- *
+ * 娣诲姞椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param po
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map addIrrigateProject(IrrigateProject po) {
+ String projectName = po.getProjectName();
+ String irrigateGroups = po.getIrrigateGroups();
+ Long operatorId = po.getOperator();
+
+ IrProject irProject = new IrProject();
+ irProject.setProjectName(projectName);
+ irProject.setProjectState((byte)1);
+ irProject.setOperator(operatorId);
+ irProject.setOperateTime(new Date());
+ irProject.setDeleted((byte)0);
+ irProjectMapper.insert(irProject);
+ Long projectId = irProject.getId();
+ if(projectId == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鍒涘缓鐏屾簤椤圭洰澶辫触");
+ map.put("content", null);
+ return map;
+ }
+
+ String[] irrigateGroupArr = irrigateGroups.split(",");
+ Integer sort = 1;
+ for(String irrigateGroupId : irrigateGroupArr) {
+ String trimmed = irrigateGroupId.trim();
+ if(trimmed.isEmpty()) {
+ continue;
+ }
+ try {
+ Long irrigateGroupIdLong = Long.parseLong(trimmed);
+ IrProjectGroup irProjectGroup = new IrProjectGroup();
+ irProjectGroup.setProjectId(projectId);
+ irProjectGroup.setGroupId(irrigateGroupIdLong);
+ irProjectGroup.setSort(sort++);
+ irProjectGroupMapper.insert(irProjectGroup);
+ } catch (NumberFormatException e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鐏屾簤缁処D鏍煎紡閿欒");
+ map.put("content", null);
+ return map;
+ }
+ }
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "娣诲姞鐏屾簤椤圭洰鎴愬姛");
+ map.put("content", null);
+ return map;
+ }
+
+ /**
+ * 鍒犻櫎鐏屾簤椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param projectId
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map deleteIrrigateProject(Long projectId) {
+ try {
+ irProjectGroupMapper.unbindGroup(projectId);
+ irProjectMapper.deleteByPrimaryKey(projectId);
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鐏屾簤椤圭洰鍒犻櫎鎴愬姛");
+ map.put("content", null);
+ return map;
+ } catch (Exception e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鐏屾簤椤圭洰鍒犻櫎澶辫触");
+ map.put("content", null);
+ return map;
+ }
+ }
+
+ /**
+ * 淇敼鐏屾簤椤圭洰锛岀洰鍓嶄娇鐢�
+ * @param po
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public Map updateIrrigateProject(IrrigateProject po) {
+ Long projectId = po.getProjectId();
+ Map map_deleteProject = ((ProjectSv) AopContext.currentProxy()).deleteIrrigateProject(projectId);
+ if(map_deleteProject.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_deleteProject.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map_addProject = ((ProjectSv) AopContext.currentProxy()).addIrrigateProject(po);
+ if(map_addProject.get("success").equals(false)) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", map_addProject.get("msg").toString());
+ map.put("content", null);
+ return map;
+ }
+
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "淇敼鐏屾簤椤圭洰鎴愬姛");
+ map.put("content", null);
+ return map;
+ }
+
+ /**
+ * 鍒犻櫎椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
* @param id
*/
public Integer deleteProject(Long id) {
@@ -80,7 +203,7 @@
* @return
*/
public Integer updateProject(IrProject po){
- po.setOperateDt(new Date());
+ po.setOperateTime(new Date());
if (po.getVillageId() != null) {
po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId()));
po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId()));
@@ -112,7 +235,7 @@
* @return
*/
public Integer updateProjectState(IrProject po){
- po.setOperateDt(new Date());
+ po.setOperateTime(new Date());
int rows = irProjectMapper.updateProjectState(po);
if (rows == 0){
return 0;
@@ -125,13 +248,13 @@
* @param id
* @return
*/
- public IrProject selectById(Long id){
- IrProject irProject = irProjectMapper.selectById(id);
+ public VoProjectOne selectById(Long id){
+ VoProjectOne irProject = irProjectMapper.selectById(id);
return irProject;
}
/**
- * 鍒嗛〉鏌ヨ椤圭洰
+ * 鍒嗛〉鏌ヨ椤圭洰锛屾棫鐗堟湰锛屽師鍒欎笂搴熷純
* @param queryVo
* @return
*/
@@ -146,4 +269,43 @@
rsVo.obj = irProjectMapper.getProjects(params);
return rsVo;
}
+
+ /**
+ * 鍒嗛〉鏌ヨ椤圭洰锛屾柊鐗堟湰锛岀洰鍓嶄娇鐢�
+ * @param queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoProjectSimple>> getSimpleProjects(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irProjectMapper.getSimpleProjectsCount(params);
+
+ QueryResultVo<List<VoProjectSimple>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irProjectMapper.getSimpleProjects(params);
+ return rsVo;
+ }
+
+ /**
+ * 鏍规嵁椤圭洰Id鑾峰彇椤圭洰璇︽儏锛岀紪杈戦」鐩俊鎭娇鐢�
+ * @param projectId
+ * @return
+ */
+ public Map getProjectDetail(Long projectId) {
+ try {
+ VoProjectDetail voProjectDetail = irProjectMapper.getProjectDetail(projectId);
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鑾峰彇椤圭洰璇︽儏鎴愬姛");
+ map.put("content", voProjectDetail);
+ return map;
+ } catch (Exception e) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鑾峰彇椤圭洰璇︽儏澶辫触");
+ map.put("content", null);
+ return map;
+ }
+ }
}
--
Gitblit v1.8.0