From 8dcb0edcc2ceaa244501e7ed0c4f363ab4f3a428 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期五, 03 四月 2026 15:29:04 +0800
Subject: [PATCH] Merge branch '2.0.1' of http://139.186.142.91:10010/r/productDev/funingyunwei into 2.0.1

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalServiceImpl.java |  137 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 137 insertions(+), 0 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalServiceImpl.java
new file mode 100644
index 0000000..f25aa2d
--- /dev/null
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalServiceImpl.java
@@ -0,0 +1,137 @@
+package com.doumee.service.business.impl;
+
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
+import com.doumee.core.model.PageData;
+import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
+import com.doumee.core.utils.DateUtil;
+import com.doumee.core.utils.Utils;
+import com.doumee.dao.business.YwElectricalMapper;
+import com.doumee.dao.business.model.YwElectrical;
+import com.doumee.dao.business.model.YwGateway;
+import com.doumee.service.business.YwElectricalService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 鐢佃〃璁惧淇℃伅Service瀹炵幇
+ * @author renkang
+ * @date 2026/04/03
+ */
+@Service
+public class YwElectricalServiceImpl implements YwElectricalService {
+
+    @Autowired
+    private YwElectricalMapper ywElectricalMapper;
+
+    @Override
+    public Integer create(YwElectrical ywElectrical) {
+        if (Objects.isNull(ywElectrical)
+                || StringUtils.isBlank(ywElectrical.getName())
+                || StringUtils.isBlank(ywElectrical.getCode())) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo loginUserInfo = ywElectrical.getLoginUserInfo();
+        // 鏍¢獙琛ㄥ彿鍞竴
+        if (ywElectricalMapper.selectCount(new QueryWrapper<YwElectrical>().lambda()
+                .eq(YwElectrical::getIsdeleted, Constants.ZERO)
+                .eq(YwElectrical::getCode, ywElectrical.getCode())) > Constants.ZERO) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "琛ㄥ彿閲嶅!");
+        }
+        ywElectrical.setCreateDate(new Date());
+        ywElectrical.setCreator(loginUserInfo.getId());
+        ywElectrical.setEditDate(new Date());
+        ywElectrical.setEditor(loginUserInfo.getId());
+        ywElectrical.setIsdeleted(Constants.ZERO);
+        ywElectricalMapper.insert(ywElectrical);
+        return ywElectrical.getId();
+    }
+
+    @Override
+    public void deleteById(Integer id, LoginUserInfo user) {
+        ywElectricalMapper.update(new UpdateWrapper<YwElectrical>()
+                .lambda()
+                .set(YwElectrical::getIsdeleted, Constants.ONE)
+                .set(YwElectrical::getEditDate, DateUtil.getCurrDateTime())
+                .set(YwElectrical::getEditor, user.getId())
+                .eq(YwElectrical::getId, id)
+        );
+    }
+
+    @Override
+    public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) {
+        if (CollectionUtils.isEmpty(ids)) {
+            return;
+        }
+        for (Integer id : ids) {
+            this.deleteById(id, user);
+        }
+    }
+
+    @Override
+    public void updateById(YwElectrical ywElectrical) {
+        if (Objects.isNull(ywElectrical)
+                || Objects.isNull(ywElectrical.getId())
+                || StringUtils.isBlank(ywElectrical.getName())
+                || StringUtils.isBlank(ywElectrical.getCode())) {
+            throw new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        LoginUserInfo loginUserInfo = ywElectrical.getLoginUserInfo();
+        // 鏍¢獙琛ㄥ彿鍞竴锛堟帓闄よ嚜韬級
+        if (ywElectricalMapper.selectCount(new QueryWrapper<YwElectrical>().lambda()
+                .eq(YwElectrical::getIsdeleted, Constants.ZERO)
+                .eq(YwElectrical::getCode, ywElectrical.getCode())
+                .ne(YwElectrical::getId, ywElectrical.getId())) > Constants.ZERO) {
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "琛ㄥ彿閲嶅!");
+        }
+        ywElectrical.setEditDate(new Date());
+        ywElectrical.setEditor(loginUserInfo.getId());
+        ywElectricalMapper.updateById(ywElectrical);
+    }
+
+    @Override
+    public YwElectrical findById(Integer id) {
+        return ywElectricalMapper.selectJoinOne(YwElectrical.class,
+                new MPJLambdaWrapper<YwElectrical>()
+                        .selectAll(YwElectrical.class)
+                        .selectAs(YwGateway::getName, YwElectrical::getGatewayName)
+                        .leftJoin(YwGateway.class, YwGateway::getId, YwElectrical::getGatewayId)
+                        .eq(YwElectrical::getId, id)
+                        .last(" limit 1 ")
+        );
+    }
+
+    @Override
+    public PageData<YwElectrical> findPage(PageWrap<YwElectrical> pageWrap) {
+        IPage<YwElectrical> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
+        MPJLambdaWrapper<YwElectrical> queryWrapper = new MPJLambdaWrapper<>();
+        Utils.MP.blankToNull(pageWrap.getModel());
+        YwElectrical model = pageWrap.getModel();
+        queryWrapper.selectAll(YwElectrical.class)
+                .selectAs(YwGateway::getName, YwElectrical::getGatewayName)
+                .leftJoin(YwGateway.class, YwGateway::getId, YwElectrical::getGatewayId)
+                .and(Objects.nonNull(model) && StringUtils.isNotBlank(model.getName()),
+                        i -> i.like(YwElectrical::getName, model.getName())
+                             .or()
+                             .like(YwElectrical::getCode, model.getName()))
+                .eq(Objects.nonNull(model) && Objects.nonNull(model.getRunStatus()), YwElectrical::getRunStatus, model.getRunStatus())
+                .eq(Objects.nonNull(model) && Objects.nonNull(model.getGatewayId()), YwElectrical::getGatewayId, model.getGatewayId())
+                .eq(YwElectrical::getIsdeleted, Constants.ZERO)
+                .orderByDesc(YwElectrical::getCreateDate);
+        IPage<YwElectrical> iPage = ywElectricalMapper.selectJoinPage(page, YwElectrical.class, queryWrapper);
+        return PageData.from(iPage);
+    }
+}

--
Gitblit v1.9.3