新增教学场地校验编号的重复性
This commit is contained in:
+8
-1
@@ -6,6 +6,7 @@ import com.roomroot.common.utils.StringUtils;
|
|||||||
import com.roomroot.jwgl.entity.JSB;
|
import com.roomroot.jwgl.entity.JSB;
|
||||||
import com.roomroot.jwgl.mapper.ClassRoomMapper;
|
import com.roomroot.jwgl.mapper.ClassRoomMapper;
|
||||||
import com.roomroot.jwgl.service.ClassRoomService;
|
import com.roomroot.jwgl.service.ClassRoomService;
|
||||||
|
import com.roomroot.jwgl.unit.BusinessException;
|
||||||
import com.roomroot.jwgl.unit.PageQuery;
|
import com.roomroot.jwgl.unit.PageQuery;
|
||||||
import com.roomroot.jwgl.unit.PageResult;
|
import com.roomroot.jwgl.unit.PageResult;
|
||||||
import com.roomroot.jwgl.utils.UuidUtil;
|
import com.roomroot.jwgl.utils.UuidUtil;
|
||||||
@@ -27,11 +28,17 @@ public class ClassRoomServiceImpl implements ClassRoomService {
|
|||||||
public void add(JSB jsb) {
|
public void add(JSB jsb) {
|
||||||
jsb.setId(UuidUtil.getUUID());
|
jsb.setId(UuidUtil.getUUID());
|
||||||
jsb.setDelFlag(0);
|
jsb.setDelFlag(0);
|
||||||
// 教室编号为非空列:留空时按现有最大数字编号 +1 自动生成
|
// 教室编号为非空列:留空时按现有最大数字编号 +1 自动生成;手填时校验唯一,避免按编号查询出现多行
|
||||||
if (StringUtils.isEmpty(jsb.getJsbh())) {
|
if (StringUtils.isEmpty(jsb.getJsbh())) {
|
||||||
jsb.setJsbh(nextJsbh());
|
jsb.setJsbh(nextJsbh());
|
||||||
} else {
|
} else {
|
||||||
jsb.setJsbh(jsb.getJsbh().trim());
|
jsb.setJsbh(jsb.getJsbh().trim());
|
||||||
|
Long dup = jsbMapper.selectCount(new LambdaQueryWrapper<JSB>()
|
||||||
|
.eq(JSB::getJsbh, jsb.getJsbh())
|
||||||
|
.eq(JSB::getDelFlag, 0));
|
||||||
|
if (dup != null && dup > 0) {
|
||||||
|
throw new BusinessException("教室编号已存在:" + jsb.getJsbh());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
jsbMapper.insert(jsb);
|
jsbMapper.insert(jsb);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-1
@@ -407,7 +407,12 @@ public class ElectiveServiceImpl implements ElectiveService {
|
|||||||
}
|
}
|
||||||
JSB room = classRoomMapper.selectById(zyjsbh);
|
JSB room = classRoomMapper.selectById(zyjsbh);
|
||||||
if (room == null) {
|
if (room == null) {
|
||||||
room = classRoomMapper.selectOne(new LambdaQueryWrapper<JSB>().eq(JSB::getJsbh, zyjsbh));
|
// 教室编号历史上可能出现重复行,取第一条避免 selectOne 多结果异常
|
||||||
|
List<JSB> rooms = classRoomMapper.selectList(new LambdaQueryWrapper<JSB>()
|
||||||
|
.eq(JSB::getJsbh, zyjsbh)
|
||||||
|
.eq(JSB::getDelFlag, 0)
|
||||||
|
.last("LIMIT 1"));
|
||||||
|
room = rooms.isEmpty() ? null : rooms.get(0);
|
||||||
}
|
}
|
||||||
return room == null ? null : room.getJsmc();
|
return room == null ? null : room.getJsmc();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user