From 9f095733d13185290cfedd242b5f299585fbcad0 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期一, 07 四月 2025 10:05:34 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/service/impl/DocTypeServiceImpl.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/DocTypeServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/DocTypeServiceImpl.java
index 0192d5c..5d142eb 100644
--- a/src/main/java/com/zy/asrs/service/impl/DocTypeServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/DocTypeServiceImpl.java
@@ -1,12 +1,59 @@
package com.zy.asrs.service.impl;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.core.common.Cools;
+import com.core.exception.CoolException;
import com.zy.asrs.mapper.DocTypeMapper;
import com.zy.asrs.entity.DocType;
import com.zy.asrs.service.DocTypeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
+import java.util.Date;
+
@Service("docTypeService")
public class DocTypeServiceImpl extends ServiceImpl<DocTypeMapper, DocType> implements DocTypeService {
+ @Override
+ public DocType selectOrAdd(String docName, Boolean pakin) {
+ if (Cools.isEmpty(docName)) {
+ return null;
+ }
+ DocType docType = null;
+ try {
+ docType = this.selectById(docName);
+ } catch (Exception ignore) {}
+ if (docType == null) {
+ Wrapper<DocType> wrapper = new EntityWrapper<DocType>().eq("doc_name", docName);
+ if(pakin){
+ wrapper.eq("pakin",1);
+ }else {
+ wrapper.eq("pakout",1);
+ }
+ docType = this.selectOne(wrapper);
+ }
+
+ if (docType == null) {
+ long docId = 1L;
+ DocType last = this.selectOne(new EntityWrapper<DocType>().orderBy("doc_id", false));
+ if (last != null) {
+ docId = last.getDocId() + 1;
+ }
+ docType = new DocType();
+ docType.setDocId(docId);
+ docType.setDocName(docName);
+ if (null != pakin) {
+ docType.setPakin(pakin ? 1 : 0);
+ docType.setPakout(pakin ? 0 : 1);
+ }
+ docType.setStatus(1);
+ docType.setCreateTime(new Date());
+ docType.setUpdateTime(new Date());
+ if (!this.insert(docType)) {
+ throw new CoolException("鍗曟嵁绫诲瀷閿欒");
+ }
+ }
+ return docType;
+ }
}
--
Gitblit v1.9.1