|
|
@ -21,6 +21,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
@ -42,10 +43,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* 网格访问记录表 用户对网格访问的一个记录,只有在访问网格首页时才存储数据,一个用户一天对一个网格的访问只有一条记录 |
|
|
@ -165,16 +163,26 @@ public class GridVisitedServiceImpl extends BaseServiceImpl<GridVisitedDao, Grid |
|
|
|
gridVisitedDTO.setVisitTime(date); |
|
|
|
gridVisitedDTO.setUpdatedTime(date); |
|
|
|
//查询是否存在历史数据( 一个用户一天对一个网格只存在一条访问记录)
|
|
|
|
GridVisitedDTO dto = baseDao.selectGridVisitedByGridIdAndUserId(gridVisitedDTO); |
|
|
|
List<GridVisitedDTO> dto = baseDao.selectGridVisitedByGridIdAndUserId(gridVisitedDTO); |
|
|
|
GridVisitedEntity entity = null; |
|
|
|
if (dto == null || dto.getId() == null) { |
|
|
|
boolean result = false; |
|
|
|
if(null == dto || dto.size() <= NumConstant.ZERO){ |
|
|
|
entity = ConvertUtils.sourceToTarget(gridVisitedDTO, GridVisitedEntity.class); |
|
|
|
return insert(entity); |
|
|
|
} else { |
|
|
|
dto.setUpdatedBy(visitedFormDTO.getUserId()); |
|
|
|
dto.setUpdatedTime(date); |
|
|
|
return BaseServiceImpl.retBool(gridVisitedDao.updateByVisitedId(dto)); |
|
|
|
}else{ |
|
|
|
dto.get(NumConstant.ZERO).setUpdatedBy(visitedFormDTO.getUserId()); |
|
|
|
dto.get(NumConstant.ZERO).setUpdatedTime(date); |
|
|
|
result = BaseServiceImpl.retBool(gridVisitedDao.updateByVisitedId(dto.get(NumConstant.ZERO))); |
|
|
|
if(dto.size() > NumConstant.ONE){ |
|
|
|
List<String> ids = new LinkedList<>(); |
|
|
|
dto.subList(NumConstant.ONE,dto.size()).forEach(obj -> { |
|
|
|
ids.add(obj.getId()); |
|
|
|
}); |
|
|
|
baseDao.deleteBatch(ids); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|