From c6eb867d69f7cb2faf3818984bbe12316a692396 Mon Sep 17 00:00:00 2001
From: guoyuji <guoyujie@ng.com>
Date: 星期三, 24 四月 2024 13:10:54 +0800
Subject: [PATCH] 推送其他金额相关新增修改程序

---
 north-glass-erp/src/main/java/com/example/erp/service/sd/BasicOtherMoneyService.java |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicOtherMoneyService.java b/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicOtherMoneyService.java
index 14d50af..982af9d 100644
--- a/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicOtherMoneyService.java
+++ b/north-glass-erp/src/main/java/com/example/erp/service/sd/BasicOtherMoneyService.java
@@ -1,6 +1,7 @@
 package com.example.erp.service.sd;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.example.erp.entity.sd.BasicOtherMoney;
 import com.example.erp.mapper.sd.BasicOtherMoneyMapper;
 import org.springframework.stereotype.Service;
@@ -25,9 +26,31 @@
         return basicOtherMoneyMapper.deleteById(id);
     }
 
-    public int save(String alias) {
-        BasicOtherMoney basicOtherMoney = new  BasicOtherMoney();
-        basicOtherMoney.setAlias(alias);
-        return basicOtherMoneyMapper.insert(basicOtherMoney);
+    public boolean save(String alias) {
+        //鍒ゆ柇鏄惁宸茬粡瀛樺湪
+        QueryWrapper<BasicOtherMoney> queryWrapperByName = new QueryWrapper<>();
+        queryWrapperByName.eq("alias", alias);
+        int count = Math.toIntExact(basicOtherMoneyMapper.selectCount(queryWrapperByName));
+        if(count>0){
+            return false;
+        }
+
+        //鏌ヨ鏈�澶х殑鍒楀悕
+        QueryWrapper<BasicOtherMoney> queryWrapper = new QueryWrapper<>();
+        queryWrapper.orderByDesc("id");
+        List<BasicOtherMoney> basicOtherMoneyList = basicOtherMoneyMapper.selectList(queryWrapper);
+        //瓒呰繃100鏉′笉鎵ц
+        if(basicOtherMoneyList.size()==100){
+            return false;
+        }
+
+        BasicOtherMoney basicOtherMoney = basicOtherMoneyList.get(0);
+        String getColumn = basicOtherMoney.getColumn()==null?"0":basicOtherMoney.getColumn().replace("M","");
+        int  columnNum = Integer.parseInt(getColumn)+1;
+        BasicOtherMoney newBasicOtherMoney = new  BasicOtherMoney();
+        newBasicOtherMoney.setColumn("M"+String.format("%02d", columnNum));
+        newBasicOtherMoney.setAlias(alias);
+        basicOtherMoneyMapper.insert(newBasicOtherMoney);
+        return true;
     }
 }

--
Gitblit v1.8.0