From 237f9af69f9bf1a9ef8cd46e60ec368caa549ae7 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期二, 28 十一月 2023 14:17:08 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/crm/manager/service/impl/CstmrServiceImpl.java |   93 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 93 insertions(+), 0 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 eacac84..0a38ccc 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,12 +1,105 @@
 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;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service("cstmrService")
 public class CstmrServiceImpl extends ServiceImpl<CstmrMapper, Cstmr> implements CstmrService {
 
+    @Override
+    public Cstmr selectByUuid(Long hostId, String uuid) {
+        return this.baseMapper.selectByUuid(hostId, uuid);
+    }
+
+    @Override
+    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 "00001";
+        }
+        return zerofill(String.valueOf(Integer.parseInt(cstmr.getUuid()) + 1), 5);
+    }
+
+    @Override
+    public Page<Cstmr> getPage2(Page<Cstmr> page, Long hostId, Long deptId, Long userId,Long roleId, String conditionName, String condition) {
+        return page.setRecords(baseMapper.listByPage2(page, hostId, deptId, userId,roleId,conditionName, condition));
+    }
+
+    @Override
+    public Page<Cstmr> getPage1(Page<Cstmr> page, Long hostId, String deptId, Long userId,  Long director, String conditionName,  String condition) {
+        return page.setRecords(baseMapper.listByPage1(page, hostId, deptId, userId, director, conditionName, condition));
+    }
+
+    @Override
+    public Page<Cstmr> getPage3(Page<Cstmr> page, Long hostId, String deptId, Long userId,  Long director, List<Integer> cstmrIds, String conditionName, String condition) {
+        if (cstmrIds==null){
+            return page.setRecords(baseMapper.listByPage1(page, hostId, deptId, userId,  director,conditionName, condition));
+        }else {
+            return page.setRecords(baseMapper.listByPage3(page, hostId, deptId, userId,  director,cstmrIds,conditionName, condition));
+        }
+    }
+
+    @Override
+    public Page<Cstmr> getPage33(Page<Cstmr> page, Long hostId, String deptId, Long userId,  Long director, List<Integer> cstmrIds, String conditionName, String condition) {
+        if (cstmrIds==null){
+            return page.setRecords(baseMapper.listByPage11(page, hostId, deptId, userId, director,conditionName, condition));
+        }else {
+            return page.setRecords(baseMapper.listByPage33(page, hostId, deptId, userId, director,cstmrIds,conditionName, condition));
+        }
+    }
+
+    @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 Page<Cstmr> getPageCstmr2(Page<Cstmr> page, Long hostId, String deptId, Long userId,  String condition) {
+        return page.setRecords(baseMapper.listByPageCstmr2(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){
+            return msg;
+        } else if (msg.length() > count){
+            return msg.substring(0, 16);
+        } else {
+            StringBuilder msgBuilder = new StringBuilder(msg);
+            for (int i = 0; i<count-msg.length(); i++){
+                msgBuilder.insert(0,"0");
+            }
+            return msgBuilder.toString();
+        }
+    }
+
+    @Override
+    public Cstmr selectByName(Long hostId, String name) {
+        return this.baseMapper.selectByName(hostId, name);
+    }
 }

--
Gitblit v1.9.1