1.修改门禁卡输入空不能提交到bug
This commit is contained in:
gaoben 2021-11-08 11:26:59 +08:00
parent 40c2da9d96
commit 4d60ca38aa
3 changed files with 52 additions and 40 deletions

View File

@ -141,6 +141,9 @@ public class SysRoleController extends AbstractController {
//ValidatorUtils.validateEntity(role); //ValidatorUtils.validateEntity(role);
role.setCreateBy(getUser().getNickName()); role.setCreateBy(getUser().getNickName());
role.setCreateTime(new Date()); role.setCreateTime(new Date());
if(role.getRoleName().length()>32){
return R.error("角色名称太长");
}
sysRoleService.saveRole(role); sysRoleService.saveRole(role);
return R.ok(); return R.ok();

View File

@ -433,7 +433,11 @@ public class TenPersonController extends AbstractController {
return R.error("卡号已录入"); return R.error("卡号已录入");
} }
} }
}else{ }
else if(tenPerson.getDoorCardEntity().getDoorCard().trim().equals("")){
}
else{
tenPerson.setDoorCardEntity(null); tenPerson.setDoorCardEntity(null);
} }

View File

@ -1099,49 +1099,54 @@ public class TenPersonServiceImpl implements TenPersonService {
} }
if (entity.getDoorCardEntity() != null) { if (entity.getDoorCardEntity() != null) {
// TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper<TenDoorCardEntity>() if(entity.getDoorCardEntity().getDoorCard().trim().length()>0){
// .eq("person_id", entity.getPersonId())); // TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper<TenDoorCardEntity>()
// .eq("person_id", entity.getPersonId()));
List<TenDoorCardEntity> personDoorCardList = tenDoorCardService.list( List<TenDoorCardEntity> personDoorCardList = tenDoorCardService.list(
new QueryWrapper<TenDoorCardEntity>() new QueryWrapper<TenDoorCardEntity>()
.eq("person_id",entity.getPersonId()) .eq("person_id",entity.getPersonId())
); );
for(TenDoorCardEntity cardEntity: personDoorCardList){ for(TenDoorCardEntity cardEntity: personDoorCardList){
tenDoorCardService.removeById(cardEntity.getDoorCardId()); tenDoorCardService.removeById(cardEntity.getDoorCardId());
} }
TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper<TenDoorCardEntity>()
.eq("door_card",entity.getDoorCardEntity().getDoorCard())
.eq("cell_id",entity.getCellId()));
if(oldCard==null){
// //增加
TenDoorCardEntity newCard = new TenDoorCardEntity();
newCard.setPersonId(entity.getPersonId());
if (entity.getDoorCardEntity().getValidBegin() == null) {
newCard.setValidBegin(new Date());
} else {
newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin());
}
if (entity.getDoorCardEntity().getValidEnd() == null) {
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);//设置起时间
cal.add(Calendar.YEAR, 10);//增加一年
// System.out.println("输出::"+cal.getTime());
newCard.setValidEnd(cal.getTime());
} else {
newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd());
}
// newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin());
// newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd());
newCard.setCellId(entity.getCellId());
newCard.setDoorCard(entity.getDoorCardEntity().getDoorCard());
Date now = new Date();
newCard.setCreateTime(now);
newCard.setLastUpdateTime(now);
tenDoorCardService.save(newCard);
}else{
TenDoorCardEntity oldCard = tenDoorCardService.getOne(new QueryWrapper<TenDoorCardEntity>()
.eq("door_card",entity.getDoorCardEntity().getDoorCard())
.eq("cell_id",entity.getCellId()));
if(oldCard==null){
// //增加
TenDoorCardEntity newCard = new TenDoorCardEntity();
newCard.setPersonId(entity.getPersonId());
if (entity.getDoorCardEntity().getValidBegin() == null) {
newCard.setValidBegin(new Date());
} else {
newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin());
} }
if (entity.getDoorCardEntity().getValidEnd() == null) {
Date date = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(date);//设置起时间
cal.add(Calendar.YEAR, 10);//增加一年
// System.out.println("输出::"+cal.getTime());
newCard.setValidEnd(cal.getTime());
} else {
newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd());
}
// newCard.setValidBegin(entity.getDoorCardEntity().getValidBegin());
// newCard.setValidEnd(entity.getDoorCardEntity().getValidEnd());
newCard.setCellId(entity.getCellId());
newCard.setDoorCard(entity.getDoorCardEntity().getDoorCard());
Date now = new Date();
newCard.setCreateTime(now);
newCard.setLastUpdateTime(now);
tenDoorCardService.save(newCard);
}else{ }else{
//删除卡号
tenDoorCardService.removeById(entity.getDoorCardEntity().getDoorCardId());
} }
// if (oldCard != null) { // if (oldCard != null) {