laravel的union all求聚合

//出库
        $outstockQuery = $this->getOutstockContentQuery($hqCode, $startDate, $endDate, $orgzIds, $typesIn, $productCategory, $onTheWay, $searchType, $keyword, $orderBy, $sort, $length, $offset, $settlementDate);

        //入库
        $InStockContentModel = new InStockContentModel();
        $instockQuery = $InStockContentModel->getInstockContentQuery($hqCode, $startDate, $endDate, $orgzIds, $typesOut, $productCategory, $onTheWay, $searchType, $keyword, $orderBy, $sort, $length, $offset, $settlementDate);

        $unionQuery = $outstockQuery->unionAll($instockQuery);
        $query = clone $unionQuery;

        $summary = DB::table( DB::raw("({$query->toSql()}) as t") )
            ->mergeBindings($query->getQuery())
            ->select(DB::raw('SUM(quantity) as quantity'),
                DB::raw('SUM(amount) as amount'),
                DB::raw('COUNT(*) as total'))
            ->first();

        $result = ['list'=> [],'summary'=>[],'total'=>0];
        $result['total'] = $summary->total??0;
        if ( $result['total'] == 0 ){
            return $result;
        }

        $summary = $summary ? array($summary) : ['quantity'=>0,'amount'=>0];

SpringBoot热部署

  • 部署方式(SpringBootDevtools)
  • 部署方法

1.第一步、先设置我们的pom.xml文件,加入依赖

首先是把下面代码在<dependencies>中

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
        <scope>true</scope>
    </dependency>

2.另外下面的代码是放在<build>  下面<plugins>里的

<plugin>
   <!--热部署配置-->
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-maven-plugin</artifactId>
   <configuration>
       <!--fork:如果没有该项配置,整个devtools不会起作用-->
       <fork>true</fork>
   </configuration>
 </plugin>

第二步、设置IDEA的自动编译:

(1)File-Settings-Compiler勾选 Build Project automatically

2)快捷键 ctrl + shift + alt + /,选择Registry,勾上 Compiler autoMake allow when app running

我们的修改已经生效了,不用通过重启一下项目。