司机、站点、产品分类
parent
6de523c327
commit
ec68e8fc3e
|
|
@ -51,6 +51,6 @@ public class DriverServiceImpl extends ServiceImpl<DriverMapper, DriverEntity> i
|
|||
public PageResult<DriverEntity> paging(PageParam pageParam, DriverEntity driverEntity) {
|
||||
Page<DriverEntity> page = pageParam.toPage();
|
||||
page.addOrder(OrderItem.desc("cd.create_time"));
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.<DriverEntity>query(driverEntity)));
|
||||
return PageResult.of(baseMapper.paging(pageParam.toPage(), Wrappers.query(driverEntity)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package com.njzscloud.dispose.cst.station.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njzscloud.dispose.common.pojo.entity.BaseEntity;
|
||||
import com.njzscloud.dispose.cst.org.pojo.entity.OrgEntity;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
|
@ -82,5 +84,11 @@ public class StationEntity extends BaseEntity {
|
|||
* 纬度
|
||||
*/
|
||||
private Double lat;
|
||||
|
||||
/**
|
||||
* 关联组织信息(返回用)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private OrgEntity org;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
import com.njzscloud.dispose.cst.org.pojo.entity.OrgEntity;
|
||||
import com.njzscloud.dispose.cst.org.service.OrgService;
|
||||
import com.njzscloud.dispose.cst.station.mapper.StationMapper;
|
||||
import com.njzscloud.dispose.cst.station.pojo.entity.StationEntity;
|
||||
import com.njzscloud.dispose.cst.station.service.StationService;
|
||||
|
|
@ -13,9 +15,13 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 站点信息
|
||||
*
|
||||
* @author ljw
|
||||
*/
|
||||
@Slf4j
|
||||
|
|
@ -23,31 +29,65 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
public class StationServiceImpl extends ServiceImpl<StationMapper, StationEntity> implements StationService {
|
||||
|
||||
private final OrgService orgService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void add(StationEntity stationEntity) {
|
||||
OrgEntity org = stationEntity.getOrg();
|
||||
orgService.save(org);
|
||||
stationEntity.setOrgId(org.getId());
|
||||
this.save(stationEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void modify(StationEntity stationEntity) {
|
||||
orgService.updateById(stationEntity.getOrg());
|
||||
this.updateById(stationEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void del(List<Long> ids) {
|
||||
List<StationEntity> stations = this.listByIds(ids);
|
||||
this.removeBatchByIds(ids);
|
||||
List<Long> orgIds = stations.stream()
|
||||
.map(StationEntity::getOrgId)
|
||||
.filter(Objects::nonNull).toList();
|
||||
if (!orgIds.isEmpty()) {
|
||||
orgService.removeBatchByIds(orgIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public StationEntity detail(Long id) {
|
||||
return this.getById(id);
|
||||
StationEntity station = this.getById(id);
|
||||
if (station != null && station.getOrgId() != null) {
|
||||
station.setOrg(orgService.getById(station.getOrgId()));
|
||||
}
|
||||
return station;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<StationEntity> paging(PageParam pageParam, StationEntity stationEntity) {
|
||||
return PageResult.of(this.page(pageParam.toPage(), Wrappers.<StationEntity>query(stationEntity)));
|
||||
PageResult<StationEntity> page = PageResult.of(this.page(pageParam.toPage(), Wrappers.query(stationEntity)));
|
||||
List<StationEntity> records = page.getRecords();
|
||||
if (records.isEmpty()) {
|
||||
return page;
|
||||
}
|
||||
List<Long> orgIds = records.stream()
|
||||
.map(StationEntity::getOrgId)
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
if (!orgIds.isEmpty()) {
|
||||
Map<Long, OrgEntity> orgMap = orgService.listByIds(orgIds).stream()
|
||||
.collect(Collectors.toMap(OrgEntity::getId, it -> it));
|
||||
records.forEach(station -> station.setOrg(orgMap.get(station.getOrgId())));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ spring:
|
|||
- /oss/**
|
||||
- /endpoint/reload
|
||||
- /permission/refresh_cache
|
||||
- /static/**
|
||||
- /**
|
||||
|
||||
oss:
|
||||
type: ali
|
||||
|
|
|
|||
Loading…
Reference in New Issue