|
@@ -1,14 +1,23 @@
|
|
|
package com.ktg.iscs.service.impl;
|
|
package com.ktg.iscs.service.impl;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
|
|
+import cn.hutool.core.lang.Assert;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.ktg.common.utils.StringUtils;
|
|
|
import com.ktg.iscs.domain.IsLockCabinet;
|
|
import com.ktg.iscs.domain.IsLockCabinet;
|
|
|
|
|
+import com.ktg.iscs.domain.IsLockCabinetSlots;
|
|
|
import com.ktg.iscs.mapper.IsLockCabinetMapper;
|
|
import com.ktg.iscs.mapper.IsLockCabinetMapper;
|
|
|
|
|
+import com.ktg.iscs.mapper.IsLockCabinetSlotsMapper;
|
|
|
import com.ktg.iscs.service.IIsLockCabinetService;
|
|
import com.ktg.iscs.service.IIsLockCabinetService;
|
|
|
|
|
+import com.ktg.iscs.service.IIsLockCabinetSlotsService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 锁控机柜Service业务层处理
|
|
* 锁控机柜Service业务层处理
|
|
|
*
|
|
*
|
|
@@ -20,12 +29,56 @@ public class IsLockCabinetServiceImpl extends ServiceImpl<IsLockCabinetMapper, I
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IsLockCabinetMapper isLockCabinetMapper;
|
|
private IsLockCabinetMapper isLockCabinetMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private IIsLockCabinetSlotsService iIsLockCabinetSlotsService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Page<IsLockCabinet> getIsLockCabinetPage(Page<IsLockCabinet> page, IsLockCabinet isLockCabinet) {
|
|
public Page<IsLockCabinet> getIsLockCabinetPage(Page<IsLockCabinet> page, IsLockCabinet isLockCabinet) {
|
|
|
Page<IsLockCabinet> result = page(page, Wrappers.<IsLockCabinet>lambdaQuery()
|
|
Page<IsLockCabinet> result = page(page, Wrappers.<IsLockCabinet>lambdaQuery()
|
|
|
|
|
+ .like(StringUtils.isNotBlank(isLockCabinet.getCabinetCode()), IsLockCabinet::getCabinetCode, isLockCabinet.getCabinetCode())
|
|
|
|
|
+ .like(StringUtils.isNotBlank(isLockCabinet.getCabinetName()), IsLockCabinet::getCabinetName, isLockCabinet.getCabinetName())
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(isLockCabinet.getIsOnline()), IsLockCabinet::getIsOnline, isLockCabinet.getIsOnline())
|
|
|
|
|
+ .eq(isLockCabinet.getWorkareId() != null, IsLockCabinet::getWorkareId, isLockCabinet.getWorkareId())
|
|
|
|
|
+ .eq(isLockCabinet.getWorkstationId() != null, IsLockCabinet::getWorkstationId, isLockCabinet.getWorkstationId())
|
|
|
|
|
+ .eq(StringUtils.isNotBlank(isLockCabinet.getStatus()), IsLockCabinet::getStatus, isLockCabinet.getStatus())
|
|
|
.orderByDesc(IsLockCabinet::getCabinetId));
|
|
.orderByDesc(IsLockCabinet::getCabinetId));
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean deleteIsLockCabinetByCabinetIds(String cabinetIds) {
|
|
|
|
|
+ Assert.notBlank(cabinetIds, "请选择需要删除的数据!");
|
|
|
|
|
+ Long[] longIds = Convert.toLongArray(cabinetIds);
|
|
|
|
|
+ List<Long> ids = Arrays.asList(longIds);
|
|
|
|
|
+ // 开始检测下面有没有正在使用的仓位信息,有的话不能删
|
|
|
|
|
+ List<IsLockCabinetSlots> list = iIsLockCabinetSlotsService.list(Wrappers.<IsLockCabinetSlots>lambdaQuery()
|
|
|
|
|
+ .in(IsLockCabinetSlots::getCabinetId, ids));
|
|
|
|
|
+ Assert.isTrue(list.isEmpty(), "请先清理柜子下的仓位信息!");
|
|
|
|
|
+ return removeBatchByIds(ids);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean insertIsLockCabinet(IsLockCabinet isLockCabinet) {
|
|
|
|
|
+ // 开始判断编码是否重复
|
|
|
|
|
+ if (StringUtils.isNotBlank(isLockCabinet.getCabinetCode())) {
|
|
|
|
|
+ List<IsLockCabinet> list = list(Wrappers.<IsLockCabinet>lambdaQuery()
|
|
|
|
|
+ .eq(IsLockCabinet::getCabinetCode, isLockCabinet.getCabinetCode()));
|
|
|
|
|
+ Assert.isTrue(list.isEmpty(), "该编码已被使用,请更换!");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 判断名称是否重复
|
|
|
|
|
+ List<IsLockCabinet> list1 = list(Wrappers.<IsLockCabinet>lambdaQuery()
|
|
|
|
|
+ .eq(IsLockCabinet::getCabinetName, isLockCabinet.getCabinetName()));
|
|
|
|
|
+ Assert.isTrue(list1.isEmpty(), "该名称已被使用,请更换!");
|
|
|
|
|
+ return save(isLockCabinet);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Boolean updateIsLockCabinet(IsLockCabinet isLockCabinet) {
|
|
|
|
|
+ Assert.notNull(isLockCabinet.getCabinetId(), "逐渐id不能为空!");
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return updateById(isLockCabinet);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|