From c97d60075a43626dcdd4d5d4e59d55c94642a7dc Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期一, 20 十月 2025 10:35:42 +0800
Subject: [PATCH] 最新版本541200007
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java | 94 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 85 insertions(+), 9 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
index 9d6cd82..b89b1b5 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/CategoryServiceImpl.java
@@ -1,7 +1,10 @@
package com.doumee.service.business.impl;
+import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
+import com.doumee.dao.business.JkLineMapper;
+import com.doumee.dao.business.model.JkLine;
import com.doumee.service.business.third.model.LoginUserInfo;
import com.doumee.service.business.third.model.PageData;
import com.doumee.service.business.third.model.PageWrap;
@@ -14,11 +17,16 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.github.yulichang.query.MPJQueryWrapper;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
+import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import org.springframework.validation.BindException;
import java.util.ArrayList;
import java.util.Date;
@@ -35,10 +43,15 @@
public class CategoryServiceImpl implements CategoryService {
@Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+ @Autowired
private CategoryMapper categoryMapper;
+ @Autowired
+ private JkLineMapper jkLineMapper;
@Override
- public Integer create(Category category) {
+ @Transactional(rollbackFor = {Exception.class, BindException.class})
+ public Integer create(Category category){
checkUnique(category);
LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(loginUserInfo ==null){
@@ -54,15 +67,35 @@
insert.setRemark(category.getRemark());
insert.setStatus(Constants.ZERO);
insert.setSortnum(category.getSortnum());
+ insert.setBizType(category.getBizType());
insert.setImgurl(category.getImgurl());
insert.setType(category.getType());
insert.setParentId(category.getParentId());
categoryMapper.insert(insert);
+ if(insert.getBizType()!=null){
+ //娓呯┖鍏朵粬bizType,鍙繚鐣欏綋鍓嶆柊澧炶褰曞敮涓�鏈夋晥
+ categoryMapper.update(null,new UpdateWrapper<Category>().lambda()
+ .set(Category::getBizType,null)
+ .eq(Category::getBizType,insert.getType())
+ .ne(Category::getId,insert.getId())
+ );
+ }
return insert.getId();
}
@Override
public void deleteById(Integer id) {
+ Category c = categoryMapper.selectById(id);
+ if(c == null||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(Constants.equalsInteger(c.getType(),Constants.FOUR)){
+ //濡傛灉鏄柊绾胯矾锛屾鏌ユ槸鍚︽湁瀛愮嚎璺紝鏈夊垯涓嶅厑璁稿垹闄�
+ if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO)
+ .eq(JkLine::getCategoryId,id)) >0){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓荤嚎璺��"+c.getName()+"銆戜笅宸插瓨鍦ㄥ瓙绾胯矾锛屼笉鍏佽鍒犻櫎锛�");
+ }
+ }
categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
.eq(Category::getId,id)
);
@@ -79,15 +112,37 @@
if (CollectionUtils.isEmpty(ids)) {
return;
}
- categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
+ for(Integer id :ids){
+ Category c = categoryMapper.selectById(id);
+ if(c == null ||Constants.equalsInteger(c.getIsdeleted(),Constants.ONE)){
+ continue;
+ }
+ if(Constants.equalsInteger(c.getType(),Constants.FOUR)){
+ //濡傛灉鏄柊绾胯矾锛屾鏌ユ槸鍚︽湁瀛愮嚎璺紝鏈夊垯涓嶅厑璁稿垹闄�
+ if(jkLineMapper.selectCount(new MPJLambdaWrapper<JkLine>().eq(JkLine::getIsdeleted,Constants.ZERO)
+ .eq(JkLine::getCategoryId,id)) >0){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓荤嚎璺��"+c.getName()+"銆戜笅宸插瓨鍦ㄥ瓙绾胯矾锛屼笉鍏佽鍒犻櫎锛�");
+ }
+ }
+ }
+ categoryMapper.update(null,new UpdateWrapper<Category>().lambda().set(Category::getIsdeleted,Constants.ONE)
.in(Category::getId,ids)
);
}
@Override
+ @Transactional(rollbackFor = {Exception.class, BindException.class})
public void updateById(Category category) {
checkUnique(category);
categoryMapper.updateById(category);
+ if(category.getBizType()!=null){
+ //娓呯┖鍏朵粬璇izType灞炴��,鍙繚鐣欏綋鍓嶈褰曞敮涓�鏈夋晥
+ categoryMapper.update(null,new UpdateWrapper<Category>().lambda()
+ .set(Category::getBizType,null)
+ .eq(Category::getBizType,category.getBizType())
+ .ne(Category::getId,category.getId())
+ );
+ }
}
@Override
@@ -131,22 +186,36 @@
@Override
public PageData<Category> findPage(PageWrap<Category> pageWrap) {
IPage<Category> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
- QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
+ MPJLambdaWrapper<Category> queryWrapper = new MPJLambdaWrapper<>();
Utils.MP.blankToNull(pageWrap.getModel());
- queryWrapper.lambda().eq(Category::getIsdeleted,Constants.ZERO)
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() +
+ systemDictDataBiz.queryByCode(Constants.FTP,Constants.BANNER_IMG).getCode();
+ queryWrapper.selectAll(Category.class );
+ if(Constants.equalsInteger(pageWrap.getModel().getType(),Constants.FOUR)){
+ //濡傛灉鏄富绾胯矾锛屾煡璇㈢嚎璺暟鍜屽鎴锋暟
+ queryWrapper.select( "(select count(1) from jk_line b where b.isdeleted=0 and b.CATEGORY_ID = t.id)",Category::getLineNum);
+ queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id)",Category::getCustomerNum);
+ queryWrapper.select( "(select count(1) from jk_customer b left join jk_line c on b.line_id=c.id where c.isdeleted=0 and b.isdeleted=0 and c.CATEGORY_ID = t.id and b.DISTANCE_STATUS = 1)",Category::getCustomerDoneNum);
+ }
+ queryWrapper.eq(Category::getIsdeleted,Constants.ZERO)
.eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType())
- .isNull(Category::getParentId);
+ .like(StringUtils.isNotBlank(pageWrap.getModel().getName()),Category::getName,pageWrap.getModel().getName())
+ .isNull(Category::getParentId)
+ .orderByDesc(Category::getSortnum);
PageData<Category> categoryPageData = PageData.from(categoryMapper.selectPage(page, queryWrapper));
//鏌ヨ鎵�鏈変簩绾ф暟鎹�
List<Category> categoryList = categoryMapper.selectList(
new QueryWrapper<Category>().lambda()
.eq(Objects.nonNull(pageWrap.getModel().getType()),Category::getType,pageWrap.getModel().getType())
- .eq(Category::getIsdeleted,Constants.ZERO).isNotNull(Category::getParentId));
+ .eq(Category::getIsdeleted,Constants.ZERO).isNotNull(Category::getParentId).orderByDesc(Category::getSortnum));
for (Category category:categoryPageData.getRecords()) {
category.setChildCategoryList(
categoryList.stream().filter(i->Constants.equalsInteger(i.getParentId(),category.getId())).collect(Collectors.toList())
);
+ if(StringUtils.isNotBlank(category.getImgurl())){
+ category.setImgurlFull(prefixUrl + category.getImgurl());
+ }
}
return categoryPageData;
@@ -159,6 +228,10 @@
}
@Override
public List<Category> findChileList(Category model) {
+ if(Objects.isNull(model)){
+ model = new Category();
+ }
+ model.setIsdeleted(Constants.ZERO);
List<Category> list =findList(model);
List<Category> data = new ArrayList<>();
if(list!=null){
@@ -171,6 +244,8 @@
category.setGroupName( category.getParentName()+"/"+category.getName());
data.add(category);
}
+ }else{
+ data.add(category);
}
}
}
@@ -193,12 +268,13 @@
wrapper.lambda()
.eq(Category::getIsdeleted,Constants.ZERO)
.eq(Category::getType,category.getType())
- .eq(Category::getName,category.getName());
+ .eq(Category::getName,category.getName())
+ .ne(category.getId()!=null, Category::getId,category.getId())
+ ;
List<Category> categories = categoryMapper.selectList(wrapper);
-
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categories)){
- throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"鍒嗙被淇℃伅宸插瓨鍦�");
+ throw new BusinessException(ResponseStatus.DATA_EXISTS.getCode(),"淇℃伅宸插瓨鍦�");
}
}
}
--
Gitblit v1.9.3