From 52cd0fe6f2224b0bd17b19ddaf475406a92b9ed4 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期五, 09 五月 2025 13:42:00 +0800
Subject: [PATCH] Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java | 389 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 389 insertions(+), 0 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
new file mode 100644
index 0000000..da54d34
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigateGroup/IrrigateGroupSv.java
@@ -0,0 +1,389 @@
+package com.dy.pipIrrIrrigate.irrigateGroup;
+
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.daoIr.IrGroupClientMapper;
+import com.dy.pipIrrGlobal.daoIr.IrGroupIntakeMapper;
+import com.dy.pipIrrGlobal.daoIr.IrGroupUnitMapper;
+import com.dy.pipIrrGlobal.daoIr.IrIrrigateGroupMapper;
+import com.dy.pipIrrGlobal.pojoIr.IrGroupClient;
+import com.dy.pipIrrGlobal.pojoIr.IrGroupIntake;
+import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit;
+import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
+import com.dy.pipIrrGlobal.voIr.VoGroup;
+import com.dy.pipIrrGlobal.voIr.VoGroupDetail;
+import com.dy.pipIrrGlobal.voIr.VoGroupOne;
+import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
+import com.dy.pipIrrIrrigate.irrigateGroup.dto.IrrigateGroup;
+import com.dy.pipIrrIrrigate.irrigateGroup.qo.QoGroup;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author :WuZeYu
+ * @Date :2024/5/21 15:57
+ * @LastEditTime :2024/5/21 15:57
+ * @Description
+ */
+@Slf4j
+@Service
+public class IrrigateGroupSv {
+ @Autowired
+ private IrIrrigateGroupMapper irIrrigateGroupMapper;
+
+ @Autowired
+ private IrGroupUnitMapper irGroupUnitMapper;
+
+ @Autowired
+ private IrGroupClientMapper irGroupClientMapper;
+
+ @Autowired
+ private IrGroupIntakeMapper irGroupIntakeMapper;
+
+ /**
+ * 鍒涘缓杞亴缁�
+ *
+ * @param po
+ * @return
+ */
+ public Integer addIrrigateGroup(IrIrrigateGroup po) {
+ po.setOperateTime(new Date());
+ po.setDeleted((byte) 0);
+ int rows = irIrrigateGroupMapper.insertSelective(po);
+ if (rows == 0) {
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 鍒犻櫎杞亴缁�
+ *
+ * @param id
+ */
+ public Integer deleteIrrigateGroup(Long id) {
+ int rows = irIrrigateGroupMapper.deleteLogicById(id);
+ int rows1 = irGroupUnitMapper.deleteByGroupId(id);
+ if (rows == 0) {
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 淇敼杞亴缁�
+ * @param po
+ * @return
+ */
+ public Integer updateIrrigateGroup(IrIrrigateGroup po){
+ po.setOperateTime(new Date());
+ int rows = irIrrigateGroupMapper.updateByPrimaryKeySelective(po);
+ if (rows == 0){
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 鑾峰彇涓�涓疆鐏岀粍
+ * @param id
+ * @return
+ */
+ public VoGroupOne selectById(Long id){
+ VoGroupOne unit = irIrrigateGroupMapper.selectById(id);
+ return unit;
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ杞亴缁�
+ * @param queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoGroup>> getIrrigateGroups(QueryVo queryVo){
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irIrrigateGroupMapper.getRecordCount(params);
+
+ QueryResultVo<List<VoGroup>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irIrrigateGroupMapper.getIrrigateGroups(params);
+ return rsVo;
+ }
+
+ /**
+ * 杞亴缁勬坊鍔犵亴婧夊崟鍏�
+ *
+ * @param po
+ * @return
+ */
+ public Integer addGroupUnit(IrGroupUnit po) {
+ po.setOperateDt(new Date());
+ int rows = irGroupUnitMapper.insertSelective(po);
+ if (rows == 0) {
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 杞亴缁勭Щ闄ょ亴婧夊崟鍏�
+ *
+ * @param po
+ * @return
+ */
+ public Integer deleteGroupUnit(IrGroupUnit po) {
+ int rows = irGroupUnitMapper.deleteByUnitIdGroupId(po);
+ if (rows == 0) {
+ return 0;
+ }
+ return 1;
+ }
+
+ /**
+ * 鏌ヤ竴涓疆鐏岀粍缁戝畾鐨勭亴婧夊崟鍏僫d
+ * @param groupId
+ * @return
+ */
+ public List<Long> getGroupBindUnits(Long groupId) {
+ List<Long> groupBindUnits = irGroupUnitMapper.getGroupBindUnits(groupId);
+ return groupBindUnits;
+ }
+
+ /**
+ * //鏌ユ湭缁戝畾杞亴缁勭殑鐏屾簤鍗曞厓id
+ * @return
+ */
+ public List<Long> getNotBindUnits() {
+ List<Long> notBindUnits = irGroupUnitMapper.getNotBindUnits();
+ return notBindUnits;
+ }
+
+ //杞亴缁勫叧鑱斿啘鎴�
+ public Long addGroupClient(IrGroupClient po) {
+ irGroupClientMapper.insert(po);
+ return po.getId();
+ }
+
+ /**
+ * 鏍规嵁杞亴缁勫悕绉版煡璇㈡槸鍚﹀瓨鍦紙娣诲姞杞亴缁勬椂浣跨敤锛�
+ * @param groupCode 杞亴缁勫悕绉�
+ * @return 鏄惁瀛樺湪
+ */
+ public boolean existsByGroupCode(String groupCode) {
+ if (groupCode == null || "".equals(groupCode.trim())) {
+ return false;
+ }
+ return irIrrigateGroupMapper.countByGroupCode(groupCode) > 0;
+ }
+
+ /**
+ * 鏍规嵁杞亴缁勫悕绉版煡璇㈡槸鍚﹀瓨鍦紙淇敼杞亴缁勬椂浣跨敤锛屾帓闄ゅ綋鍓岻D锛�
+ * @param groupCode 杞亴缁勫悕绉�
+ * @param excludeId 闇�瑕佹帓闄ょ殑ID
+ * @return 鏄惁瀛樺湪
+ */
+ public boolean existsByGroupCodeExcludeId(String groupCode, Long excludeId) {
+ if (groupCode == null || "".equals(groupCode.trim())) {
+ return false;
+ }
+ return irIrrigateGroupMapper.countByGroupCodeExcludeId(groupCode, excludeId) > 0;
+ }
+
+ /**
+ * 鍒犻櫎杞亴缁勪笌鍐滄埛绠$悊
+ * @param id
+ * @return
+ */
+ public Integer deleteGroupClient (Long id) {
+ return irGroupClientMapper.deleteByPrimaryKey(id);
+ }
+
+ /**
+ * 鍒涘缓杞亴缁�
+ * @param po
+ * @return
+ */
+ public Map addIrrigateGroup(IrrigateGroup po) {
+ IrIrrigateGroup irrigateGroup = new IrIrrigateGroup();
+ irrigateGroup.setGroupCode(po.getGroupCode());
+ irrigateGroup.setDefaultDuration(po.getDefaultDuration());
+ irrigateGroup.setOperator(po.getOperator());
+ irrigateGroup.setOperateTime(new Date());
+ irrigateGroup.setDeleted((byte) 0);
+ irIrrigateGroupMapper.insertSelective(irrigateGroup);
+ Long groupId = irrigateGroup.getId();
+ if(groupId == null) {
+ Map map = new HashMap<>();
+ map.put("success", false);
+ map.put("msg", "鍒涘缓杞亴缁勫け璐�");
+ map.put("content", null);
+ return map;
+ }
+
+ String[] intakeArr = po.getIntakes().split(",");
+ Integer sort = 1;
+ for(String intekeId : intakeArr) {
+ String trimmed = intekeId.trim();
+ if(trimmed.isEmpty()) {
+ continue;
+ }
+ try {
+ Long intakeIdLong = Long.parseLong(trimmed);
+ IrGroupIntake irGroupIntake = new IrGroupIntake();
+ irGroupIntake.setGroupId(groupId);
+ irGroupIntake.setIntakeId(intakeIdLong);
+ irGroupIntakeMapper.insert(irGroupIntake);
+ } 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;
+ }
+
+ /**
+ * 鏍规嵁缁処D鍒犻櫎鍙栨按鍙e叧鑱�
+ * @param groupId
+ * @return
+ */
+ public Map deleteGroup(Long groupId) {
+ try {
+ irGroupIntakeMapper.deleteByGroupId(groupId);
+ irIrrigateGroupMapper.deleteByPrimaryKey(groupId);
+
+ 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
+ */
+ public Map updateIrrigateGroup(IrrigateGroup po) {
+ // 淇敼杞亴缁�
+ IrIrrigateGroup irrigateGroup = new IrIrrigateGroup();
+ irrigateGroup.setId(po.getGroupId());
+ irrigateGroup.setGroupCode(po.getGroupCode());
+ irrigateGroup.setDefaultDuration(po.getDefaultDuration());
+ irrigateGroup.setOperator(po.getOperator());
+ irrigateGroup.setOperateTime(new Date());
+ irrigateGroup.setDeleted((byte) 0);
+ irIrrigateGroupMapper.updateByPrimaryKeySelective(irrigateGroup);
+
+ // 鍒犻櫎杞亴缁勪笌鍙栨按鍙e叧鑱�
+ Long groupId = po.getGroupId();
+ irGroupIntakeMapper.deleteByGroupId(groupId);
+
+ // 娣诲姞杞亴缁勪笌鍙栨按鍙e叧鑱�
+ String[] intakeArr = po.getIntakes().split(",");
+ Integer sort = 1;
+ for(String intekeId : intakeArr) {
+ String trimmed = intekeId.trim();
+ if(trimmed.isEmpty()) {
+ continue;
+ }
+ try {
+ Long intakeIdLong = Long.parseLong(trimmed);
+ IrGroupIntake irGroupIntake = new IrGroupIntake();
+ irGroupIntake.setGroupId(groupId);
+ irGroupIntake.setIntakeId(intakeIdLong);
+ irGroupIntakeMapper.insert(irGroupIntake);
+ } 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 queryVo
+ * @return
+ */
+ public QueryResultVo<List<VoGroupSimple>> getSimpleGroups(QoGroup queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params);
+
+ QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>();
+ rsVo.pageSize = queryVo.pageSize;
+ rsVo.pageCurr = queryVo.pageCurr;
+ rsVo.calculateAndSet(itemTotal, params);
+ rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(params);
+ return rsVo;
+ }
+
+ /**
+ * 鏌ヨ鍏ㄩ儴杞亴缁�
+ * @return
+ */
+ public List<VoGroupSimple> getAllGroups() {
+ //Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ //Long itemTotal = irIrrigateGroupMapper.getSimpleGroupCount(params);
+
+ //QueryResultVo<List<VoGroupSimple>> rsVo = new QueryResultVo<>();
+ //rsVo.pageSize = queryVo.pageSize;
+ //rsVo.pageCurr = queryVo.pageCurr;
+ //rsVo.calculateAndSet(itemTotal, params);
+ //rsVo.obj = irIrrigateGroupMapper.getSimpleGroups(null);
+ //return rsVo;
+
+ return irIrrigateGroupMapper.getSimpleGroups(null);
+ }
+
+ /**
+ * 鑾峰彇杞亴缁勮鎯�
+ * @param groupId
+ * @return
+ */
+ public Map getGroupDetail(Long groupId) {
+ try {
+ VoGroupDetail voGroupDetail = irIrrigateGroupMapper.getGroupDetail(groupId);
+ Map map = new HashMap<>();
+ map.put("success", true);
+ map.put("msg", "鑾峰彇杞亴缁勮鎯呮垚鍔�");
+ map.put("content", voGroupDetail);
+ 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