From 7bfa5f63181b0cedd43899e9dacdfca26ebfd4ad Mon Sep 17 00:00:00 2001
From: liulin <lin.liu@88.com>
Date: 星期二, 08 七月 2025 09:50:58 +0800
Subject: [PATCH] 修改支付接口

---
 src/main/java/com/lunhan/water/service/WaterFacilityRecordsService.java |  244 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 244 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/lunhan/water/service/WaterFacilityRecordsService.java b/src/main/java/com/lunhan/water/service/WaterFacilityRecordsService.java
new file mode 100644
index 0000000..50a22fb
--- /dev/null
+++ b/src/main/java/com/lunhan/water/service/WaterFacilityRecordsService.java
@@ -0,0 +1,244 @@
+/**
+#                                                    __----~~~~~~~~~~~------___
+#                                   .  .   ~~//====......          __--~ ~~
+#                   -.            \_|//     |||\\  ~~~~~~::::... /~
+#                ___-==_       _-~o~  \/    |||  \\            _/~~-
+#        __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
+#    _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
+#  .~       .~       |   \\ -_    /  /-   /   ||      \   /
+# /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
+# |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
+#          '         ~-|      /|    |-~\~~       __--~~
+#                      |-~~-_/ |    |   ~\_   _-~            /\
+#                           /  \     \__   \/~                \__
+#                       _--~ _/ | .-~~____--~-/                  ~~==.
+#                      ((->/~   '.|||' -_|    ~~-/ ,              . _||
+#                                 -_     ~\      ~~---l__i__i__i--~~_/
+#                                 _-~-__   ~)  \--______________--~~
+#                               //.-~~~-~_--~- |-------~~~~~~~~
+#                                      //.-~~~--\
+#                  神兽保佑
+#                  永无BUG!
+*/
+package com.lunhan.water.service;
+
+import com.lunhan.water.common.*;
+import com.lunhan.water.common.enums.*;
+import com.lunhan.water.common.model.Tuple;
+import com.lunhan.water.common.util.*;
+import org.apache.commons.lang3.BooleanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import java.util.*;
+import java.util.stream.Collectors;
+import com.lunhan.water.repository.impl.WaterFacilityRecordsMapperImpl;
+import com.lunhan.water.repository.po.WaterFacilityRecordsPO;
+import com.lunhan.water.entity.request.waterfacilityrecords.ReqCreateWaterFacilityRecords;
+import com.lunhan.water.entity.request.waterfacilityrecords.ReqModifyWaterFacilityRecords;
+import com.lunhan.water.entity.search.SearchWaterFacilityRecords;
+import com.lunhan.water.repository.vo.WaterFacilityRecordsVO;
+import com.lunhan.water.service.convert.WaterFacilityRecordsConvert;
+
+/**
+ * 设备供水记录
+ * @author lin.liu
+ */
+@Service
+public class WaterFacilityRecordsService extends BaseService {
+    @Autowired
+    private WaterFacilityRecordsMapperImpl mapper;
+
+    public ExecutedResult<Long> create(ReqCreateWaterFacilityRecords request) {
+        // 转换po
+        WaterFacilityRecordsPO item = WaterFacilityRecordsConvert.INSTANCE.toCreate(request);
+        // 设置状态
+        //item.setStatus(EState.NORMAL.getValue());
+        // 设置记录创建时间
+        item.setCreateTime(LocalDateTimeUtil.nowTimeStamp());
+        // 是否删除(逻辑删除)初始值
+        item.setIsDelete(EYesOrNo.NO.getValue());
+
+        int rowCount = mapper.insert(item);
+        if (rowCount != 1) {
+            return ExecutedResult.failed("创建[设备供水记录]失败。");
+        }
+        return ExecutedResult.success(item.getId());
+    }
+
+    public ExecutedResult<String> modify(ReqModifyWaterFacilityRecords request) {
+        // 验证记录是否存在
+        ExecutedResult<WaterFacilityRecordsPO> checkExists = this.check4Id(request.getId());
+        if (checkExists.isFailed()) {
+            return ExecutedResult.failed(checkExists.getMsg());
+        }
+        // 转换po
+        WaterFacilityRecordsPO item = WaterFacilityRecordsConvert.INSTANCE.toModify(request);
+
+        int rowCount = mapper.updateById(item);
+        if (rowCount != 1) {
+            return ExecutedResult.failed("编辑[设备供水记录]失败。");
+        }
+        return ExecutedResult.success();
+    }
+
+    public ExecutedResult<WaterFacilityRecordsVO> get(Long id) {
+        WaterFacilityRecordsVO result = new WaterFacilityRecordsVO();
+
+        WaterFacilityRecordsPO find = mapper.get(id);
+        if (null != find) {
+            // 转换vo
+            result = WaterFacilityRecordsConvert.INSTANCE.toVo(find);
+        }
+        return ExecutedResult.success(result);
+    }
+
+//    public ExecutedResult<String> stop(Long id) {
+//        // 验证记录是否存在
+//        ExecutedResult<WaterFacilityRecordsPO> checkExists = this.check4Id(id);
+//        if (checkExists.isFailed()) {
+//            return ExecutedResult.failed(checkExists.getMsg());
+//        }
+//        WaterFacilityRecordsPO item = new WaterFacilityRecordsPO();
+//        item.setId(id);
+//        item.setStatus(EState.DISABLED.getValue());
+//
+//        int rowCount = mapper.updateById(item);
+//        if (rowCount != 1) {
+//           return ExecutedResult.failed("停用[设备供水记录]失败。");
+//       }
+//       return ExecutedResult.success();
+//   }
+//
+//    public ExecutedResult<String> enable(Long id) {
+//        // 验证记录是否存在
+//        ExecutedResult<WaterFacilityRecordsPO> checkExists = this.check4Id(id);
+//        if (checkExists.isFailed()) {
+//            return ExecutedResult.failed(checkExists.getMsg());
+//        }
+//        WaterFacilityRecordsPO item = new WaterFacilityRecordsPO();
+//        item.setId(id);
+//        item.setStatus(EState.NORMAL.getValue());
+//
+//        int rowCount = mapper.updateById(item);
+//        if (rowCount != 1) {
+//            return ExecutedResult.failed("启用[设备供水记录]失败。");
+//        }
+//        return ExecutedResult.success();
+//    }
+//
+//    public ExecutedResult<String> setSort(ReqSetSort request) {
+//        // 验证记录是否存在
+//        ExecutedResult<WaterFacilityRecordsPO> checkExists = this.check4Id(request.getId());
+//        if (checkExists.isFailed()) {
+//            return ExecutedResult.failed(checkExists.getMsg());
+//        }
+//        WaterFacilityRecordsPO item = new WaterFacilityRecordsPO();
+//        item.setId(request.getId());
+//        item.setSort(request.getSort());
+//
+//        int rowCount = mapper.updateById(item);
+//        if (rowCount != 1) {
+//            return ExecutedResult.failed("设置[设备供水记录]排序值失败。");
+//        }
+//        return ExecutedResult.success();
+//    }
+//
+//    public ExecutedResult<String> listSetSort(ReqListSetSort request) {
+//        // id列表
+//        List<Long> listId = request.getList().stream().map(ReqSetSort::getId).collect(Collectors.toList());
+//        // 验证记录是否存在
+//        ExecutedResult<List<WaterFacilityRecordsPO>> checkExists = this.check4Id(listId);
+//        if (checkExists.isFailed()) {
+//            return ExecutedResult.failed(checkExists.getMsg());
+//        }
+//
+//        List<WaterFacilityRecordsPO> listUpdate = request.getList().stream()
+//                .map(c -> {
+//                    WaterFacilityRecordsPO item = new WaterFacilityRecordsPO();
+//                    item.setId(c.getId());
+//                    item.setSort(c.getSort());
+//                    return item;
+//                })
+//                .collect(Collectors.toList());
+//        Boolean result = mapper.modifyList(listUpdate);
+//        if (result) {
+//            return ExecutedResult.success();
+//        }
+//        return ExecutedResult.failed("[设备供水记录]设置排序值失败");
+//    }
+//
+//    public ExecutedResult<String> remove(Long id) {
+//        Boolean result = mapper.deleteLogic(id);
+//        if (BooleanUtils.isFalse(result)) {
+//            return ExecutedResult.failed("删除[设备供水记录]失败。");
+//        }
+//        return ExecutedResult.success();
+//    }
+//
+//    public ExecutedResult<String> removeList(List<Long> ids) {
+//        Boolean result = mapper.deleteLogic(ids);
+//        if (BooleanUtils.isFalse(result)) {
+//            return ExecutedResult.failed("删除[设备供水记录]失败。");
+//        }
+//        return ExecutedResult.success();
+//    }
+
+    public ExecutedResult<List<WaterFacilityRecordsVO>> getList(List<Long> listId) {
+        List<WaterFacilityRecordsVO> result = new ArrayList<>();
+
+        List<WaterFacilityRecordsPO> list = mapper.getList(listId);
+        if (ListUtil.isNotNullOrEmpty(list)) {
+            // 转换vo
+            result = WaterFacilityRecordsConvert.INSTANCE.toVo(list);
+        }
+        return ExecutedResult.success(result);
+    }
+
+    public ExecutedResult<PagerResult<WaterFacilityRecordsVO>> search(SearchWaterFacilityRecords search) {
+        // 处理创建时间范围-查询参数
+        Tuple<String, String> createTimeRange = ParameterUtil.getTimeRange(search.getCreateTimeRange());
+        if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem1())) {
+            search.setCreateTimeStart(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem1()).getTime());
+        }
+        if (StringUtil.isNotNullOrEmpty(createTimeRange.getItem2())) {
+            search.setCreateTimeEnd(LocalDateTimeUtil.getTimeStamp(createTimeRange.getItem2()).getTime());
+        }
+
+        PagerResult<WaterFacilityRecordsPO> pageList = mapper.search(search);
+        List<WaterFacilityRecordsVO> listVo = new ArrayList<>();
+        List<WaterFacilityRecordsPO> list = pageList.getList();
+        if (ListUtil.isNotNullOrEmpty(list)) {
+            pageList.setLastId(list.get(list.size() - 1).getId());
+            // 转换vo
+            listVo = WaterFacilityRecordsConvert.INSTANCE.toVo(list);
+        }
+        PagerResult<WaterFacilityRecordsVO> result = new PagerResult<>(pageList.getLimit(), pageList.getPage(), pageList.getTotal(), listVo);
+        result.setLastId(pageList.getLastId());
+        return ExecutedResult.success(result);
+    }
+
+    protected ExecutedResult<WaterFacilityRecordsPO> check4Id(Long id) {
+        WaterFacilityRecordsPO exists = mapper.get(id);
+        if (Objects.isNull(exists)) {
+            return ExecutedResult.failed("[设备供水记录]不存在:" + id);
+        }
+        return ExecutedResult.success(exists);
+    }
+    protected ExecutedResult<List<WaterFacilityRecordsPO>> check4Id(List<Long> listId) {
+        // 从数据库查找设备供水记录
+        List<WaterFacilityRecordsPO> list = mapper.getList(listId);
+        if (ListUtil.isNullOrEmpty(list)) {
+            return ExecutedResult.failed("[设备供水记录]不存在." + listId);
+        }
+        // 数据库找到的id列表
+        List<Long> listIdFind = list.stream().map(WaterFacilityRecordsPO::getId).collect(Collectors.toList());
+        // 数量不一致
+        if (listId.size() != listIdFind.size()) {
+            // 筛选数据库不存在的设备供水记录
+            List<Long> listIdNotFound = listId.stream().filter(c -> !listIdFind.contains(c)).collect(Collectors.toList());
+            if (ListUtil.isNullOrEmpty(list)) {
+                return ExecutedResult.failed("[设备供水记录]不存在." + listIdNotFound);
+            }
+        }
+        return ExecutedResult.success(list);
+    }}

--
Gitblit v1.9.3