|
|
@@ -28,6 +28,7 @@ import com.poteviohealth.cgp.statistics.model.Order;
|
|
|
import com.poteviohealth.cgp.statistics.model.indto.DishesOrderWebInDTO;
|
|
|
import com.poteviohealth.cgp.statistics.model.indto.OrderCostWebInDTO;
|
|
|
import com.poteviohealth.cgp.statistics.model.indto.OrderServiceWebInDTO;
|
|
|
+import com.poteviohealth.cgp.statistics.model.indto.OrderWebInDTO;
|
|
|
import com.poteviohealth.cgp.statistics.model.outdto.*;
|
|
|
import com.poteviohealth.cgp.statistics.service.IOrderService;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
@@ -246,6 +247,76 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<OrderExcelDTO> excelList(OrderWebInDTO dto) {
|
|
|
+ try {
|
|
|
+ Integer operatorId = TokenContext.cureOperatorId();
|
|
|
+ QueryWrapper<Order> queryWrapper = webOrderQuery(dto, "o.");
|
|
|
+ //int count;
|
|
|
+ /* if (null != dto.getProductIds()) {
|
|
|
+ queryWrapper.eq("od.product_id", dto.getProductIds());
|
|
|
+ count = baseMapper.orderPageListAllSize(queryWrapper,dbName,operatorId);
|
|
|
+ }else{*/
|
|
|
+ int count = baseMapper.orderPageListSize(queryWrapper,dbName,operatorId);
|
|
|
+ // }
|
|
|
+ //每页10000条,计算总页数
|
|
|
+ int maxPage = (int) Math.ceil(count/10000.0);
|
|
|
+ int start = 0;
|
|
|
+ LinkedList<OrderExcelDTO> list = Lists.newLinkedList();
|
|
|
+ for (int i = 0; i < maxPage; i++) {
|
|
|
+ LinkedList<OrderExcelDTO> findList = baseMapper.orderExcel(queryWrapper,dbName,operatorId,start);
|
|
|
+ start = findList.getLast().getId();
|
|
|
+ list.addAll(findList);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderExcelDTO orderExcelDTO : list) {
|
|
|
+ for (OrderConstantEnum.OrderStatus status : EnumUtils.getEnumList(OrderConstantEnum.OrderStatus.class)) {
|
|
|
+ if (status.getCode().toString().equals(orderExcelDTO.getOrderStatus())) {
|
|
|
+ orderExcelDTO.setOrderStatus(status.getDisplay());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderConstantEnum.PayStyle status : EnumUtils.getEnumList(OrderConstantEnum.PayStyle.class)) {
|
|
|
+ if (status.getCode().toString().equals(orderExcelDTO.getPayStyle())) {
|
|
|
+ orderExcelDTO.setPayStyle(status.getDisplay());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderConstantEnum.PayStatus status : EnumUtils.getEnumList(OrderConstantEnum.PayStatus.class)) {
|
|
|
+ if (status.getCode().toString().equals(orderExcelDTO.getPayStatus())) {
|
|
|
+ orderExcelDTO.setPayStatus(status.getDisplay());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (OrderConstantEnum.OrderStyle status : EnumUtils.getEnumList(OrderConstantEnum.OrderStyle.class)) {
|
|
|
+ if (status.getCode().toString().equals(orderExcelDTO.getOrderStyle())) {
|
|
|
+ orderExcelDTO.setOrderStyle(status.getDisplay());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderExcelDTO.setPayAccount(getPayAccountString(orderExcelDTO.getPayAccount()));
|
|
|
+ orderExcelDTO.setStationOrGroupName(StringUtils.isNotBlank(orderExcelDTO.getGroupLeaderName())?orderExcelDTO.getGroupLeaderName():orderExcelDTO.getServiceStationName());
|
|
|
+ }
|
|
|
+ //ForkJoinPool pool = new ForkJoinPool();
|
|
|
+
|
|
|
+ /* OrderExcelTask task = new OrderExcelTask(1,maxPage,queryWrapper, operatorId, dbName,baseMapper);
|
|
|
+ Future<List<OrderExcelDTO>> future = pool.submit(task);
|
|
|
+ do {
|
|
|
+ pool.awaitTermination(1, TimeUnit.SECONDS);
|
|
|
+ } while (!future.isDone());
|
|
|
+ pool.shutdown();
|
|
|
+ list = future.get();*/
|
|
|
+ return list;
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new BuilderException("工单导出失败,请重新操作");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private String getPayAccountString(String payAccount){
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (String s : payAccount.split(",")) {
|
|
|
@@ -388,6 +459,56 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
|
|
|
return orderQueryWrapper;
|
|
|
}
|
|
|
|
|
|
+ private QueryWrapper<Order> webOrderQuery(OrderWebInDTO orderWebInDTO, String prefix) {
|
|
|
+ QueryWrapper<Order> orderQueryWrapper = new QueryWrapper<>();
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getSearchValuePhone())) {
|
|
|
+ orderQueryWrapper.eq(prefix + "phone", orderWebInDTO.getSearchValuePhone());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getSearchValueName())) {
|
|
|
+ orderQueryWrapper.like(prefix + "name", orderWebInDTO.getSearchValueName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getSearchValueOrderCode())) {
|
|
|
+ orderQueryWrapper.eq(prefix + "sn", orderWebInDTO.getSearchValueOrderCode());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getOrderStatus())) {
|
|
|
+ orderQueryWrapper.eq(prefix + "order_status", orderWebInDTO.getOrderStatus());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getPayStatus())) {
|
|
|
+ orderQueryWrapper.eq(prefix + "pay_status", orderWebInDTO.getPayStatus());
|
|
|
+ }
|
|
|
+ if (orderWebInDTO.getPayWay() != null) {
|
|
|
+ orderQueryWrapper.eq(prefix + "pay_way", orderWebInDTO.getPayWay());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(orderWebInDTO.getOrderStyle())) {
|
|
|
+ orderQueryWrapper.eq(prefix + "order_style", orderWebInDTO.getOrderStyle());
|
|
|
+ }
|
|
|
+ if (orderWebInDTO.getStartDate() != null) {
|
|
|
+ orderQueryWrapper.ge(prefix + "order_time", orderWebInDTO.getStartDate());
|
|
|
+ }
|
|
|
+ if (orderWebInDTO.getEndDate() != null) {
|
|
|
+ orderQueryWrapper.le(prefix + "order_time", orderWebInDTO.getEndDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer stationId = TokenContext.curStationId();
|
|
|
+ Integer belong = TokenContext.wbBelong();
|
|
|
+ Integer supplierId = TokenContext.curSupplierId();
|
|
|
+ if(belong.equals(1)){
|
|
|
+ orderQueryWrapper.eq(prefix + "supplier_one_id", supplierId);
|
|
|
+ }else if(belong.equals(2)){
|
|
|
+ orderQueryWrapper.eq(stationId != null,prefix+"service_station_id",stationId);
|
|
|
+ }else{
|
|
|
+ orderQueryWrapper.eq(stationId != null,prefix+"station_id",stationId);
|
|
|
+ if (supplierId != null && !supplierId.equals(-1)) {
|
|
|
+ orderWebInDTO.setSupplierId(supplierId);
|
|
|
+ }else if(orderWebInDTO.getSupplierId() == null){
|
|
|
+ orderQueryWrapper.in(!TokenContext.supplierList().isEmpty(),prefix + "supplier_id",TokenContext.supplierList());
|
|
|
+ }
|
|
|
+ orderQueryWrapper.eq(orderWebInDTO.getSupplierId() != null,prefix + "supplier_id", orderWebInDTO.getSupplierId());
|
|
|
+ }
|
|
|
+ orderQueryWrapper.eq(prefix + "order_type", OrderConstantEnum.OrderType.PRODUCT.getCode());
|
|
|
+ return orderQueryWrapper;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private QueryWrapper webQuery(DishesOrderWebInDTO orderWebInDTO) {
|
|
|
QueryWrapper<Order> orderQueryWrapper = new QueryWrapper<>();
|