HQL(JPQL)和原生SQL实现查询自定义返回类
维修申请实例RepairApplyInstance:
package com.byx.scaffold.common.entity.jpa;
import com.byx.scaffold.common.entity.jpaEnum.RepairStatusConstant;
import lombok.Data;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;
/**
* 维修申请实例
* @author xiaoping
* @date 2024/12/26
**/
@Data
@Table(name = "repair_apply_instance")
@Entity(name = "common_RepairApplyInstance") //若存在同名Bean,可定义name区分
public class RepairApplyInstance {
@Id // 默认使用 uuid
private String businessKey;
/** 工单编号(区域编号+日期+时间+uuid前八位) */
private String repairNumber;
/** 工单类型 */
private String orderType;
/** 故障类型,多个故障以“;”隔开 */
private String faultTypes;
/** 故障描述 */
private String faultDescription;
/** 维修优先级(一级,二级,三级) */
private String priority;
/** 故障时间 */
private LocalDateTime faultTime;
/** 备注 */
private String remark;
/** 开始时间 */
private LocalDateTime startTime;
/** 结束时间 */
private LocalDateTime endTime;
/** 区分平台报修和导入(0:人工;1:市局,2:巡检) */
private int platformRepair;
/** 工单状态(-4:已移交,-3:关闭,-2:取消,-1:拒绝,0:待响应,1:维修中,2:待观察,3:维修完成) */
@Convert(converter = RepairStatusConstant.RepairStatusEnumConverter.class)
private RepairStatusConstant repairStatus;
}
工单对应设备RepairDevice:
package com.byx.scaffold.common.entity.jpa;
import lombok.Data;
import javax.persistence.*;
/**
* @author xiaoping
* @date 2024/12/26
**/
@Data
@Table(name = "repair_devices")
@Entity(name = "common_RepairDevice")
public class RepairDevice {
@Id
private String id;
/** 设备编号 */
private String deviceNumber;
/** 设备名称 */
private String deviceName;
/** 设备类型 */
private String deviceType;
/** 设备品牌 */
private String deviceBrand;
/**
* 设备使用状态
*/
private String deviceState;
/** 维修工单 */
@ManyToOne
@JoinColumn(name = "business_key") // TODO 把 order_id 改为这个
private RepairApplyInstance applyInstance;
/** 对应设备总览的UUID */
private String deviceUUID;
}
枚举类RepairStatusConstant:
package com.byx.scaffold.common.entity.jpaEnum;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* 维修工单对应状态枚举
*
* @author xiaoPing
* @createdTime 2022年3月31日下午1:52:35
*/
public enum RepairStatusConstant implements BaseEnum<Integer> {
TRANSFER(-4, "已移交"),
CLOSED(-3, "关闭"),
CANCEL(-2, "取消"),
REJECTED(-1, "拒绝"),
WAIT_RESPONSE(0, "待响应"),
REPAIRING (1, "维修中"),
WAIT_OBSERVE (2, "待观察"),
FINISHED(3, "维修完成");
// 维修工单状态key
private final Integer value;
// 维修工单状态
private final String statusName;
RepairStatusConstant(Integer value, String statusName) {
this.value = value;
this.statusName = statusName;
}
原文地址:https://blog.csdn.net/gp_911014/article/details/145137557
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!