Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
e94386dfbf
@ -3,6 +3,7 @@ package com.fuint.business.store.service.impl;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuint.business.order.mapper.AllOrderInfoMapper;
|
import com.fuint.business.order.mapper.AllOrderInfoMapper;
|
||||||
@ -386,9 +387,13 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
|
|||||||
MtStore mtStore = mtStoreMapper.selectById(Integer.parseInt(flag));
|
MtStore mtStore = mtStoreMapper.selectById(Integer.parseInt(flag));
|
||||||
// 找到对应的站长deptId
|
// 找到对应的站长deptId
|
||||||
LambdaQueryWrapper<TDuty> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TDuty> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
lambdaQueryWrapper.eq(TDuty::getCode,"z001");
|
/* lambdaQueryWrapper.eq(TDuty::getCode,"z001");*/
|
||||||
TDuty tDuty = tDutyMapper.selectOne(lambdaQueryWrapper);
|
lambdaQueryWrapper.eq(TDuty::getStoreId,mtStore.getContractDeptId());
|
||||||
|
List<TDuty> tDuties = tDutyMapper.selectList(lambdaQueryWrapper);
|
||||||
|
TDuty tDuty = new TDuty();
|
||||||
|
if(ObjectUtils.isNotEmpty(tDuties)){
|
||||||
|
tDuty = tDuties.get(0);
|
||||||
|
}
|
||||||
// 查找对应的用户信息
|
// 查找对应的用户信息
|
||||||
TAccount tAccount = new TAccount();
|
TAccount tAccount = new TAccount();
|
||||||
tAccount.setDeptId(mtStore.getContractDeptId());
|
tAccount.setDeptId(mtStore.getContractDeptId());
|
||||||
@ -425,8 +430,16 @@ public class StoreServiceImpl extends ServiceImpl<MtStoreMapper, MtStore> implem
|
|||||||
MtStore mtStore = mtStoreMapper.selectById(Integer.parseInt(flag));
|
MtStore mtStore = mtStoreMapper.selectById(Integer.parseInt(flag));
|
||||||
// 找到对应的站长deptId
|
// 找到对应的站长deptId
|
||||||
LambdaQueryWrapper<TDuty> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<TDuty> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
|
/* lambdaQueryWrapper.eq(TDuty::getCode,"z001");*/
|
||||||
|
lambdaQueryWrapper.eq(TDuty::getStoreId,mtStore.getContractDeptId());
|
||||||
|
List<TDuty> tDuties = tDutyMapper.selectList(lambdaQueryWrapper);
|
||||||
|
TDuty tDuty = new TDuty();
|
||||||
|
if(ObjectUtils.isNotEmpty(tDuties)){
|
||||||
|
tDuty = tDuties.get(0);
|
||||||
|
}
|
||||||
|
/*LambdaQueryWrapper<TDuty> lambdaQueryWrapper = Wrappers.lambdaQuery();
|
||||||
lambdaQueryWrapper.eq(TDuty::getCode,"z001");
|
lambdaQueryWrapper.eq(TDuty::getCode,"z001");
|
||||||
TDuty tDuty = tDutyMapper.selectOne(lambdaQueryWrapper);
|
TDuty tDuty = tDutyMapper.selectOne(lambdaQueryWrapper);*/
|
||||||
|
|
||||||
|
|
||||||
// 查找对应的用户信息
|
// 查找对应的用户信息
|
||||||
|
@ -66,7 +66,8 @@ public class SysDeptController extends BaseController
|
|||||||
@GetMapping(value = "/{deptId}")
|
@GetMapping(value = "/{deptId}")
|
||||||
public ResponseObject getInfo(@PathVariable Long deptId)
|
public ResponseObject getInfo(@PathVariable Long deptId)
|
||||||
{
|
{
|
||||||
List<SysDept> sysDepts = deptService.selectDeptLists(deptId);
|
//List<SysDept> sysDepts = deptService.selectDeptLists(deptId);
|
||||||
|
List<SysDept> sysDepts = deptService.selectDeptListss(deptId);
|
||||||
SysDept sysDept = deptService.selectDeptById(deptId);
|
SysDept sysDept = deptService.selectDeptById(deptId);
|
||||||
if (ObjectUtil.isNotEmpty(sysDept)) sysDept.setStoreNums(sysDepts.size());
|
if (ObjectUtil.isNotEmpty(sysDept)) sysDept.setStoreNums(sysDepts.size());
|
||||||
List<SysDept> sysDepts1 = deptService.selectDeptList(new SysDept());
|
List<SysDept> sysDepts1 = deptService.selectDeptList(new SysDept());
|
||||||
@ -97,6 +98,16 @@ public class SysDeptController extends BaseController
|
|||||||
return getSuccessResult(row);
|
return getSuccessResult(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取可创建油站数
|
||||||
|
*/
|
||||||
|
@PostMapping("/getMaxNumber")
|
||||||
|
public ResponseObject getMaxNumber(@Validated @RequestBody SysDept dept) throws Exception {
|
||||||
|
|
||||||
|
int maxNumber = deptService.getMaxNumber(dept);
|
||||||
|
return getSuccessResult(maxNumber);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
|
@ -23,6 +23,10 @@ public interface ISysDeptService extends IService<SysDept>
|
|||||||
public List<SysDept> selectDeptList(SysDept dept);
|
public List<SysDept> selectDeptList(SysDept dept);
|
||||||
|
|
||||||
List<SysDept> selectDeptLists(Long parentId);
|
List<SysDept> selectDeptLists(Long parentId);
|
||||||
|
List<SysDept> selectDept(Long parentId);
|
||||||
|
List<SysDept> selectDeptByDeptId(Long parentId);
|
||||||
|
List<SysDept> selectDeptListss(Long parentId);
|
||||||
|
List<SysDept> selectDeptListsss(Long parentId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门树结构信息
|
* 查询部门树结构信息
|
||||||
@ -136,4 +140,6 @@ public interface ISysDeptService extends IService<SysDept>
|
|||||||
long getCountdown();
|
long getCountdown();
|
||||||
|
|
||||||
boolean isTopLevelNodes(Integer deptId);
|
boolean isTopLevelNodes(Integer deptId);
|
||||||
|
|
||||||
|
int getMaxNumber(SysDept dept);
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,41 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> imple
|
|||||||
return baseMapper.selectList(queryWrapper);
|
return baseMapper.selectList(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> selectDept(Long parentId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("dept_id",parentId);
|
||||||
|
queryWrapper.eq("if_delete","0");
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> selectDeptByDeptId(Long parentId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("dept_id",parentId);
|
||||||
|
queryWrapper.eq("if_delete","0");
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> selectDeptListss(Long parentId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||||
|
/*queryWrapper.eq("parent_id",parentId);*/
|
||||||
|
queryWrapper.eq("dept_type","3");
|
||||||
|
queryWrapper.eq("if_delete","0");
|
||||||
|
queryWrapper.like("ancestors",parentId);
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDept> selectDeptListsss(Long parentId) {
|
||||||
|
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||||
|
/*queryWrapper.eq("parent_id",parentId);*/
|
||||||
|
queryWrapper.eq("if_delete","0");
|
||||||
|
queryWrapper.like("ancestors",parentId);
|
||||||
|
return baseMapper.selectList(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询部门树结构信息
|
* 查询部门树结构信息
|
||||||
*
|
*
|
||||||
@ -256,13 +291,27 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> imple
|
|||||||
throw new ServiceException("部门停用,不允许新增");
|
throw new ServiceException("部门停用,不允许新增");
|
||||||
}
|
}
|
||||||
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
|
||||||
List<SysDept> sysDepts = this.selectDeptLists(dept.getParentId());
|
List<SysDept> sysDepts = this.selectDeptListss(dept.getParentId());
|
||||||
if (ObjectUtils.isNotEmpty(info) && ObjectUtils.isNotEmpty(info.getStoreNum()) && CollectionUtil.isNotEmpty(sysDepts) && sysDepts.size()>=info.getStoreNum())
|
if (ObjectUtils.isNotEmpty(info) && ObjectUtils.isNotEmpty(info.getStoreNum()) && CollectionUtil.isNotEmpty(sysDepts) && sysDepts.size()>=info.getStoreNum())
|
||||||
{
|
{
|
||||||
throw new Exception("已到达最大的油站数量,不可添加!");
|
throw new Exception("已到达最大的油站数量,不可添加!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (ObjectUtils.isNotEmpty(dept) && ObjectUtils.isNotEmpty(dept.getDeptType()) && dept.getDeptType().equals("1")){
|
||||||
|
List<SysDept> sysDepts = this.selectDept(dept.getParentId());
|
||||||
|
for (SysDept sysDept : sysDepts) {
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDept) && ObjectUtils.isNotEmpty(sysDept.getDeptType()) && sysDept.getDeptType().equals("1")){
|
||||||
|
List<SysDept> sysDeptss = this.selectDeptByDeptId(sysDept.getParentId());
|
||||||
|
for (SysDept deptss : sysDeptss) {
|
||||||
|
if (ObjectUtils.isNotEmpty(deptss) && deptss.getDeptType().equals("1")){
|
||||||
|
throw new Exception("不可再添加代理!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int insert = baseMapper.insert(dept);
|
int insert = baseMapper.insert(dept);
|
||||||
//处理店铺
|
//处理店铺
|
||||||
if(StringUtils.isNotEmpty(dept.getDeptType())){
|
if(StringUtils.isNotEmpty(dept.getDeptType())){
|
||||||
@ -508,4 +557,101 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper,SysDept> imple
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxNumber(SysDept dept) {
|
||||||
|
int maxNumber = 0;
|
||||||
|
int middleNumber = 0;
|
||||||
|
int finalNumber = 0;
|
||||||
|
int middleNumber01 = 0;
|
||||||
|
int middleNumber02 = 0;
|
||||||
|
//递归拿到最高节点
|
||||||
|
SysDept recursion = recursion(dept);
|
||||||
|
if (ObjectUtils.isNotEmpty(recursion) && ObjectUtils.isNotEmpty(recursion.getStoreNum())) {
|
||||||
|
maxNumber = recursion.getStoreNum();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (ObjectUtils.isNotEmpty(dept.getDeptId())){
|
||||||
|
//上级
|
||||||
|
List<SysDept> sysDepts1 = this.selectDeptByDeptId(dept.getParentId());
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDepts1) && sysDepts1.get(0).getDeptId() != 100) {
|
||||||
|
maxNumber = sysDepts1.get(0).getStoreNum();
|
||||||
|
//本身
|
||||||
|
List<SysDept> sysDepts = this.selectDeptByDeptId(dept.getDeptId());
|
||||||
|
middleNumber01 = sysDepts.get(0).getStoreNum();
|
||||||
|
//同级
|
||||||
|
List<SysDept> sysDepts2 = this.selectDeptLists(dept.getParentId());
|
||||||
|
for (SysDept sysDept : sysDepts2) {
|
||||||
|
middleNumber += sysDept.getStoreNum();
|
||||||
|
}
|
||||||
|
middleNumber02 = middleNumber - middleNumber01;
|
||||||
|
if (middleNumber02 + dept.getStoreNum() > maxNumber){
|
||||||
|
finalNumber = maxNumber - middleNumber02;
|
||||||
|
}else {
|
||||||
|
finalNumber = dept.getStoreNum();
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
finalNumber = dept.getStoreNum();
|
||||||
|
}
|
||||||
|
return finalNumber;
|
||||||
|
}else {
|
||||||
|
//上级
|
||||||
|
List<SysDept> sysDepts1 = this.selectDeptByDeptId(dept.getParentId());
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDepts1) && sysDepts1.get(0).getDeptId() != 100){
|
||||||
|
maxNumber = sysDepts1.get(0).getStoreNum();
|
||||||
|
//同级
|
||||||
|
List<SysDept> sysDepts2 = this.selectDeptLists(dept.getParentId());
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDepts2)) {
|
||||||
|
for (SysDept sysDept : sysDepts2) {
|
||||||
|
middleNumber += sysDept.getStoreNum();
|
||||||
|
}
|
||||||
|
middleNumber01 = dept.getStoreNum();
|
||||||
|
if (middleNumber + middleNumber01 > maxNumber){
|
||||||
|
return maxNumber-middleNumber;
|
||||||
|
}else {
|
||||||
|
return middleNumber01;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
if (maxNumber > dept.getStoreNum()){
|
||||||
|
finalNumber = dept.getStoreNum();
|
||||||
|
}else {
|
||||||
|
finalNumber = maxNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
finalNumber = dept.getStoreNum();
|
||||||
|
}
|
||||||
|
return finalNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*List<SysDept> sysDepts = this.selectDeptListsss(recursion.getDeptId());
|
||||||
|
int size = sysDepts.size();
|
||||||
|
for (SysDept sysDept : sysDepts) {
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDept) && ObjectUtils.isNotEmpty(sysDept.getStoreNum()) && sysDept.getParentId() != 100) {
|
||||||
|
SysDept sysDept1 = sysDepts.get(size - 1);
|
||||||
|
middleNumber01 = dept.getStoreNum();
|
||||||
|
middleNumber += sysDept.getStoreNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finalNumber = maxNumber - middleNumber - middleNumber01;
|
||||||
|
if (finalNumber<0){
|
||||||
|
finalNumber = maxNumber- middleNumber;
|
||||||
|
return finalNumber;
|
||||||
|
}else {
|
||||||
|
return dept.getStoreNum();
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysDept recursion (SysDept dept){
|
||||||
|
List<SysDept> sysDepts = this.selectDept(dept.getParentId());
|
||||||
|
if (ObjectUtils.isNotEmpty(sysDepts) && ObjectUtils.isNotEmpty(sysDepts.get(0).getParentId())) {
|
||||||
|
if (sysDepts.get(0).getParentId() == 100) {
|
||||||
|
return sysDepts.get(0);
|
||||||
|
}
|
||||||
|
return recursion(sysDepts.get(0));
|
||||||
|
}
|
||||||
|
return new SysDept();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user