SQL Group问题

This commit is contained in:
wanggeng 2022-11-23 18:51:44 +08:00
parent a4e04fb19e
commit 1f5b67b4f5
3 changed files with 102 additions and 90 deletions

View File

@ -175,7 +175,7 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
@Override
public List<VenuesInfoDTO> listVenuesInfo(Map<String, Object> params) throws SearchException {
setDataAuthorityInfo(params);
params.put("creator",securityComponent.getCurrentUser().getUserId());
params.put("creator", securityComponent.getCurrentUser().getUserId());
return venuesInfoDao.listVenuesInfo(params);
}
@ -183,7 +183,7 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
public SuccessResultList<List<VenuesInfoDTO>> listPageVenuesInfo(ListPage page) throws SearchException {
setDataAuthorityInfo(page.getParams());
String creator = securityComponent.getCurrentUser().getUserId();
page.getParams().put("creator",creator);
page.getParams().put("creator", creator);
PageHelper.startPage(page.getPage(), page.getRows());
List<VenuesInfoDTO> venuesInfoDTOs = venuesInfoDao.listVenuesInfo(page.getParams());
PageInfo<VenuesInfoDTO> pageInfo = new PageInfo<>(venuesInfoDTOs);
@ -192,10 +192,10 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
@Override
public SuccessResultList<List<VenuesInfoDTO>> listPageVenuesInfoResources(ListPage page) {
PageHelper.startPage(page.getPage(),page.getRows());
PageHelper.startPage(page.getPage(), page.getRows());
List<VenuesInfoDTO> venuesInfoDTOs = venuesInfoDao.listVenuesInfo(page.getParams());
PageInfo<VenuesInfoDTO> pageInfo = new PageInfo<>(venuesInfoDTOs);
return new SuccessResultList<>(venuesInfoDTOs,pageInfo.getPageNum(),pageInfo.getTotal());
return new SuccessResultList<>(venuesInfoDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@Override
@ -203,11 +203,11 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
String projectCategory = StringUtils.isEmpty(params.get("categoryId").toString()) ? "" : params.get("categoryId").toString();
String venueCity = StringUtils.isEmpty(params.get("cityId").toString()) ? "" : params.get("cityId").toString();
String venueArea = StringUtils.isEmpty(params.get("areaId").toString()) ? "" : params.get("areaId").toString();
params.put("projectCategory",projectCategory);
params.put("venueCity",venueCity);
params.put("venueArea",venueArea);
params.put("projectCategory", projectCategory);
params.put("venueCity", venueCity);
params.put("venueArea", venueArea);
List<VenuesInfoDTO> list = venuesInfoDao.listVenuesByKeyWords(params);
for (VenuesInfoDTO item : list){
for (VenuesInfoDTO item : list) {
item.setVenuePanorama(item.getVenuePanorama().split(",")[0]);
}
return new SuccessResultData(list);
@ -215,59 +215,59 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
@Override
public Object getVenuesDetailById(String token, Map<String, Object> params) throws SearchException {
Map<String,Object> result = getHashMap(0);
if(StringUtils.isEmpty(params.get("venuesInfoId").toString())){
Map<String, Object> result = getHashMap(0);
if (StringUtils.isEmpty(params.get("venuesInfoId").toString())) {
return result;
}
//场馆列表
Map<String,Object> venuesInfo = venuesInfoDao.getVenuesInfoForWeChatProgram(params);
if (venuesInfo != null && venuesInfo.size() > 0){
venuesInfo.put("venueBanner",venuesInfo.get("venueBanner").toString().replaceAll(",",","));
Map<String, Object> venuesInfo = venuesInfoDao.getVenuesInfoForWeChatProgram(params);
if (venuesInfo != null && venuesInfo.size() > 0) {
venuesInfo.put("venueBanner", venuesInfo.get("venueBanner").toString().replaceAll(",", ","));
}
result.put("venueInfo",venuesInfo);
result.put("venueInfo", venuesInfo);
//所有项目
List<Map<String,Object>> projectList = venuesProjectDao.listVenuesProjectForWeChatProgram(params);
result.put("projectList",projectList);
List<Map<String, Object>> projectList = venuesProjectDao.listVenuesProjectForWeChatProgram(params);
result.put("projectList", projectList);
return result;
}
@Override
public Map<String, Object> getVenuesProjectDetailById(String token, Map<String, Object> params) {
Map<String,Object> result = getHashMap(0);
if(StringUtils.isEmpty(params.get("venuesProjectId").toString())){
Map<String, Object> result = getHashMap(0);
if (StringUtils.isEmpty(params.get("venuesProjectId").toString())) {
return result;
}
VenuesProjectDTO venuesProjectDTO = venuesProjectDao.getVenuesProjectDetailById(params);
result.put("venuesProjectInfo",venuesProjectDTO);
result.put("venuesProjectInfo", venuesProjectDTO);
//返回近三天的预定状态
List<Map<String, Object>> dayList = new ArrayList<>(0);
SimpleDateFormat sf = new SimpleDateFormat("M月d日");
String[] dayGroup = new String[]{DateUtil.getTime(),DateUtil.getAfterDayDate("1"),DateUtil.getAfterDayDate("2")};
for (int i = 0; i < dayGroup.length;i++) {
String[] dayGroup = new String[]{DateUtil.getTime(), DateUtil.getAfterDayDate("1"), DateUtil.getAfterDayDate("2")};
for (int i = 0; i < dayGroup.length; i++) {
Map<String, Object> dayMap = getHashMap(0);
dayMap.put("week",DateUtil.getAfterDayWeek(i + ""));
dayMap.put("dateFormat",sf.format(DateUtil.fomatDate(dayGroup[i])));
dayMap.put("date",dayGroup[i].substring(0,10));
dayMap.put("week", DateUtil.getAfterDayWeek(i + ""));
dayMap.put("dateFormat", sf.format(DateUtil.fomatDate(dayGroup[i])));
dayMap.put("date", dayGroup[i].substring(0, 10));
//判断是否可以预订
dayMap.put("bookingType","true");
if(i == 0){
dayMap.put("week","今天");
dayMap.put("bookingType", "true");
if (i == 0) {
dayMap.put("week", "今天");
}
dayList.add(dayMap);
}
result.put("dayList",dayList);
result.put("dayList", dayList);
return result;
}
@Override
public Object getCityInfoByName(Map<String, Object> param) throws SearchException {
String cityName = StringUtils.isEmpty(param.get("cityName").toString()) ? "" : param.get("cityName").toString();
param.put("cityName",cityName);
String cityName = StringUtils.isEmpty(param.get("cityName").toString()) ? "" : param.get("cityName").toString();
param.put("cityName", cityName);
return venuesInfoDao.getCityInfoByName(param);
}
@Override
public SuccessResultList<List<VenuesInfoDTO>> listPageVenuesInfoFroApp(String token,ListPage page) throws SearchException {
public SuccessResultList<List<VenuesInfoDTO>> listPageVenuesInfoFroApp(String token, ListPage page) throws SearchException {
Map<String, Object> params = page.getParams();
List<VenuesInfoDTO> venuesInfoDTOs;
@ -277,38 +277,34 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
// end
orderKye = orderKye.trim();
Point myPoint = setPoint(params);
//如果传入的定位来自于腾讯地图需要转换否则会导致距离计算出现1公里左右偏差
String selfLocation = params.get("selfLocation") == null ? "" : params.get("selfLocation").toString();
//String selfLocation = StringUtils.isEmpty(params.get("selfLocation").toString()) ? "" : params.get("selfLocation").toString();
if(MAP_TYPE_TX.equals(selfLocation)
if (MAP_TYPE_TX.equals(selfLocation)
&& myPoint.getX() == 0
&& myPoint.getY() == 0){
&& myPoint.getY() == 0) {
MapLocationTransformUtil util = new MapLocationTransformUtil();
myPoint = util.map_tx2bd(myPoint);
}
//按热度查询
if(VENUE_SEARCH_HOT.equals(orderKye)){
if (VENUE_SEARCH_HOT.equals(orderKye)) {
//TODO 访问量功能实现后添加
}
//根据定位排序
if(VENUE_SEARCH_APART.equals(orderKye)){
if (VENUE_SEARCH_APART.equals(orderKye)) {
VenuesListSingleData venuesListSingleData = VenuesListSingleData.getInstance();
//venuesInfoDTOs = venuesListSingleData.getVenuesList(venuesInfoDao,params);
venuesInfoDTOs = venuesInfoDao.listVenuesByKeyWords(params);
formatPosition(myPoint,venuesInfoDTOs);
formatPosition(myPoint, venuesInfoDTOs);
pointListCompareToAse(venuesInfoDTOs);
List<VenuesInfoDTO> subList = venuesInfoDTOs.subList(0,venuesInfoDTOs.size() > 10 ? 10 : venuesInfoDTOs.size());
return new SuccessResultList<>(subList, page.getPage(), Long.parseLong(subList.size()+ ""));
List<VenuesInfoDTO> subList = venuesInfoDTOs.subList(0, venuesInfoDTOs.size() > 10 ? 10 : venuesInfoDTOs.size());
return new SuccessResultList<>(subList, page.getPage(), Long.parseLong(subList.size() + ""));
}
PageHelper.startPage(page.getPage(), page.getRows());
venuesInfoDTOs = venuesInfoDao.listVenuesByKeyWords(page.getParams());
formatPosition(myPoint,venuesInfoDTOs);
formatPosition(myPoint, venuesInfoDTOs);
PageInfo<VenuesInfoDTO> pageInfo = new PageInfo<>(venuesInfoDTOs);
return new SuccessResultList<>(venuesInfoDTOs, pageInfo.getPageNum(), pageInfo.getTotal());
}
@ -319,17 +315,17 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
List<VenuesInfoMiniAppVO> venuesInfoMiniAppVOS;
PageHelper.startPage(page.getPage(), page.getRows());
venuesInfoMiniAppVOS = venuesInfoDao.listPageVenuesInfoApp(params);
for (VenuesInfoMiniAppVO item : venuesInfoMiniAppVOS){
for (VenuesInfoMiniAppVO item : venuesInfoMiniAppVOS) {
//查询区域名
AreaDTO areaDTO = dataAreaService.get(item.getVenueArea());
item.setVenueArea(areaDTO.getAreaName());
//查询项目
params.put("venuesInfoId",item.getVenuesInfoId());
params.put("venuesInfoId", item.getVenuesInfoId());
List<VenuesProjectV2DTO> venuesProjectV2DTOS = venuesProjectV2Service.listProject(params);
String sb = "";
for ( int i = 0 ; i < venuesProjectV2DTOS.size(); i++){
if(i >= 3){
sb = sb.substring(0,sb.length() - 1);
for (int i = 0; i < venuesProjectV2DTOS.size(); i++) {
if (i >= 3) {
sb = sb.substring(0, sb.length() - 1);
break;
}
sb += venuesProjectV2DTOS.get(i).getProjectName() + ',';
@ -339,10 +335,10 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
String price = groundInfoService.getMinBookingPriceByVenuesInfoId(params);
item.setMinBookingPrice(price == null ? "" : price);
//处理距离
if(StringUtils.isEmpty(params.get("longitude").toString())
if (StringUtils.isEmpty(params.get("longitude").toString())
|| StringUtils.isEmpty(params.get("latitude").toString())
|| StringUtils.isEmpty(item.getLongitude())
|| StringUtils.isEmpty(item.getLatitude())){
|| StringUtils.isEmpty(item.getLatitude())) {
item.setApart("");
continue;
} else {
@ -352,7 +348,7 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
Point targetPoint = new Point();
targetPoint.setX(Double.parseDouble(item.getLatitude()));
targetPoint.setY(Double.parseDouble(item.getLongitude()));
item.setApart(formatPosition(myPoint,targetPoint));
item.setApart(formatPosition(myPoint, targetPoint));
}
}
@ -363,10 +359,10 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
@Override
public SuccessResultData<List<VenuesInfoDTO>> listRangeVenuesInfo(Map<String, Object> params) {
VenuesListSingleData venuesListSingleData = VenuesListSingleData.getInstance();
List<VenuesInfoDTO> venuesInfoDTOs = venuesListSingleData.getVenuesList(venuesInfoDao,params);
List<VenuesInfoDTO> venuesInfoDTOs = venuesListSingleData.getVenuesList(venuesInfoDao, params);
String venueType = params.get("venueType") == null ? "" : params.get("venueType").toString();
List<VenuesInfoDTO> screeningResult = new ArrayList<>();
if(!"".equals(venueType)){
if (!"".equals(venueType)) {
for (VenuesInfoDTO item : venuesInfoDTOs) {
if (venueType.equals(item.getVenueType())) {
screeningResult.add(item);
@ -375,7 +371,7 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
} else {
screeningResult.addAll(venuesInfoDTOs);
}
if(params.get("range") == null){
if (params.get("range") == null) {
return new SuccessResultData(screeningResult);
}
double range = Double.parseDouble(params.get("range").toString());
@ -383,10 +379,10 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
Point myPoint = setPoint(params);
formatPosition(myPoint, screeningResult);
List<VenuesInfoDTO> rangeList = new ArrayList<>();
if(screeningResult != null && screeningResult.size() > 0){
for (VenuesInfoDTO item : screeningResult){
if (screeningResult != null && screeningResult.size() > 0) {
for (VenuesInfoDTO item : screeningResult) {
apart = Double.parseDouble(item.getApart());
if(apart <= range){
if (apart <= range) {
rangeList.add(item);
}
}
@ -396,45 +392,47 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
/**
* 计算距离
*
* @param list
*/
private void formatPosition(Point myPoint, List<VenuesInfoDTO> list){
private void formatPosition(Point myPoint, List<VenuesInfoDTO> list) {
Point point = new Point();
for (VenuesInfoDTO item : list){
if(myPoint.getX() == 0 && myPoint.getY() == 0){
for (VenuesInfoDTO item : list) {
if (myPoint.getX() == 0 && myPoint.getY() == 0) {
item.setApart("0");
continue;
}
if(StringUtils.isEmpty(item.getLongitude())
&& StringUtils.isEmpty(item.getLatitude())){
if (StringUtils.isEmpty(item.getLongitude())
&& StringUtils.isEmpty(item.getLatitude())) {
item.setApart("0");
continue;
}
point.setX(Double.parseDouble(item.getLatitude()));
point.setY(Double.parseDouble(item.getLongitude()));
double lineApart = PointUtil.getDistance(myPoint,point);
double lineApart = PointUtil.getDistance(myPoint, point);
BigDecimal bg = new BigDecimal(lineApart);
item.setApart(bg.setScale(2,BigDecimal.ROUND_HALF_UP).toString());
item.setApart(bg.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
}
}
private String formatPosition(Point myPoint, Point targetPoint){
double lineApart = PointUtil.getDistance(myPoint,targetPoint);
private String formatPosition(Point myPoint, Point targetPoint) {
double lineApart = PointUtil.getDistance(myPoint, targetPoint);
BigDecimal bg = new BigDecimal(lineApart);
return bg.setScale(2,BigDecimal.ROUND_HALF_UP).toString();
return bg.setScale(2, BigDecimal.ROUND_HALF_UP).toString();
}
/**
* 距离排序
*
* @param list
*/
private void pointListCompareToAse(List<VenuesInfoDTO> list){
private void pointListCompareToAse(List<VenuesInfoDTO> list) {
Collections.sort(list, new Comparator<VenuesInfoDTO>() {
@Override
public int compare(VenuesInfoDTO o1, VenuesInfoDTO o2) {
double apart1 = Double.parseDouble(o1.getApart());
double apart2 = Double.parseDouble(o2.getApart());
if(apart1 == apart2){
if (apart1 == apart2) {
return 0;
}
return apart1 > apart2 ? 1 : -1;
@ -442,11 +440,13 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
});
}
private Point setPoint(Map<String, Object> params){
double longitude = NO_POINT.equals(params.get(VENUE_SEARCH_LONGITUDE).toString()) ?
0 : Double.parseDouble(params.get(VENUE_SEARCH_LONGITUDE).toString());
double latitude = NO_POINT.equals(params.get(VENUE_SEARCH_LATITUDE).toString()) ?
0 : Double.parseDouble(params.get(VENUE_SEARCH_LATITUDE).toString());
private Point setPoint(Map<String, Object> params) {
Object longitudeObj = params.get(VENUE_SEARCH_LONGITUDE);
Object latitudeObj = params.get(VENUE_SEARCH_LATITUDE);
double longitude = longitudeObj == null || NO_POINT.equals(longitudeObj.toString()) ?
0 : Double.parseDouble(longitudeObj.toString());
double latitude = latitudeObj == null || NO_POINT.equals(latitudeObj.toString()) ?
0 : Double.parseDouble(latitudeObj.toString());
Point Point = new Point();
Point.setX(latitude);
Point.setY(longitude);
@ -456,26 +456,27 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
/**
* 后台-场馆zTree
* 有数据权限校验
*
* @return 返回场馆zTree集合
*/
@Override
public List<ZTreeDTO> listVenuesInfoZTree() {
Map<String, Object> params = getHashMap(16);
setDataAuthorityInfo(params);
params.put("creator",securityComponent.getCurrentUser().getUserId());
params.put("creator", securityComponent.getCurrentUser().getUserId());
List<VenuesInfoDTO> venuesInfoDTO = venuesInfoDao.listVenuesInfo(params);
List<ZTreeDTO> zTreeDTOs = new ArrayList<>();
for (VenuesInfoDTO item : venuesInfoDTO){
for (VenuesInfoDTO item : venuesInfoDTO) {
ZTreeDTO zTreeDTO = new ZTreeDTO();
zTreeDTO.setName(item.getVenueName());
if("arrive".equals(item.getVenueCharge())){
if ("arrive".equals(item.getVenueCharge())) {
zTreeDTO.setName(item.getVenueName() + "(直接到场)");
zTreeDTO.setTarget(item.getVenueCharge());
}
if("booking".equals(item.getVenueCharge())){
if ("booking".equals(item.getVenueCharge())) {
zTreeDTO.setName(item.getVenueName());
}
if("ticket".equals(item.getVenueCharge())){
if ("ticket".equals(item.getVenueCharge())) {
zTreeDTO.setName(item.getVenueName());
}
zTreeDTO.setpId("0");
@ -488,19 +489,19 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
@Override
public VenuesInfoDTO getVenuesInfoByIdForApp(String token, Map<String, Object> param) throws SearchException {
VenuesInfoDTO venuesInfoDTO = venuesInfoDao.getVenuesInfoForApp(param);
if(venuesInfoDTO == null){
if (venuesInfoDTO == null) {
return new VenuesInfoDTO();
}
//查询是否有项目信息
venuesInfoDTO.setHasProject("0");
param.put("venuesInfoId",venuesInfoDTO.getVenuesInfoId());
param.put("venuesInfoId", venuesInfoDTO.getVenuesInfoId());
List<VenuesProjectDTO> projectList = venuesProjectDao.listVenuesProject(param);
if(projectList != null && projectList.size() > 0){
if (projectList != null && projectList.size() > 0) {
venuesInfoDTO.setHasProject("1");
}
String resultLocation = param.get("resultLocation") == null ? "" : param.get("resultLocation").toString();
//返回的场馆定位需要转换为腾讯地图坐标
if(MAP_TYPE_TX.equals(resultLocation)){
if (MAP_TYPE_TX.equals(resultLocation)) {
Point point = new Point();
MapLocationTransformUtil util = new MapLocationTransformUtil();
point.setX(Double.parseDouble(venuesInfoDTO.getLatitude()));
@ -513,17 +514,17 @@ public class VenuesInfoServiceImpl extends DefaultBaseService implements IVenues
}
@Override
public SuccessResult saveEntranceTicket(EntranceTicketDTO entranceTicketDTO) throws Exception{
Map<String,Object> param= HashMapUtil.beanToMap(entranceTicketDTO);
public SuccessResult saveEntranceTicket(EntranceTicketDTO entranceTicketDTO) throws Exception {
Map<String, Object> param = HashMapUtil.beanToMap(entranceTicketDTO);
String entranceTicketId = UUIDUtil.get32UUID();
param.put("entranceTicketId",entranceTicketId);
param.put("entranceTicketId", entranceTicketId);
setSaveInfo(param);
venuesInfoDao.saveEntranceTicket(param);
return new SuccessResult();
}
@Override
public SuccessResult updateEntranceTicket(EntranceTicketDTO entranceTicketDTO) throws Exception{
public SuccessResult updateEntranceTicket(EntranceTicketDTO entranceTicketDTO) throws Exception {
Map<String, Object> param = HashMapUtil.beanToMap(entranceTicketDTO);
setUpdateInfo(param);
venuesInfoDao.updateEntranceTicket(param);

View File

@ -482,12 +482,21 @@
t1.is_delete = 0
AND t1.venues_info_id = #{venuesInfoId}
GROUP BY
t1.venues_info_id,
t1.venue_charge,
t1.venue_panorama,
t1.venue_plan,
t1.venue_name,
t1.venue_position,
t1.longitude,
t1.latitude,
t1.venue_telephone,
t1.venue_route,
t1.venue_other_service
t1.venue_position,
t2.dictionary_name,
t1.venue_other_service,
t1.venue_description,
t1.business_hours,
t1.booking_tips
</select>
</mapper>

View File

@ -270,7 +270,9 @@
t1.venues_project_id,
t1.venue_id,
t1.project_category,
t2.data_name,
t1.business_hours,
t1.project_description
t1.project_description,
t3.data_name
</select>
</mapper>