【update】后台管理接口查询速度优化
This commit is contained in:
parent
8f7bc94a22
commit
8ff534ca1e
|
@ -7,6 +7,7 @@ import com.chint.domain.aggregates.supplier.SupplierProduct;
|
|||
import com.chint.domain.exceptions.LegEventException;
|
||||
import com.chint.domain.factoriy.leg_event.LegEventFactory;
|
||||
import com.chint.domain.repository.*;
|
||||
import com.chint.manage.entity.business.LegItinerary;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -180,6 +181,33 @@ public class LegDomainService {
|
|||
return list;
|
||||
}
|
||||
|
||||
public List<LegItinerary> queryLocationByLeg(List<LegItinerary> list) {
|
||||
list.forEach(leg -> {
|
||||
LegExtensionField legExtensionField = leg.getLegExtensionField();
|
||||
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
|
||||
List<Long> locationIdsAsLong;
|
||||
if (legExtensionField.getLocationIds().startsWith("[")) {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLongFromArray();
|
||||
} else {
|
||||
locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
|
||||
}
|
||||
List<Location> locationList = legExtensionField.getLocationList();
|
||||
if (locationList == null || locationList.size() != locationIdsAsLong.size()) {
|
||||
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
|
||||
legExtensionField.setLocationList(byNameList);
|
||||
}
|
||||
}
|
||||
if (leg.getOriginId() != null && leg.getOriginLocation() == null) {
|
||||
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
|
||||
}
|
||||
|
||||
if (leg.getDestinationId() != null && leg.getDestinationLocation() == null) {
|
||||
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public RouteOrder checkLegIfStartApproval(RouteOrder routeOrder) {
|
||||
routeOrder.reloadStatus();
|
||||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
|
|
|
@ -7,15 +7,12 @@ import com.chint.domain.aggregates.system.AccountCompany;
|
|||
import com.chint.domain.aggregates.system.SystemCode;
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import com.chint.domain.aggregates.system.SystemOrganizationExtension;
|
||||
import com.chint.domain.aggregates.user.Role;
|
||||
import com.chint.domain.aggregates.user.RoleOrganization;
|
||||
import com.chint.domain.aggregates.user.RoleUser;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.*;
|
||||
import com.chint.domain.value_object.system.RoleOrganizationVO;
|
||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||
import com.chint.infrastructure.repository.cache.CacheRoleRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -166,12 +163,12 @@ public class SystemDomainService {
|
|||
@ListenTo(command = "UserRoleCommand", order = 0)
|
||||
public void loadUserRole(UserRoleCommand command) {
|
||||
User user = command.getUser();
|
||||
List<RoleUser> byUserId = roleUserRepository.findByUserId(user.getUserId());
|
||||
List<Role> roleList = byUserId.stream().flatMap(it -> roleRepository
|
||||
.findById(it.getRoleId())
|
||||
.stream())
|
||||
.toList();
|
||||
user.setRoleList(roleList);
|
||||
// List<RoleUser> byUserId = roleUserRepository.findByUserId(user.getUserId());
|
||||
// List<Role> roleList = byUserId.stream().flatMap(it -> roleRepository
|
||||
// .findById(it.getRoleId())
|
||||
// .stream())
|
||||
// .toList();
|
||||
// user.setRoleList(roleList);
|
||||
roleRepository.loadUserRole(user);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.application.dtos.system.RoleOrgParam;
|
||||
import com.chint.domain.aggregates.system.SystemOrganization;
|
||||
import com.chint.domain.aggregates.user.Role;
|
||||
import com.chint.domain.aggregates.user.RoleOrganization;
|
||||
import com.chint.domain.aggregates.user.RoleUser;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.RoleRepository;
|
||||
|
@ -105,7 +103,6 @@ public class RoleRepositoryImpl implements RoleRepository {
|
|||
}
|
||||
user.setRoleOrgCodeList(orgCodeList);
|
||||
|
||||
|
||||
// List<String> orgCodeList = cacheRoleRepository
|
||||
// .roleOrgCodeList(userId, null);
|
||||
// List<SystemOrganizationVO> systemOrganizationVOList = cacheRoleRepository
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.chint.manage.entity.business;
|
||||
|
||||
import com.chint.domain.aggregates.order.LegExtensionField;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xx LegItinerary.java
|
||||
*
|
||||
**/
|
||||
@Data
|
||||
@Table("leg")
|
||||
public class LegItinerary implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
private Long legId;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime endTime;
|
||||
|
||||
/****/
|
||||
private Integer legType;
|
||||
|
||||
/****/
|
||||
private Integer sequence;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime startTime;
|
||||
|
||||
/****/
|
||||
private Long destinationId;
|
||||
|
||||
/****/
|
||||
private Long originId;
|
||||
|
||||
/****/
|
||||
private Long routeId;
|
||||
|
||||
/****/
|
||||
private Long routeOrderKey;
|
||||
|
||||
/****/
|
||||
private String estimateAmount;
|
||||
|
||||
/****/
|
||||
private String legNo;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime createTime;
|
||||
|
||||
/****/
|
||||
private String currencyType;
|
||||
|
||||
@Transient
|
||||
private Location originLocation;
|
||||
|
||||
@Transient
|
||||
private Location destinationLocation;
|
||||
|
||||
@MappedCollection(idColumn = "leg_id")
|
||||
private LegExtensionField legExtensionField;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.chint.manage.entity.business;
|
||||
|
||||
import com.chint.domain.aggregates.order.ApprovalEvent;
|
||||
import lombok.Data;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.relational.core.mapping.MappedCollection;
|
||||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xx RouteOrderBasic.java
|
||||
*
|
||||
**/
|
||||
@Data
|
||||
@Table("route_order")
|
||||
public class RouteOrderItinerary implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Id
|
||||
private Long routeId;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime bookingTime;
|
||||
|
||||
/****/
|
||||
private String userId;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime createTime;
|
||||
|
||||
/****/
|
||||
private String createUser;
|
||||
|
||||
/****/
|
||||
private Integer sort;
|
||||
|
||||
/****/
|
||||
private Integer status;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime updateTime;
|
||||
|
||||
/****/
|
||||
private String updateUser;
|
||||
|
||||
/****/
|
||||
private String fakeOrderNo;
|
||||
|
||||
/****/
|
||||
private String actualOrderNo;
|
||||
|
||||
/**差旅订单号**/
|
||||
private String routeOrderNo;
|
||||
|
||||
/****/
|
||||
private String supplierName;
|
||||
|
||||
/****/
|
||||
private String accountCompany;
|
||||
|
||||
/****/
|
||||
private String sysCode;
|
||||
|
||||
/****/
|
||||
private String instructions;
|
||||
|
||||
/****/
|
||||
private String standardLevel;
|
||||
|
||||
/****/
|
||||
private String creator;
|
||||
|
||||
/****/
|
||||
private String accountCompanyName;
|
||||
|
||||
/**入账公司64位编码**/
|
||||
private String accountCompanyCode;
|
||||
|
||||
/****/
|
||||
private String projectName;
|
||||
|
||||
/****/
|
||||
private String costCenter;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime startTime;
|
||||
|
||||
/****/
|
||||
private java.time.LocalDateTime endTime;
|
||||
|
||||
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||
private List<ApprovalEvent> approveEvents;
|
||||
|
||||
@MappedCollection(idColumn = "route_id", keyColumn = "route_order_key")
|
||||
private List<LegItinerary> legItems;
|
||||
|
||||
|
||||
}
|
|
@ -20,8 +20,9 @@ public class ConsumptionDetailQuery extends BaseQuery{
|
|||
private Integer productType;
|
||||
private String userName="";
|
||||
private String actualOrderNo=""; //申请单号
|
||||
private List<Long> orderIds=new ArrayList<>();
|
||||
// private List<Long> orderIds=new ArrayList<>();
|
||||
private List<String> orderNos=new ArrayList<>();
|
||||
private List<String> companyCodes=new ArrayList<>();
|
||||
|
||||
public String getActualOrderNo() {
|
||||
return BaseUtil.extractAfterDash(actualOrderNo);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.chint.manage.entity.query;
|
||||
|
||||
import com.chint.domain.value_object.BaseQuery;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.manage.util.BaseUtil;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -13,7 +12,7 @@ public class ItineraryPageQuery extends BaseQuery {
|
|||
private String applicant="";// 申请人
|
||||
private String actualOrderNo=""; //申请单号
|
||||
private List<String> userIds=new ArrayList<>();
|
||||
private List<Long> routeIds=new ArrayList<>();
|
||||
private List<String> companyCodes=new ArrayList<>();
|
||||
|
||||
|
||||
public String getActualOrderNo() {
|
||||
|
|
|
@ -28,11 +28,23 @@ public class OrderPageQuery extends BaseQuery {
|
|||
|
||||
private List<String> employeeNos=null;
|
||||
|
||||
private List<String> companyCodes=null;
|
||||
|
||||
private List<Long> routeIds=null;
|
||||
|
||||
private boolean routeIdsEmpty;
|
||||
|
||||
private boolean employeeNosEmpty;
|
||||
|
||||
|
||||
public boolean getRouteIdsEmpty() {
|
||||
if(routeIds==null||routeIds.isEmpty()){
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getEmployeeNosEmpty() {
|
||||
if(employeeNos==null||employeeNos.isEmpty()){
|
||||
return true;
|
||||
|
|
|
@ -4,12 +4,16 @@ import com.chint.domain.value_object.BaseQuery;
|
|||
import com.chint.manage.util.BaseUtil;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class StandardQuery extends BaseQuery {
|
||||
private String applicant="";// 申请人
|
||||
private String companyName=""; // 出差公司
|
||||
private String orderNo=""; //订单号
|
||||
private String actualOrderNo=""; //申请单号
|
||||
private List<String> companyCods=new ArrayList<String>();
|
||||
|
||||
public String getActualOrderNo() {
|
||||
return BaseUtil.extractAfterDash(actualOrderNo);
|
||||
|
|
|
@ -36,24 +36,27 @@ public interface JdbcOrderDetailBasicRepository extends CrudRepository<OrderDeta
|
|||
List<Long> findAllOrderId();
|
||||
|
||||
|
||||
@Query("SELECT * FROM order_detail " +
|
||||
"WHERE route_id IN (:#{#dto.routeIds}) " +
|
||||
// "WHERE 1=1 " +
|
||||
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
|
||||
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) " +
|
||||
"AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " +
|
||||
"AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))" +
|
||||
@Query("SELECT * FROM order_detail od " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE (roef.company_code IN (:#{#dto.companyCodes})) " +
|
||||
"AND (:#{#dto.routeIdsEmpty} = TRUE OR roef.route_id IN (:#{#dto.routeIds})) " +
|
||||
"AND (:#{#dto.orderNo} ='' OR od.order_no LIKE :#{#dto.orderNo}) " +
|
||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR od.order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
|
||||
"AND (:#{#dto.productType} ='' OR od.product_type = :#{#dto.productType}) " +
|
||||
"AND (:#{#dto.employeeNo} ='' OR od.employee_no = :#{#dto.employeeNo}) " +
|
||||
"AND (:#{#dto.employeeNosEmpty} = TRUE OR od.employee_no IN (:#{#dto.employeeNos})) " +
|
||||
"LIMIT :#{#pageRequest.pageSize} OFFSET :#{#pageRequest.pageNumber}")
|
||||
List<OrderDetailBasic> listByCondition(@Param("dto") OrderPageQuery dto, @Param("pageRequest") PageRequest pageRequest);
|
||||
|
||||
@Query("SELECT COUNT(*) FROM order_detail " +
|
||||
"WHERE route_id IN (:#{#dto.routeIds}) " +
|
||||
// "WHERE 1=1 " +
|
||||
"AND (:#{#dto.orderNo} ='' OR order_no LIKE :#{#dto.orderNo}) " +
|
||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime} ) " +
|
||||
"AND (:#{#dto.productType} ='' OR product_type = :#{#dto.productType}) "+
|
||||
"AND (:#{#dto.employeeNo} ='' OR employee_no = :#{#dto.employeeNo}) " +
|
||||
"AND (:#{#dto.employeeNosEmpty} = TRUE OR employee_no IN (:#{#dto.employeeNos}))")
|
||||
@Query("SELECT COUNT(*) FROM order_detail od " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE (roef.company_code IN (:#{#dto.companyCodes})) " +
|
||||
"AND (:#{#dto.routeIdsEmpty} = TRUE OR roef.route_id IN (:#{#dto.routeIds})) " +
|
||||
"AND (:#{#dto.orderNo} ='' OR od.order_no LIKE :#{#dto.orderNo}) " +
|
||||
"AND (:#{#dto.startTime} IS NULL OR :#{#dto.endTime} IS NULL OR od.order_date BETWEEN :#{#dto.startTime} AND :#{#dto.endTime}) " +
|
||||
"AND (:#{#dto.productType} ='' OR od.product_type = :#{#dto.productType}) " +
|
||||
"AND (:#{#dto.employeeNo} ='' OR od.employee_no = :#{#dto.employeeNo}) " +
|
||||
"AND (:#{#dto.employeeNosEmpty} = TRUE OR od.employee_no IN (:#{#dto.employeeNos}))"
|
||||
)
|
||||
Integer countByCondition(@Param("dto") OrderPageQuery dto);
|
||||
}
|
|
@ -19,4 +19,7 @@ public interface JdbcRouteOrderExtensionFieldBasicRepository extends CrudReposit
|
|||
List<RouteOrderExtensionFieldBasic> findAllByBelongDeptCodeIn(@Param("belongDeptCode") List<String> belongDeptCode);
|
||||
|
||||
List<RouteOrderExtensionFieldBasic> findAllByCompanyCodeIn(@Param("code") List<String> code);
|
||||
|
||||
@Query("select * from route_order_extension_field")
|
||||
List<RouteOrderExtensionFieldBasic> findAll();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.chint.manage.mapper;
|
||||
|
||||
import com.chint.manage.entity.business.RouteOrderItinerary;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author xx JdbcRouteOrderBasicRepository数据库操作接口类
|
||||
*
|
||||
**/
|
||||
@Repository
|
||||
public interface JdbcRouteOrderItineraryRepository extends CrudRepository<RouteOrderItinerary,Long> {
|
||||
|
||||
List<RouteOrderItinerary> findByRouteIdIn(List<Long> routeIds);
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.chint.manage.mapper;
|
||||
|
||||
import com.chint.manage.entity.OrderDetailBasic;
|
||||
import com.chint.manage.entity.OrderExceedStandard;
|
||||
import com.chint.manage.entity.RouteOrderExtensionFieldBasic;
|
||||
import com.chint.manage.entity.query.StandardQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ManageOrderDetailRepository {
|
||||
|
||||
List<OrderDetailBasic> orderDetailBasicList(List<Long> routeIds);
|
||||
|
||||
Page<OrderExceedStandard> OrderExceedStandard(StandardQuery dto);
|
||||
|
||||
List<RouteOrderExtensionFieldBasic> findAll();
|
||||
}
|
|
@ -45,19 +45,20 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
|||
|
||||
@Override
|
||||
public Page<ItineraryPageDto> itineraryPageQueryByDto(ItineraryPageQuery dto) {
|
||||
String query = "SELECT * FROM route_order "
|
||||
String query ="LEFT JOIN route_order_extension_field roef ON roef.route_id=ro.route_id "
|
||||
+ "WHERE actual_order_no IS NOT NULL ";
|
||||
|
||||
if (!dto.getRouteIds().isEmpty()) {
|
||||
query+="AND route_id IN (:routeIds) ";
|
||||
if (!dto.getCompanyCodes().isEmpty()) {
|
||||
query+="AND roef.company_code IN (:companyCodes) ";
|
||||
}
|
||||
|
||||
if (!dto.getUserIds().isEmpty()) {
|
||||
query+="AND user_id IN (:userIds) ";
|
||||
query+="AND ro.user_id IN (:userIds) ";
|
||||
}
|
||||
|
||||
if (!dto.getActualOrderNo().isEmpty()) {
|
||||
query+="AND actual_order_no = :actualOrderNo ";
|
||||
dto.setActualOrderNo(dto.getActualOrderNo()+"%");
|
||||
query+="AND ro.actual_order_no LIKE (:actualOrderNo) ";
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
@ -65,14 +66,15 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
|||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
|
||||
params.put("actualOrderNo", dto.getActualOrderNo());
|
||||
params.put("userIds", dto.getUserIds());
|
||||
params.put("routeIds", dto.getRouteIds());
|
||||
params.put("companyCodes", dto.getCompanyCodes());
|
||||
params.put("offset", pageRequest.getOffset());
|
||||
params.put("limit", pageRequest.getPageSize());
|
||||
|
||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||
|
||||
String pagedQuery ="SELECT * FROM route_order ro "+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<ItineraryPageDto> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(ItineraryPageDto.class));
|
||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||
|
||||
String countQuery="SELECT COUNT(*) FROM route_order ro "+query;
|
||||
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
|
||||
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
@ -80,10 +82,13 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
|||
@Override
|
||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||
//数据权限
|
||||
List<Long> orderIds=baseUtil.getOrderIds();
|
||||
if (orderIds==null||orderIds.isEmpty()) {
|
||||
// List<Long> orderIds=baseUtil.getOrderIds();
|
||||
List<String> companyCodes =baseUtil.getCompanyCode();
|
||||
if (companyCodes==null||companyCodes.isEmpty()) {
|
||||
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||
}
|
||||
dto.setCompanyCodes(companyCodes);
|
||||
|
||||
Page<? extends BaseExcel> data=new PageImpl<>(Collections.emptyList());
|
||||
//申请单查询
|
||||
if (!dto.getActualOrderNo().isEmpty()){
|
||||
|
@ -105,53 +110,66 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
|||
|
||||
|
||||
private Page<TrainOrderDetailExcel> trainPageConsumptionDetail(ConsumptionDetailQuery dto){
|
||||
String query = "SELECT * FROM train_order_detail "
|
||||
+ "WHERE 1=1 ";
|
||||
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE 1=1 ";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
PageRequest pageRequest = PageRequest
|
||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
|
||||
query = getString(dto, query, params, pageRequest);
|
||||
|
||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||
String pagedQuery ="SELECT * FROM train_order_detail tod "
|
||||
+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<TrainOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(TrainOrderDetailExcel.class));
|
||||
|
||||
String countQuery = "SELECT COUNT(*) FROM train_order_detail tod " + query;
|
||||
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
||||
private Page<FlightOrderDetailExcel> flightPageConsumptionDetail(ConsumptionDetailQuery dto){
|
||||
String query = "SELECT * FROM flight_order_detail "
|
||||
+ "WHERE 1=1 ";
|
||||
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE 1=1 ";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
PageRequest pageRequest = PageRequest
|
||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
|
||||
query = getString(dto, query, params, pageRequest);
|
||||
|
||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||
String pagedQuery ="SELECT * FROM flight_order_detail tod "
|
||||
+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<FlightOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(FlightOrderDetailExcel.class));
|
||||
|
||||
String countQuery = "SELECT COUNT(*) FROM flight_order_detail tod " + query;
|
||||
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
||||
private Page<HotelOrderDetailExcel> hotelPageConsumptionDetail(ConsumptionDetailQuery dto){
|
||||
String query = "SELECT * FROM hotel_order_detail "
|
||||
+ "WHERE 1=1 ";
|
||||
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE 1=1 ";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
PageRequest pageRequest = PageRequest
|
||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("create_time").descending());
|
||||
query = getString(dto, query, params, pageRequest);
|
||||
|
||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||
String pagedQuery ="SELECT * FROM hotel_order_detail tod "
|
||||
+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<HotelOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(HotelOrderDetailExcel.class));
|
||||
|
||||
String countQuery = "SELECT COUNT(*) FROM hotel_order_detail tod " + query;
|
||||
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
||||
private Page<CarOrderDetailExcel> carPageConsumptionDetail(ConsumptionDetailQuery dto){
|
||||
String query = "SELECT * FROM car_order_detail "
|
||||
+ "WHERE 1=1 ";
|
||||
String query = "LEFT JOIN order_detail od ON tod.order_id=od.order_id " +
|
||||
"LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "+
|
||||
"WHERE 1=1 ";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
PageRequest pageRequest = PageRequest
|
||||
|
@ -159,29 +177,32 @@ public class JdbcConsumptionDetailRepositoryImpl implements JdbcConsumptionDetai
|
|||
|
||||
query = getString(dto, query, params, pageRequest);
|
||||
|
||||
String pagedQuery = query + " LIMIT :limit OFFSET :offset";
|
||||
long count = jdbcTemplate.queryForObject("SELECT COUNT(*) FROM (" + query + ") AS count", params, Long.class);
|
||||
String pagedQuery ="SELECT * FROM car_order_detail tod "
|
||||
+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<CarOrderDetailExcel> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(CarOrderDetailExcel.class));
|
||||
|
||||
String countQuery = "SELECT COUNT(*) FROM car_order_detail tod " + query;
|
||||
long count = jdbcTemplate.queryForObject(countQuery, params, Long.class);
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
||||
private static String getString(ConsumptionDetailQuery dto, String query, Map<String, Object> params, PageRequest pageRequest) {
|
||||
if (!dto.getUserName().isEmpty()) {
|
||||
dto.setUserName(dto.getUserName()+"%");
|
||||
query +="AND user_name LIKE (:userName)";
|
||||
query +="AND tod.user_name LIKE (:userName)";
|
||||
}
|
||||
|
||||
if (!dto.getOrderIds().isEmpty()) {
|
||||
query +="AND order_id IN (:orderIds)";
|
||||
if (!dto.getCompanyCodes().isEmpty()) {
|
||||
query +="AND roef.company_code IN (:companyCodes)";
|
||||
}
|
||||
|
||||
if (!dto.getOrderNos().isEmpty()) {
|
||||
query +="AND order_no IN (:orderNos)";
|
||||
query +="AND tod.order_no IN (:orderNos)";
|
||||
}
|
||||
|
||||
params.put("userName", dto.getUserName());
|
||||
params.put("orderNos", dto.getOrderNos());
|
||||
params.put("orderIds", dto.getOrderIds());
|
||||
params.put("companyCodes", dto.getCompanyCodes());
|
||||
|
||||
params.put("offset", pageRequest.getOffset());
|
||||
params.put("limit", pageRequest.getPageSize());
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.chint.manage.mapper.impl;
|
||||
|
||||
import com.chint.manage.entity.OrderDetailBasic;
|
||||
import com.chint.manage.entity.OrderExceedStandard;
|
||||
import com.chint.manage.entity.RouteOrderExtensionFieldBasic;
|
||||
import com.chint.manage.entity.query.StandardQuery;
|
||||
import com.chint.manage.mapper.ManageOrderDetailRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Repository
|
||||
public class ManageOrderDetailRepositoryImpl implements ManageOrderDetailRepository {
|
||||
|
||||
@Autowired
|
||||
private NamedParameterJdbcTemplate jdbcTemplate;
|
||||
|
||||
@Override
|
||||
public List<OrderDetailBasic> orderDetailBasicList(List<Long> routeIds) {
|
||||
String query = "SELECT * FROM order_detail WHERE route_id IN (:routeIds)";
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("routeIds", routeIds);
|
||||
List<OrderDetailBasic> results = jdbcTemplate.query(query, params, BeanPropertyRowMapper.newInstance(OrderDetailBasic.class));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<OrderExceedStandard> OrderExceedStandard(StandardQuery dto) {
|
||||
String query ="LEFT JOIN order_detail od ON oes.order_no=od.order_no "
|
||||
+ "LEFT JOIN route_order_extension_field roef ON roef.route_id=od.route_id "
|
||||
+ "WHERE 1=1 ";
|
||||
if (!dto.getApplicant().isEmpty()) {
|
||||
dto.setApplicant(dto.getApplicant()+"%");
|
||||
query+="AND oes.applicat LIKE (:applicat) ";
|
||||
}
|
||||
|
||||
if (!dto.getOrderNo().isEmpty()) {
|
||||
query+="AND oes.order_no LIKE (:orderNo) ";
|
||||
}
|
||||
|
||||
if (!dto.getActualOrderNo().isEmpty()) {
|
||||
query+="AND oes.actual_order_no LIKE (:actualOrderNo) ";
|
||||
}
|
||||
|
||||
if (!dto.getCompanyName().isEmpty()) {
|
||||
query+="AND oes.company_name LIKE (:companyName) ";
|
||||
}
|
||||
|
||||
if (!dto.getCompanyCods().isEmpty()) {
|
||||
query+="AND roef.company_code IN (:companyCods) ";
|
||||
}
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
PageRequest pageRequest = PageRequest
|
||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
||||
params.put("actualOrderNo", dto.getActualOrderNo());
|
||||
params.put("applicat", dto.getApplicant());
|
||||
params.put("companyName", dto.getCompanyName());
|
||||
params.put("companyCods", dto.getCompanyCods());
|
||||
params.put("orderNo", dto.getOrderNo());
|
||||
params.put("offset", pageRequest.getOffset());
|
||||
params.put("limit", pageRequest.getPageSize());
|
||||
|
||||
String pagedQuery ="SELECT * FROM order_exceed_standard oes "+ query + " LIMIT :limit OFFSET :offset";
|
||||
List<OrderExceedStandard> results = jdbcTemplate.query(pagedQuery, params, BeanPropertyRowMapper.newInstance(OrderExceedStandard.class));
|
||||
|
||||
String countSql="SELECT COUNT(*) AS count FROM order_exceed_standard oes " + query ;
|
||||
long count = jdbcTemplate.queryForObject(countSql, params, Long.class);
|
||||
|
||||
return new PageImpl<>(results, pageRequest, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RouteOrderExtensionFieldBasic> findAll() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
List<RouteOrderExtensionFieldBasic> results = jdbcTemplate.query("select distinct(company_code) from route_order_extension_field", params, BeanPropertyRowMapper.newInstance(RouteOrderExtensionFieldBasic.class));
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
|
@ -15,7 +15,9 @@ import com.chint.manage.entity.OrderDetailBasic;
|
|||
import com.chint.manage.entity.OrderDownloadRecord;
|
||||
import com.chint.manage.entity.OrderExceedStandard;
|
||||
import com.chint.manage.entity.RouteOrderExtensionFieldBasic;
|
||||
import com.chint.manage.entity.business.LegItinerary;
|
||||
import com.chint.manage.entity.dto.ItineraryPageDto;
|
||||
import com.chint.manage.entity.business.RouteOrderItinerary;
|
||||
import com.chint.manage.entity.excel.OrderPageExcel;
|
||||
import com.chint.manage.entity.excel.BaseExcel;
|
||||
import com.chint.manage.entity.excel.OrderExceedStandardExcel;
|
||||
|
@ -31,8 +33,6 @@ import com.chint.manage.util.ExcelUtil;
|
|||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -61,6 +61,8 @@ public class ManageServiceImpl implements ManageService {
|
|||
@Autowired
|
||||
private JdbcRouteRepository jdbcRouteRepository;
|
||||
@Autowired
|
||||
private JdbcRouteOrderItineraryRepository jdbcRouteOrderItineraryRepository;
|
||||
@Autowired
|
||||
private JdbcUserRepository jdbcUserRepository;
|
||||
@Autowired
|
||||
private JdbcOrderDownloadRecordRepository jdbcOrderDownloadRecordRepository;
|
||||
|
@ -80,6 +82,8 @@ public class ManageServiceImpl implements ManageService {
|
|||
private JdbcHotelOrderDetailRepository jdbcHotelOrderDetailRepository;
|
||||
@Autowired
|
||||
private JdbcCarOrderDetailRepository jdbcCarOrderDetailRepository;
|
||||
@Autowired
|
||||
private ManageOrderDetailRepository manageOrderDetailRepository;
|
||||
|
||||
@Override
|
||||
public PageResult<? extends BaseExcel> pageConsumptionDetail(ConsumptionDetailQuery dto) {
|
||||
|
@ -98,19 +102,12 @@ public class ManageServiceImpl implements ManageService {
|
|||
@Override
|
||||
public PageResult<OrderExceedStandardExcel> standardQuery(StandardQuery dto) {
|
||||
//数据权限
|
||||
List<String> orderNos=baseUtil.getOrderNos();
|
||||
if (orderNos==null||orderNos.isEmpty()) {
|
||||
List<String> companyCods=baseUtil.getCompanyCode();
|
||||
if (companyCods==null||companyCods.isEmpty()) {
|
||||
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||
}
|
||||
|
||||
PageRequest pageRequest = PageRequest
|
||||
.of(dto.getPageNum() - 1, dto.getPageSize(), Sort.by("id").descending());
|
||||
Page<OrderExceedStandard> page=jdbcOrderExceedStandardRepository.findAllByApplicantContainsAndDeptNameContainsAndActualOrderNoContainsAndOrderNoContainsAndOrderNoIn(dto.getApplicant(),
|
||||
dto.getCompanyName(),
|
||||
dto.getActualOrderNo(),
|
||||
dto.getOrderNo(),
|
||||
orderNos,
|
||||
pageRequest);
|
||||
dto.setCompanyCods(companyCods);
|
||||
Page<OrderExceedStandard> page=manageOrderDetailRepository.OrderExceedStandard(dto);
|
||||
List<OrderExceedStandardExcel> excelList = getOrderExceedStandardExcels(page);
|
||||
return PageResult.totalPageNum(page.getTotalElements(), excelList);
|
||||
}
|
||||
|
@ -127,11 +124,11 @@ public class ManageServiceImpl implements ManageService {
|
|||
@Override
|
||||
public PageResult<ItineraryPageDto> itineraryPageQuery(ItineraryPageQuery dto) {
|
||||
//数据权限
|
||||
List<Long> routeIds=baseUtil.getRouteIds();
|
||||
if (routeIds==null||routeIds.isEmpty()) {
|
||||
List<String> companyCodes=baseUtil.getCompanyCode();
|
||||
if (companyCodes==null||companyCodes.isEmpty()) {
|
||||
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||
}
|
||||
dto.setRouteIds(routeIds);
|
||||
dto.setCompanyCodes(companyCodes);
|
||||
|
||||
List<User> users=new ArrayList<>();
|
||||
if (!dto.getApplicant().isEmpty()){
|
||||
|
@ -146,13 +143,13 @@ public class ManageServiceImpl implements ManageService {
|
|||
List<ItineraryPageDto> list=page.getContent();
|
||||
//查询行程和审批单信息
|
||||
List<Long> routeIdList=list.stream().map(ItineraryPageDto::getRouteId).toList();
|
||||
List<RouteOrder> routeOrders=jdbcRouteRepository.findByRouteIdIn(routeIdList);
|
||||
|
||||
List<RouteOrderItinerary> routeOrders=jdbcRouteOrderItineraryRepository.findByRouteIdIn(routeIdList);
|
||||
List<ItineraryPageDto> orders = list
|
||||
.stream()
|
||||
.map(routeOrder -> {
|
||||
RouteOrder order=routeOrders.stream().filter(s->s.getRouteId().equals(routeOrder.getRouteId())).toList().get(0);
|
||||
legDomainService.queryLocation(order.getLegItems());
|
||||
RouteOrderItinerary order=routeOrders.stream().filter(s->s.getRouteId().equals(routeOrder.getRouteId())).toList().get(0);
|
||||
legDomainService.queryLocationByLeg(order.getLegItems());
|
||||
routeOrder.setApprovalStatus(routeOrder.getApprovalStatus(order.getApproveEvents()));
|
||||
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
|
||||
return getRouteOrderPageRes(routeOrder, user,order.getLegItems());
|
||||
|
@ -177,11 +174,11 @@ public class ManageServiceImpl implements ManageService {
|
|||
@Override
|
||||
public PageResult<OrderPageExcel> orderPageQuery(OrderPageQuery dto) {
|
||||
//数据权限
|
||||
List<Long> dataRouteIds=baseUtil.getRouteIds();
|
||||
if (dataRouteIds==null||dataRouteIds.isEmpty()) {
|
||||
List<String> companyCodes=baseUtil.getCompanyCode();
|
||||
if (companyCodes==null||companyCodes.isEmpty()) {
|
||||
return PageResult.totalPageNum(0, new ArrayList<>());
|
||||
}
|
||||
dto.setRouteIds(dataRouteIds);
|
||||
dto.setCompanyCodes(companyCodes);
|
||||
|
||||
//预订人
|
||||
if (!dto.getApplicant().equals("")){
|
||||
|
@ -360,7 +357,7 @@ public class ManageServiceImpl implements ManageService {
|
|||
return excelList;
|
||||
}
|
||||
|
||||
private static ItineraryPageDto getRouteOrderPageRes(ItineraryPageDto res, User user,List<Leg> legItems) {
|
||||
private static ItineraryPageDto getRouteOrderPageRes(ItineraryPageDto res, User user,List<LegItinerary> legItems) {
|
||||
List<LocationRes> locationRes = legItems
|
||||
.stream()
|
||||
.flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))
|
||||
|
|
|
@ -2,10 +2,6 @@ package com.chint.manage.util;
|
|||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.manage.entity.RouteOrderExtensionFieldBasic;
|
||||
import com.chint.manage.mapper.JdbcOrderDetailBasicRepository;
|
||||
import com.chint.manage.mapper.JdbcRouteOrderExtensionFieldBasicRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -18,32 +14,16 @@ import java.util.Objects;
|
|||
*/
|
||||
@Component
|
||||
public class BaseUtil {
|
||||
@Autowired
|
||||
private JdbcRouteOrderExtensionFieldBasicRepository jdbcRouteOrderExtensionFieldBasicRepository;
|
||||
@Autowired
|
||||
private JdbcOrderDetailBasicRepository jdbcOrderDetailBasicRepository;
|
||||
|
||||
public User getCurrentUser() {
|
||||
return BaseContext.getCurrentUser();
|
||||
}
|
||||
|
||||
public List<Long> getRouteIds(){
|
||||
|
||||
public List<String> getCompanyCode(){
|
||||
List<String> list = BaseContext.getCurrentUser().loadRoleOrg().getRoleOrgCodeList().stream().filter(Objects::nonNull).toList();
|
||||
if (list.isEmpty()) return null;
|
||||
List<RouteOrderExtensionFieldBasic> result= jdbcRouteOrderExtensionFieldBasicRepository.findAllByCompanyCodeIn(list);
|
||||
return result.stream().map(RouteOrderExtensionFieldBasic::getRouteId).toList();
|
||||
}
|
||||
|
||||
public List<Long> getOrderIds(){
|
||||
List<Long> routeIds = getRouteIds();
|
||||
if (routeIds==null||routeIds.isEmpty()) return null;
|
||||
return jdbcOrderDetailBasicRepository.findAllOrderId(routeIds);
|
||||
}
|
||||
|
||||
public List<String> getOrderNos(){
|
||||
List<Long> routeIds = getRouteIds();
|
||||
if (routeIds==null||routeIds.isEmpty()) return null;
|
||||
return jdbcOrderDetailBasicRepository.findAllOrderNo(routeIds);
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -16,7 +16,9 @@ import java.util.Map;
|
|||
public class DataJdbcCreatorUtil {
|
||||
|
||||
//package路径
|
||||
private final String prefix="com.chint.manage";
|
||||
private final String PREFIX="com.chint.manage";
|
||||
|
||||
private final String BUSINESS="Itinerary";
|
||||
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
|
@ -39,7 +41,7 @@ public class DataJdbcCreatorUtil {
|
|||
*/
|
||||
private List<String> getTables() throws SQLException {
|
||||
List<String> tables = new ArrayList<String>();
|
||||
tables.add("crux_system_log");
|
||||
tables.add("leg");
|
||||
return tables;
|
||||
}
|
||||
|
||||
|
@ -98,13 +100,13 @@ public class DataJdbcCreatorUtil {
|
|||
/**
|
||||
* package路径
|
||||
*/
|
||||
private final String bean_package = prefix+".entity";
|
||||
private final String bean_package = PREFIX+".entity";
|
||||
|
||||
private final String mapper_package = prefix+".mapper";
|
||||
private final String mapper_package = PREFIX+".mapper";
|
||||
|
||||
private final String service_package = prefix+".service";
|
||||
private final String service_package = PREFIX+".service";
|
||||
|
||||
private final String service_impl_package = prefix+".service.impl";
|
||||
private final String service_impl_package = PREFIX+".service.impl";
|
||||
|
||||
/**
|
||||
* 数据库
|
||||
|
@ -149,7 +151,7 @@ public class DataJdbcCreatorUtil {
|
|||
temp = tables[i].trim();
|
||||
sb.append(temp.substring(0, 1).toUpperCase()).append(temp.substring(1));
|
||||
}
|
||||
beanName = sb.toString()+"Basic";
|
||||
beanName = sb.toString()+BUSINESS;
|
||||
mapperName = "Jdbc"+beanName + "Repository";
|
||||
_mapperName = shotFirst(mapperName);
|
||||
serviceName = beanName + "Service";
|
||||
|
|
Loading…
Reference in New Issue