From fb3059d13187b35f2b3613665e06065f3f736b47 Mon Sep 17 00:00:00 2001 From: cuibaocheng Date: Wed, 5 May 2021 13:44:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BE=E7=89=87=E5=A5=97=E7=89=88=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DistributionServiceImpl.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java b/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java index db7b249..1cb17a4 100644 --- a/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java +++ b/src/main/java/cn/com/tenlion/service/examination/distribution/impl/DistributionServiceImpl.java @@ -27,6 +27,9 @@ import org.apache.commons.collections.map.HashedMap; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.*; /** @@ -175,7 +178,21 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist setAppUpdateInfo(token, params); } if(StringUtils.isEmpty(distributionVO.getDistributionAllotTime())) { - throw new UpdateException("需要确定最终分配时间"); + throw new UpdateException("需要确定最终开始时间"); + } + if(StringUtils.isEmpty(distributionVO.getDistributionAllotEndTime())) { + throw new UpdateException("需要确定最终结束时间"); + } + try { + DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date startTime = fmt.parse(distributionVO.getDistributionAllotTime()); + Date endTime = fmt.parse(distributionVO.getDistributionAllotEndTime()); + long timeDelta = (startTime.getTime() - endTime.getTime()) /1000;//单位是秒 + if(timeDelta > (-1 * 60 * 60) ) { + throw new UpdateException("时间范围错误"); + } + }catch(Exception e) { + throw new UpdateException("时间范围格式错误"); } /** * 判断是否选择了考场 @@ -231,10 +248,12 @@ public class DistributionServiceImpl extends DefaultBaseService implements IDist /** * 回显考场 */ - Map query = new HashMap(); - query.put("distributionId",dto.getDistributionId()); - List dtoList= iDistributionFieldService.list(query); - dto.setDistributionFieldList(dtoList); + if(dto != null) { + Map query = new HashMap(); + query.put("distributionId",dto.getDistributionId()); + List dtoList= iDistributionFieldService.list(query); + dto.setDistributionFieldList(dtoList); + } return dto; }