|
@@ -7,6 +7,7 @@ import com.gis.common.util.AliyunOssUtil;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.domain.dto.ExhibitionDto;
|
|
|
import com.gis.domain.dto.PageDto;
|
|
|
+import com.gis.domain.dto.TypePageDto;
|
|
|
import com.gis.domain.po.ExhibitionEntity;
|
|
|
import com.gis.domain.po.FileEntity;
|
|
|
import com.gis.mapper.ExhibitionMapper;
|
|
@@ -14,6 +15,7 @@ import com.gis.mapper.IBaseMapper;
|
|
|
import com.gis.service.ExhibitionService;
|
|
|
import com.gis.service.FileService;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,6 +24,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import tk.mybatis.mapper.entity.Condition;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -29,8 +33,9 @@ import java.util.Map;
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * Created by owen on 2020/3/11 0011 16:16
|
|
|
+ * Created by owen on 2021/6/18 0011 16:16
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Long> implements ExhibitionService {
|
|
|
|
|
@@ -55,7 +60,7 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Result<ExhibitionEntity> search(PageDto param) {
|
|
|
+ public Result<ExhibitionEntity> search(TypePageDto param) {
|
|
|
Condition condition = new Condition(ExhibitionEntity.class);
|
|
|
String searchKey = param.getSearchKey();
|
|
|
if (StringUtils.isNotBlank(searchKey)) {
|
|
@@ -68,6 +73,10 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
// if (StringUtils.isNotBlank(startTime) && StringUtils.isNotBlank(endTime) ) {
|
|
|
// condition.and().andBetween("createTime", startTime, endTime);
|
|
|
// }
|
|
|
+ String type = param.getType();
|
|
|
+ if (StringUtils.isNotBlank(type)) {
|
|
|
+ condition.and().andEqualTo("status", type);
|
|
|
+ }
|
|
|
|
|
|
condition.orderBy("createTime").desc();
|
|
|
PageInfo<ExhibitionEntity> pageInfo = this.findAll(condition, param.getPageNum(), param.getPageSize());
|
|
@@ -89,7 +98,7 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
return Result.failure("对象不存在: " + id);
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, entity);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
this.update(entity);
|
|
|
}
|
|
|
|
|
@@ -121,7 +130,7 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
public Result upload(MultipartFile file, String code) {
|
|
|
|
|
|
if (StringUtils.isBlank(code)) {
|
|
|
- code = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
|
|
|
+ code = DateUtil.format(LocalDateTime.now(), "yyyyMMdd_HHmmssSSS");
|
|
|
}
|
|
|
|
|
|
Map<String, Object> result = aliyunOssUtil.uploadByByte(file, "exhibition/" + code + "/");
|
|
@@ -142,7 +151,7 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
return Result.success();
|
|
|
}
|
|
|
entity.setIsDelete(1);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
this.update(entity);
|
|
|
|
|
|
return Result.success();
|
|
@@ -157,7 +166,7 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
|
|
|
entity.setIsDelete(1);
|
|
|
entity.setIsIndex(0);
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
fileService.update(entity);
|
|
|
return Result.success();
|
|
|
}
|
|
@@ -187,5 +196,54 @@ public class ExhibitionServiceImpl extends IBaseServiceImpl<ExhibitionEntity, Lo
|
|
|
return Result.success(result);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void checkStatus() {
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
+ // 查询未开始、开始中的数据
|
|
|
+ Condition condition = new Condition(ExhibitionEntity.class);
|
|
|
+ condition.and().andEqualTo("status", "unstart");
|
|
|
+ condition.and().andEqualTo("status", "start");
|
|
|
+ List<ExhibitionEntity> allList = this.findAll(condition);
|
|
|
+ log.info("需要检查状态的数据数量: {}", allList.size());
|
|
|
+ for (ExhibitionEntity entity : allList) {
|
|
|
+ String status = entity.getStatus();
|
|
|
+
|
|
|
+ // 未开始
|
|
|
+ boolean flag = false;
|
|
|
+ if ("unstart".equals(status)) {
|
|
|
+ LocalDateTime startTime = entity.getStartTime();
|
|
|
+ if (startTime == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 活动开始:开始时间 < 当前时间
|
|
|
+ boolean before = startTime.isBefore(now);
|
|
|
+ if (before) {
|
|
|
+ entity.setStatus("start");
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ log.info("开始时间:{}, 当前时间:{}, 状态:{}", startTime, now, entity.getStatus());
|
|
|
+
|
|
|
+ // 已开始
|
|
|
+ } else if ("start".equals(status)) {
|
|
|
+ LocalDateTime endTime = entity.getEndTime();
|
|
|
+ if (endTime == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 活动结束: 结束时间 < 当前时间
|
|
|
+ boolean before = endTime.isBefore(now);
|
|
|
+ if (before) {
|
|
|
+ entity.setStatus("end");
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+ log.info("结束时间:{}, 当前时间:{}, 状态:{}", endTime, now, entity.getStatus());
|
|
|
+ }
|
|
|
+ if (flag) {
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
+ this.update(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("状态检查完成");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|