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; }