增加单日行程规划单查询接口

This commit is contained in:
lulz1 2024-04-29 14:04:17 +08:00
parent 8df5cd172b
commit ff2e9518b4
13 changed files with 160 additions and 23 deletions

View File

@ -0,0 +1,19 @@
package com.chint.application.dtos;
import lombok.Data;
import java.util.List;
@Data
public class RoutOrderFieldParam {
private Integer pageNum;
private Integer pageSize;
private List<extensionField> extensionFieldList;
private String queryDate;
@Data
public static class extensionField {
private String fieldName;
private String fieldValue;
}
}

View File

@ -0,0 +1,31 @@
package com.chint.application.dtos.mapper;
import cn.hutool.core.bean.BeanUtil;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.value_object.RouteOrderFiledVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
public class RouteOrderMapper {
@Autowired
private UserRepository userRepository;
public RouteOrderFiledVO mapToFiledVO(RouteOrder routeOrder) {
RouteOrderFiledVO routeOrderFiledVO = BeanUtil.copyProperties(routeOrder, RouteOrderFiledVO.class);
List<RouteOrderFiledVO.RouteOrderExtensionFiled> routeOrderExtensionFileds = routeOrder
.getRouteCustomExtensionFieldList()
.stream()
.map(it -> BeanUtil.copyProperties(it, RouteOrderFiledVO.RouteOrderExtensionFiled.class))
.toList();
routeOrderFiledVO.setRouteCustomExtensionFieldList(routeOrderExtensionFileds);
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(routeOrderFiledVO.getUserId());
routeOrderFiledVO.setUserName(byUserEmployeeNo.getName());
return routeOrderFiledVO;
}
}

View File

@ -1,6 +1,7 @@
package com.chint.application.out;
import com.chint.application.dtos.RoutOrderFieldParam;
import com.chint.application.dtos.response.LegRes;
import com.chint.application.dtos.response.RouteOrderPageRes;
import com.chint.application.dtos.response.RouteOrderRes;
@ -40,6 +41,7 @@ public class OrderOutController {
@Autowired
private UserRepository userRepository;
@Autowired
private OrderDomainService orderDomainService;
@ -115,9 +117,6 @@ public class OrderOutController {
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
}
@ApiOperation("查询能够同步的行程节点")
@PostMapping("/query/legs")
public Result<List<LegRes>> queryLegs(@RequestBody OrderQueryData queryData) {
@ -129,4 +128,11 @@ public class OrderOutController {
return Result.Success(SUCCESS, legResList);
}
@ApiOperation("查询单日行程规划单")
@PostMapping("/query/route/filed")
public Result<PageResult<RouteOrderFiledVO>> queryRoutOrderField(@RequestBody RoutOrderFieldParam param) {
return Result.Success(SUCCESS, orderQuery.queryRouteOrderFiled(param));
}
}

View File

@ -1,14 +1,17 @@
package com.chint.application.queryies;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.RoutOrderFieldParam;
import com.chint.application.dtos.response.*;
import com.chint.application.dtos.trip.*;
import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.queryies.estimate.EstimatePrice;
import com.chint.domain.aggregates.location.basedata.CountryLevelInfoEntity;
import com.chint.domain.aggregates.location.basedata.DistrictPOIInfoEntity;
import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEntity;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.*;
import com.chint.domain.service.LegDomainService;
import com.chint.domain.service.OrderDomainService;
@ -18,6 +21,7 @@ import com.chint.infrastructure.cache.RouteCacheService;
import com.chint.infrastructure.constant.FSSCConstant;
import com.chint.infrastructure.constant.LegConstant;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.DateTimeUtil;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.user.UserHttpRequest;
@ -27,10 +31,7 @@ import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -55,6 +56,9 @@ public class OrderQuery {
@Autowired
private CityRepository cityRepository;
@Autowired
private RouteOrderMapper routeOrderMapper;
@Autowired
private EstimatePrice estimatePrice;
@ -575,4 +579,48 @@ public class OrderQuery {
})
.toList();
}
public PageResult<RouteOrderFiledVO> queryRouteOrderFiled(RoutOrderFieldParam param) {
String queryDate = param.getQueryDate();
if (queryDate == null) {
throw new NotFoundException("只支持查询一天的数据");
}
LocalDateTime startOfDay = DateTimeUtil.startOfDay(queryDate);
LocalDateTime endOfDay = DateTimeUtil.endOfDay(queryDate);
List<RouteOrder> routeOrders = routeRepository.queryAllInOneDayAndEffective(startOfDay, endOfDay);
List<RouteOrderFiledVO> routeOrderFiledVOList = routeOrders
.stream()
.filter(it -> {
boolean res = true;
List<RoutOrderFieldParam.extensionField> extensionFieldList = param.getExtensionFieldList();
if (extensionFieldList != null && !extensionFieldList.isEmpty()) {
for (RoutOrderFieldParam.extensionField paramExtensionField : extensionFieldList) {
List<RouteCustomExtensionField> routeCustomExtensionFieldList = it.getRouteCustomExtensionFieldList();
if (routeCustomExtensionFieldList != null && !routeCustomExtensionFieldList.isEmpty()) {
Optional<RouteCustomExtensionField> first = routeCustomExtensionFieldList.stream()
.filter(routeExtensionField -> routeExtensionField.getFieldName().equals(paramExtensionField.getFieldName()))
.findFirst();
res = first
.map(routeCustomExtensionField -> routeCustomExtensionField.getFieldValue()
.equals(paramExtensionField.getFieldValue()))
.orElse(false);
} else {
res = false;
}
}
}
return res;
})
.map(routeOrderMapper::mapToFiledVO).toList();
int size = routeOrderFiledVOList.size();
if (param.getPageSize() != null && param.getPageNum() != null) {
routeOrderFiledVOList = routeOrderFiledVOList.stream()
.skip((long) (param.getPageNum() - 1) * param.getPageSize())
.limit(param.getPageSize())
.toList();
}
return PageResult.totalPageNum(size, routeOrderFiledVOList);
}
}

View File

@ -5,6 +5,7 @@ import com.chint.domain.aggregates.order.ApprovalEvent;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.value_object.OrderSaveData;
import com.chint.domain.value_object.RouteOrderFiledVO;
import java.util.List;

View File

@ -5,6 +5,7 @@ import com.chint.application.commands.OrderCreateCommand;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.factoriy.leg.RouteLegFactory;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.value_object.LegData;
import com.chint.domain.value_object.OrderSaveData;
import com.chint.domain.value_object.UserLoginParam;
@ -23,6 +24,9 @@ public class RouteOrderFactory implements OrderFactory {
@Autowired
private RouteLegFactory routeLegFactory;
@Autowired
private UserRepository userRepository;
@Value("${chint.envMark}")
private String envMark;

View File

@ -11,6 +11,8 @@ import java.util.List;
public interface RouteRepository {
RouteOrder queryById(Long orderId);
List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end);
void deleteById(Long orderId);
RouteOrder findByFakeOrderNoAndSysCode(String fakeOrderNo, String sysCode);

View File

@ -22,4 +22,6 @@ public class OrderQueryData extends BaseQuery {
private String keywords;
@ApiModelProperty("供应商标识")
private String supplierName;
private String customFieldName;
private String customFieldValue;
}

View File

@ -24,5 +24,12 @@ public class RouteOrderFiledVO {
@Embedded.Nullable
private ApproveOrderNo approveOrderNo;
@ApiModelProperty("自定义字段")
private List<RouteCustomExtensionField> routeCustomExtensionFieldList;
private List<RouteOrderExtensionFiled> routeCustomExtensionFieldList;
@Data
public static class RouteOrderExtensionFiled {
private String fieldName;
private String fieldValue;
private String extension;
}
}

View File

@ -31,6 +31,11 @@ public class RouteRepositoryImpl implements RouteRepository {
return routeCacheService.getRouteById(orderId);
}
@Override
public List<RouteOrder> queryAllInOneDayAndEffective(LocalDateTime start, LocalDateTime end) {
return jdbcRouteRepository.findByCreateTimeBetweenAndApproveOrderNo_ActualOrderNoNotNull(start, end);
}
@Override
public void deleteById(Long orderId) {
jdbcRouteRepository.deleteById(orderId);
@ -45,7 +50,6 @@ public class RouteRepositoryImpl implements RouteRepository {
if (routeOrder == null) {
routeOrder = jdbcRouteRepository.findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(fakeOrderNo, sysCode);
}
// return jdbcRouteRepository.findByApproveOrderNo_FakeOrderNoAndApproveOrderNo_SysCode(fakeOrderNo, sysCode);
return routeOrder;
}
@ -55,7 +59,6 @@ public class RouteRepositoryImpl implements RouteRepository {
if (routeOrder == null) {
routeOrder = jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode);
}
// return jdbcRouteRepository.findByApproveOrderNo_ActualOrderNoAndApproveOrderNo_SysCode(actualOrderNo, sysCode);
return routeOrder;
}

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.RouteOrder;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@ -14,6 +15,7 @@ import java.util.List;
public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
Page<RouteOrder> findByCreateUser(String userId, Pageable pageable);
List<RouteOrder> findByCreateTimeBetweenAndApproveOrderNo_ActualOrderNoNotNull(LocalDateTime start, LocalDateTime end);
List<RouteOrder> findByUserId(String employeeNo);
@ -40,4 +42,9 @@ public interface JdbcRouteRepository extends CrudRepository<RouteOrder, Long> {
List<RouteOrder> findByCreateTimeBetween(LocalDateTime createTime, LocalDateTime createTime2);
Page<RouteOrder> findAllBy(PageRequest pageResult);
@Query("""
select * from route_order r1 left join route_custom_extension_field r2 on r1.route_id = r2.route_id where
""")
List<RouteOrder> findByField();
}

View File

@ -1,9 +1,6 @@
package com.chint.infrastructure.util;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.*;
import java.time.format.DateTimeFormatter;
public class DateTimeUtil {
@ -72,4 +69,13 @@ public class DateTimeUtil {
// 格式化日期时间
return lastMonthDateTime.format(formatterDateYYYYMM);
}
public static LocalDateTime startOfDay(String date) {
LocalDate parse = LocalDate.parse(date, formatterDate);
return LocalDateTime.of(parse, LocalTime.MIN);
}
public static LocalDateTime endOfDay(String date) {
LocalDate parse = LocalDate.parse(date, formatterDate);
return LocalDateTime.of(parse, LocalTime.MAX);
}
}

View File

@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
/**
* 差旅
*
* @Authornxj
* @Date2024/4/24 16:40
*/