cooladmin 后端 查询记录

查询记录:pageQueryOp中列表查询的group by

node ts controller代码如下

import { CoolController, BaseController } from '@cool-midway/core';
import { Inject, Post, Get, Param } from '@midwayjs/decorator';
import { ComparePricesPlanInfoEntity } from '../../entity/comparePricesPlanInfo';
import { InventoryOrderInfoService } from '../../service/inventoryOrderInfo';
import { PlanInfoEntity } from '../../entity/planInfo';
import { ConsumableDetailEntity } from '../../../consumable/entity/detail';
import { Context } from 'vm';
import { OrderEntity } from '../../entity/order';
import { ComparePricesEntity } from '../../entity/comparePrices';
import { ComparePricesInfoEntity } from '../../entity/comparePricesInfo';
import { VendorEntity } from '../../entity/vendor';
import { QueryBuilder } from 'typeorm';/*** 描述*/
@CoolController({api: ['add', 'delete', 'update', 'info', 'list', 'page'],entity: OrderEntity,service: InventoryOrderInfoService,pageQueryOp: {// keyWordLikeFields: ['vendorName'],// 指定返回字段select: [//采购单信息'a.id','a.state',//状态:待确认(0)、已发货(1)、已收货(2)'a.inspectorName',//验收人员姓名'a.acceptanceContent',//验收内容'a.resultState',//验收结果状态:未验收(0)、通过(1)、不通过(2)'a.reason',//通过/不通过原因'a.createBy',//创建者'a.createTime',//创建时间'a.code',//订单编码'a.title',//订单标题'a.content',//订单内容'a.remark as orderRemark',//订单备注//比价'cp.comparePricesInfoId',//比价信息ID'cp.consumableDetailId',//耗材ID//采用价格信息'cpinfo.quotedPrice',//报价'cpinfo.serviceContent',//服务内容'cpinfo.deliveryTime',//货期'cpinfo.isProposed',//拟用采纳'cpinfo.vendorId',//供应商ID// 'cpinfo.consumableDetailId',//耗材ID'cpinfo.planInfoId',//计划明细表ID'cpinfo.vcid',//供应商-耗材关联表ID//耗材信息'c.consumableNo','c.consumableName','c.brand','c.model','c.type','c.remark as consumableDetailRemark','c.status',//供应商信息'v.vendorCode','v.vendorName','v.vendorNick','v.vendorEn',//采购计划数量'SUM(pinfo.number) as sumNum',//采购计划规格'pinfo.specification',//采购单信息// 'a.id',// 'a.planInfoId',// 'a.comparePricesId',// 'a.createTime',// 'a.updateTime',// //采购计划详情// 'b.planId',// 'b.consumableDetailId',// 'b.specification',// 'b.number',// 'b.budget',// 'b.deliveryTime',// // 'b.createBy',// // 'b.createTime',],// 联表查询join: [//ComparePricesEntity{entity: ComparePricesEntity,alias: 'cp',condition: 'a.comparePricesId = cp.id',type: 'leftJoin',},//ComparePricesInfoEntity{entity: ComparePricesInfoEntity,alias: 'cpinfo',condition: 'cp.comparePricesInfoId = cpinfo.id',type: 'leftJoin',},//ConsumableDetailEntity{entity: ConsumableDetailEntity,alias: 'c',condition: 'cp.consumableDetailId = c.id',type: 'leftJoin',},//VendorEntity{entity: VendorEntity,alias: 'v',condition: 'cpinfo.vendorId = v.id',type: 'leftJoin',},//ComparePricesPlanInfoEntity{entity: ComparePricesPlanInfoEntity,alias: 'cppinfo',condition: 'a.comparePricesId = cppinfo.comparePricesId',type: 'leftJoin',},//PlanInfoEntity{entity: PlanInfoEntity,alias: 'pinfo',condition: 'cppinfo.planInfoId = pinfo.id',type: 'leftJoin',},// {//     entity: OrderEntity,//     alias: 'o',//     condition: 'a.comparePricesId = o.comparePricesId',//     type: 'leftJoin',// },],where: async (ctx: Context) => {return [// ['a.id not in (SELECT comparePricesId from pi_purchase_order)', {}],// ['a.comparePricesId = :comparePricesId', { comparePricesId: ctx.request.body.comparePricesId }]];},extend: (queryBuilder: QueryBuilder<any>) => {queryBuilder.groupBy(['a.id','pinfo.specification',]);},addOrderBy: {'a.createTime': 'asc',},},
})
export class InventoryOrderInfoController extends BaseController {@Inject()inventoryOrderInfoService: InventoryOrderInfoService;
}

具体的SQL执行语句:

SELECTa.id,a.state,a.inspectorName,a.acceptanceContent,a.resultState,a.reason,a.createBy,a.createTime,a.CODE,a.title,a.content,a.remark AS orderRemark,cp.comparePricesInfoId,cp.consumableDetailId,cpinfo.quotedPrice,cpinfo.serviceContent,cpinfo.deliveryTime,cpinfo.isProposed,cpinfo.vendorId,cpinfo.planInfoId,cpinfo.vcid,c.consumableNo,c.consumableName,c.brand,c.model,c.type,c.remark AS consumableDetailRemark,c.STATUS,v.vendorCode,v.vendorName,v.vendorNick,v.vendorEn,SUM( pinfo.number ) AS sumNum,pinfo.specification 
FROM`pi_purchase_order` `a`LEFT JOIN `pi_compare_prices` `cp` ON `a`.`comparePricesId` = `cp`.`id`LEFT JOIN `pi_compare_prices_info` `cpinfo` ON `cp`.`comparePricesInfoId` = `cpinfo`.`id`LEFT JOIN `consumable_detail` `c` ON `cp`.`consumableDetailId` = `c`.`id`LEFT JOIN `pi_vendor` `v` ON `cpinfo`.`vendorId` = `v`.`id`LEFT JOIN `pi_compare_prices_plan_info` `cppinfo` ON `a`.`comparePricesId` = `cppinfo`.`comparePricesId`LEFT JOIN `pi_plan_info` `pinfo` ON `cppinfo`.`planInfoId` = `pinfo`.`id` 
GROUP BY`a`.`id`,pinfo.specification 
ORDER BY`a`.`createTime` ASC,`createTime` DESC

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/886193.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

UE5运行时创建slate窗口

加入"Slate","SlateCore"模块 Actor.cpp // Fill out your copyright notice in the Description page of Project Settings.#include "MyWindowClass.h"// Sets default values AMyWindowClass::AMyWindowClass() {// Set this actor to call…

react 受控组件和非受控组件

在 React 中&#xff0c;受控组件和非受控组件是两种处理表单元素&#xff08;如输入框、选择框等&#xff09;值的方式。 1. 受控组件 受控组件是指 React 组件的表单元素的值是由 React 组件的 state 来管理的。换句话说&#xff0c;React 会全程控制表单元素的值&#xff…

cesium 3DTiles之pnts格式详解

Point Cloud 1 概述 点云&#xff08;Point Cloud&#xff09;瓦片格式用于高效流式传输大规模点云数据&#xff0c;常用于 3D 可视化中。每个点由位置&#xff08;Position&#xff09;和可选的属性定义&#xff0c;这些属性用来描述点的外观&#xff08;如颜色、法线等&…

基于STM32的智能家居安防系统设计

引言 本项目基于STM32微控制器设计了一个智能家居安防系统&#xff0c;通过集成多个传感器模块和远程报警系统&#xff0c;实现对家庭的安全监控和自动化报警功能。该系统能够实时监测家中的门窗状态、烟雾浓度、以及是否有非法入侵等状况&#xff0c;并在检测到异常时通过蜂鸣…

用枚举算法解决LeetCode第3348题最小可整除数位乘积II

3348.最小可整除数位乘积II 难度&#xff1a;困难 问题描述&#xff1a; 给你一个字符串num&#xff0c;表示一个正整数&#xff0c;同时给你一个整数t。 如果一个整数没有任何数位是0&#xff0c;那么我们称这个整数是无零数字。 请你返回一个字符串&#xff0c;这个字符…

F5全新报告揭示AI时代API安全面临严峻挑战

F5 《2024年应用策略现状报告:API安全》揭示了 API 保护中的漏洞以及对全面安全措施的迫切需求 西雅图,2024年11月11日 – F5(NASDAQ: FFIV)日前发布《2024年应用策略现状报告:API 安全》(以下简称为“报告”),揭示了跨行业API安全面临的严峻现状。该报告强调了企业API保护方面…

【SpringBoot】20 同步调用、异步调用、异步回调

Git仓库 https://gitee.com/Lin_DH/system 介绍 同步调用&#xff1a;指程序在执行时&#xff0c;调用方需要等待函数调用返回结果后&#xff0c;才能继续执行下一步操作&#xff0c;是一种阻塞式调用。 异步调用&#xff1a;指程序在执行时&#xff0c;调用方在调用函数后立…

ESLint 使用教程(五):ESLint 和 Prettier 的结合使用与冲突解决

系列文章 ESLint 使用教程&#xff08;一&#xff09;&#xff1a;从零配置 ESLint ESLint 使用教程&#xff08;二&#xff09;&#xff1a;一步步教你编写 Eslint 自定义规则 ESLint 使用教程&#xff08;三&#xff09;&#xff1a;12个ESLint 配置项功能与使用方式详解 ES…

Qt_day5_常用类

常用类 目录 1. QString 字符串类&#xff08;掌握&#xff09; 2. 容器类&#xff08;掌握&#xff09; 2.1 顺序容器QList 2.2 关联容器QMap 3. 几种Qt数据类型&#xff08;熟悉&#xff09; 3.1 跨平台数据类型 3.2 QVariant 统一数据类型 3.3 QStringList 字符串列表 4. QD…

VBA学习笔记:基础知识

1.打开编辑器 工具-选项&#xff0c;可设置编辑器字体大小等 2. 运行 快捷键F5&#xff0c;或 运行-运行宏 若提示宏被禁止&#xff0c;解决办法之一&#xff1a;工具-宏-安全性-安全级-中&#xff0c;关闭excel重新打开&#xff0c;启用宏 保存文件格式为xla或xlam 3. 基本…

【CANOE】【学习】【DecodeString】字节转为中文字符输出

系列文章目录 文章目录 系列文章目录前言一、DecodeString 转为中文字节输出二、代码举例1.代码Demo2.DecodeString 函数说明函数语法&#xff1a;参数说明&#xff1a;返回值&#xff1a;使用示例&#xff1a;示例代码&#xff1a; 说明&#xff1a; 前言 有时候使用的时候&a…

oneplus6-编译-LineageOS-19.1-android12

lineage-19.1/oneplus6-build.md 修复内核崩溃 经过此两修改后, 编译出的OTA包 刷入手机, 手机重启正常越过logo 进入android, 但卡在LineageOS-19的弧形进度界面, 没有此两修改时, 根本进不到android, 只到开机logo就黑屏 亮呼吸灯 , 串口处于900E(高通ramdump模式), 因此…

C++单例模式实现

单例模式&#xff08;Singleton Pattern&#xff09;是软件设计模式中的一种&#xff0c;用于确保一个类只有一个实例&#xff0c;并提供一个全局访问点来获取这个实例。 一、初始版本&#xff08;手动创建释放&#xff09; 一个类只有一个实例的实现方法&#xff1a; 隐藏构…

超好用shell脚本NuShell mac安装

利用管道控制任意系统 Nu 可以在 Linux、macOS 和 Windows 上运行。一次学习&#xff0c;处处可用。 一切皆数据 Nu 管道使用结构化数据&#xff0c;你可以用同样的方式安全地选择&#xff0c;过滤和排序。停止解析字符串&#xff0c;开始解决问题。 强大的插件系统 具备强…

OpenJudge_ 简单英文题_04:0/1 Knapsack

题目 描述 Given the weights and values of N items, put a subset of items into a knapsack of capacity C to get the maximum total value in the knapsack. The total weight of items in the knapsack does not exceed C. 输入 First line: two positive integers N (…

算法训练(leetcode)二刷第二十六天 | *452. 用最少数量的箭引爆气球、435. 无重叠区间、*763. 划分字母区间

刷题记录 *452. 用最少数量的箭引爆气球435. 无重叠区间*763. 划分字母区间笨拙版进阶版 *452. 用最少数量的箭引爆气球 leetcode题目地址 先对气球的坐标按照Xstart进行升序排序&#xff0c;只要两个气球之间挨着就可以一箭射穿&#xff0c;因此排序后查看后一个气球的起始坐…

第12章 系统部署

12.1 Kickstart使用背景介绍 随着公司业务不断增加,经常需要采购新服务器,并要求安装Linux系统,并且要求Linux版本要一致,方便以后的维护和管理,每次人工安装linux系统会浪费掉更多时间,如果我们有办法能节省一次一次的时间岂不更好呢? 大中型互联网公司一次采购服务器…

深入探讨LINQ中的数据分块(Chunk)方法及其应用

LINQ作为C#的核心特性之一&#xff0c;大大简化了数据操作的复杂性。它不仅能够通过声明式的语法进行数据查询&#xff0c;还能实现复杂的数据操作&#xff0c;比如筛选、排序、分组等。而在众多LINQ操作中&#xff0c;Chunk方法作为一种数据分块功能&#xff0c;能够让开发者更…

【Window主机访问Ubuntu从机——Xrdp配置与使用】

使用Xrdp在Window环境下远程桌面访问Ubuntu主机 文章目录 Ubuntu安装图形化界面Ubuntu安装Xrdp通过网线连接两台主机Window主机有线连接配置Ubuntu从机设置测试有线连接 Window主机打开远程桌面功能参考文章总结 Ubuntu安装图形化界面 sudo apt update sudo apt upgrade sudo …

ECharts图表图例8

用eclipse软件制作动态单仪表图 用java知识点 代码截图&#xff1a;