From c8ec928e26cdf8efc51a576547ebcfbe3cb71f6d Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 16 三月 2023 16:28:24 +0800
Subject: [PATCH] 新增核价管理-上传询价后可进行下载功能

---
 src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java
index d0b29a8..5f3ee66 100644
--- a/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java
+++ b/src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java
@@ -1,5 +1,7 @@
 package com.zy.crm.manager.service.impl;
 
+import com.baomidou.mybatisplus.plugins.Page;
+import com.core.common.Cools;
 import com.zy.crm.manager.mapper.CstmrMapper;
 import com.zy.crm.manager.entity.Cstmr;
 import com.zy.crm.manager.service.CstmrService;
@@ -15,7 +17,21 @@
     }
 
     @Override
-    public String getNextUuid(Long hostId) {
+    public synchronized String getUuid(Long hostId) {
+        String uuid = null;
+        int times = 0;
+        while (Cools.isEmpty(uuid)) {
+            if (times > 100) { break; }
+            String nextUuid = getNextUuid(hostId);
+            if (selectByUuid(hostId, nextUuid) == null) {
+                uuid = nextUuid;
+            }
+            times ++;
+        }
+        return uuid;
+    }
+
+    private String getNextUuid(Long hostId) {
         Cstmr cstmr = this.baseMapper.selectCstmrByNewestUuid(hostId);
         if (cstmr == null) {
             return "0001";
@@ -23,6 +39,15 @@
         return zerofill(String.valueOf(Integer.parseInt(cstmr.getUuid()) + 1), 4);
     }
 
+    @Override
+    public Page<Cstmr> getPage(Page<Cstmr> page, Long hostId, String deptId, Long userId, String condition) {
+        return page.setRecords(baseMapper.listByPage(page, hostId, deptId, userId, condition));
+    }
+
+    @Override
+    public int updateDeptIdByUserId(Long userId, Long deptId) {
+        return this.baseMapper.updateDeptIdByUserId(userId, deptId);
+    }
 
     public static String zerofill(String msg, Integer count){
         if (msg.length() == count){
@@ -38,4 +63,8 @@
         }
     }
 
+    @Override
+    public Cstmr selectByName(Long hostId, String name) {
+        return this.baseMapper.selectByName(hostId, name);
+    }
 }

--
Gitblit v1.9.1