feat(dms): 新增停机记录功能并优化PDA接口(新老两种设备)

- 有两种设备,旧设备不能采集数据只能由PDA手持提交停机记录,另一种是新设备可以自动生成停机记录(包括停机开始时间和结束时间),但停机原因默认为1自动填写,需要手持PDA或者网页进行统计原因的修改更新。listOldDevices返回的就是全部旧设备用于提交插入停机记录。getShutDownForPda返回给PDA的停机记录只有停机结束时间shutEndTime为空或者停机原因SHUT_REASON_ID为1的停机记录列表。completeShutDownForPda若是遇到停机结束时间shutEndTime为空的就需要更新停机结束时间和停机原因主键SHUT_REASON_ID(老设备),若是停机结束时间shutEndTime不为空则只更新停机原因主键SHUT_REASON_ID(新设备)。
- 添加SEQ_DMS_REC_SHUT_DOWN序列用于停机记录ID生成
- 新增shutReasonId和downtimeFlag字段到DmsRecordShutDown实体类
- 实现PDA停机记录增删改查接口,支持待处理记录查询
- 添加异常处理机制,统一抛出ServiceException
- 更新三色灯状态参数映射,将机台状态参数ID改为991-993
- 优化停机记录更新逻辑,区分新老设备处理方式
- 添加设备编码和名称关联查询功能
master
zangch@mesnac.com 1 week ago
parent 18aee3074b
commit 0cd68eed0f

@ -463,6 +463,23 @@ CREATE SEQUENCE "HAIWEI"."SEQ_DMS_REPAIR_WORK_ORDER"
INCREMENT BY 1
CACHE 20;
-- ----------------------------
-- 28. SEQ_DMS_REC_SHUT_DOWN (停机记录)
-- 表: DMS_RECORD_SHUT_DOWN
-- ----------------------------
BEGIN
EXECUTE IMMEDIATE 'DROP SEQUENCE "HAIWEI"."SEQ_DMS_REC_SHUT_DOWN"';
EXCEPTION
WHEN OTHERS THEN NULL;
END;
/
CREATE SEQUENCE "HAIWEI"."SEQ_DMS_REC_SHUT_DOWN"
MINVALUE 1
MAXVALUE 9999999999999999999999999999
START WITH 1
INCREMENT BY 1
CACHE 20;
-- ============================================
-- 序列对齐:按 MAX(主键列)+1 设置 NEXTVALOracle 11g 兼容方案)
-- ============================================
@ -569,6 +586,8 @@ BEGIN
sync_seq('HAIWEI.SEQ_DMS_REPAIR_RECORD', 'HAIWEI.DMS_REPAIR_RECORD', 'RECORD_ID');
-- 27. 维修工单
sync_seq('HAIWEI.SEQ_DMS_REPAIR_WORK_ORDER', 'HAIWEI.DMS_REPAIR_WORK_ORDER', 'WORK_ORDER_ID');
-- 28. 停机记录
sync_seq('HAIWEI.SEQ_DMS_REC_SHUT_DOWN', 'HAIWEI.DMS_RECORD_SHUT_DOWN', 'RECORD_SHUT_DOWN_ID');
-- 为所有序列授权 + 创建公共同义词(保证跨 schema 应用可用)
grant_and_synonym('SEQ_DMS_INSPECT_PROJ');
@ -598,12 +617,13 @@ BEGIN
grant_and_synonym('SEQ_DMS_REPAIR_PROJECT');
grant_and_synonym('SEQ_DMS_REPAIR_RECORD');
grant_and_synonym('SEQ_DMS_REPAIR_WORK_ORDER');
grant_and_synonym('SEQ_DMS_REC_SHUT_DOWN');
END;
/
-- ============================================
-- 执行完成提示
-- ============================================
-- 共创建 27 个序列,已按 MAX(主键)+1 对齐,已授权+同义词
-- 共创建 28 个序列,已按 MAX(主键)+1 对齐,已授权+同义词
-- 验证:
-- SELECT SEQUENCE_NAME, LAST_NUMBER FROM ALL_SEQUENCES WHERE SEQUENCE_OWNER='HAIWEI' AND (SEQUENCE_NAME LIKE 'SEQ_DMS%' OR SEQUENCE_NAME LIKE 'SEQ_FAULT%');

@ -4,6 +4,7 @@ package com.aucma.dms.controller;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.exception.ServiceException;
import com.aucma.dms.domain.*;
import com.aucma.dms.domain.dto.DmsBaseDeviceLedgerDTO;
import com.aucma.dms.domain.vo.DmsBillsFaultInstanceScanVo;
@ -92,16 +93,21 @@ public class DmsMobileController extends BaseController {
*/
@GetMapping("/getDeviceByDeviceCode/{deviceCode}")
public AjaxResult getDeviceByDeviceCode(@PathVariable("deviceCode") String deviceCode) {
BaseDeviceLedger query = new BaseDeviceLedger();
query.setDeviceCode(deviceCode);
query.setIsFlag(1L); // 只查询有效设备
List<BaseDeviceLedger> list = baseDeviceLedgerService.selectBaseDeviceLedgerList(query);
if (CollectionUtils.isEmpty(list)) {
return success(null);
try {
BaseDeviceLedger query = new BaseDeviceLedger();
query.setDeviceCode(deviceCode);
query.setIsFlag(1L); // 只查询有效设备
List<BaseDeviceLedger> list = baseDeviceLedgerService.selectBaseDeviceLedgerList(query);
if (CollectionUtils.isEmpty(list)) {
return success(null);
}
// 转换为DmsBaseDeviceLedger返回保持PDA兼容性
DmsBaseDeviceLedger result = convertToDeviceLedger(list.get(0));
return success(convertDeviceLedgerToDto(result));
} catch (Exception e) {
log.error("PDA查询设备信息失败 | deviceCode={}, 异常信息: {}", deviceCode, e.getMessage(), e);
throw new ServiceException("获取设备信息失败: " + e.getMessage());
}
// 转换为DmsBaseDeviceLedger返回保持PDA兼容性
DmsBaseDeviceLedger result = convertToDeviceLedger(list.get(0));
return success(convertDeviceLedgerToDto(result));
}
/**
@ -113,18 +119,23 @@ public class DmsMobileController extends BaseController {
*/
@GetMapping("/likeDeviceName")
public AjaxResult likeDeviceName(String deviceName) {
BaseDeviceLedger query = new BaseDeviceLedger();
query.setDeviceName(deviceName);
query.setIsFlag(1L); // 只查询有效设备
List<BaseDeviceLedger> list = baseDeviceLedgerService.selectBaseDeviceLedgerList(query);
// 转换为DmsBaseDeviceLedger列表返回保持PDA兼容性
List<DmsBaseDeviceLedgerDTO> resultList = new ArrayList<>();
if (!CollectionUtils.isEmpty(list)) {
for (BaseDeviceLedger base : list) {
resultList.add(convertDeviceLedgerToDto(convertToDeviceLedger(base)));
try {
BaseDeviceLedger query = new BaseDeviceLedger();
query.setDeviceName(deviceName);
query.setIsFlag(1L); // 只查询有效设备
List<BaseDeviceLedger> list = baseDeviceLedgerService.selectBaseDeviceLedgerList(query);
// 转换为DmsBaseDeviceLedger列表返回保持PDA兼容性
List<DmsBaseDeviceLedgerDTO> resultList = new ArrayList<>();
if (!CollectionUtils.isEmpty(list)) {
for (BaseDeviceLedger base : list) {
resultList.add(convertDeviceLedgerToDto(convertToDeviceLedger(base)));
}
}
return success(resultList);
} catch (Exception e) {
log.error("PDA模糊查询设备失败 | deviceName={}, 异常信息: {}", deviceName, e.getMessage(), e);
throw new ServiceException("查询设备失败: " + e.getMessage());
}
return success(resultList);
}
/**
@ -265,72 +276,129 @@ public class DmsMobileController extends BaseController {
@PostMapping("/shutDown/add")
@Transactional(rollbackFor = Exception.class)
public AjaxResult addShutDownForPda(@RequestBody DmsRecordShutDown shutDown) {
// 若传入了停机原因ID则查询原因并回填类型
if (shutDown.getShutReason() != null) {
DmsBaseShutReason query = new DmsBaseShutReason();
query.setShutReason(shutDown.getShutReason());
query.setIsFlag("1");
List<DmsBaseShutReason> reasons = dmsBaseShutReasonService.selectDmsBaseShutReasonList(query);
if (!reasons.isEmpty()) {
shutDown.setShutType(reasons.get(0).getShutTypeId());
// 若前端未传 deviceId尝试从原因带出
if (shutDown.getDeviceId() == null) {
shutDown.setDeviceId(reasons.get(0).getDeviceId());
try {
// 若传入了停机原因ID则查询原因并回填类型
if (shutDown.getShutReason() != null) {
DmsBaseShutReason query = new DmsBaseShutReason();
query.setShutReason(shutDown.getShutReason());
query.setIsFlag("1");
List<DmsBaseShutReason> reasons = dmsBaseShutReasonService.selectDmsBaseShutReasonList(query);
if (!reasons.isEmpty()) {
shutDown.setShutType(reasons.get(0).getShutTypeId());
shutDown.setShutReasonId(reasons.get(0).getShutReasonId());
// 若前端未传 deviceId尝试从原因带出
if (shutDown.getDeviceId() == null) {
shutDown.setDeviceId(reasons.get(0).getDeviceId());
}
}
}
}
// 默认启用标识
if (shutDown.getIsFlag() == null) {
shutDown.setIsFlag(1L);
}
// 若未传入开始时间,则使用当前时间
if (shutDown.getShutBeginTime() == null) {
shutDown.setShutBeginTime(new Date());
}
int rows = dmsRecordShutDownService.insertDmsRecordShutDown(shutDown);
// 默认启用标识
if (shutDown.getIsFlag() == null) {
shutDown.setIsFlag(1L);
}
// 新增停机记录默认未结束
if (shutDown.getDowntimeFlag() == null) {
shutDown.setDowntimeFlag("0");
}
// 若未传入开始时间,则使用当前时间
if (shutDown.getShutBeginTime() == null) {
shutDown.setShutBeginTime(new Date());
}
int rows = dmsRecordShutDownService.insertDmsRecordShutDown(shutDown);
// 对指定设备OLD-01~OLD-05同步写入三色灯状态参数供设备状态统计使用
String deviceCode = shutDown.getDeviceCode();
if (deviceCode != null && deviceCode.startsWith("OLD-")) {
// 新增停机记录代表进入停机,三色灯置为“暂停”
insertTriColorStatusParams(deviceCode, shutDown.getDeviceId(), false);
}
// 对指定设备OLD-01~OLD-05同步写入三色灯状态参数供设备状态统计使用
String deviceCode = shutDown.getDeviceCode();
if (deviceCode != null && deviceCode.startsWith("OLD-")) {
// 新增停机记录代表进入停机,三色灯置为“暂停”
insertTriColorStatusParams(deviceCode, shutDown.getDeviceId(), false);
}
return success(rows);
return success(rows);
} catch (Exception e) {
log.error("PDA新增停机记录失败 | deviceCode={}, shutReason={}, deviceId={}, 异常信息: {}",
shutDown.getDeviceCode(), shutDown.getShutReason(), shutDown.getDeviceId(), e.getMessage(), e);
throw new ServiceException("新增停机记录失败: " + e.getMessage());
}
}
/**
* PDA-
* PDA-
* ID=1
*/
@GetMapping("/shutDown/get")
public AjaxResult getShutDownForPda() {
try {
List<DmsRecordShutDown> list = dmsRecordShutDownService.selectPdaShutDownList();
return success(list);
} catch (Exception e) {
log.error("PDA获取待处理停机记录失败 | 异常信息: {}", e.getMessage(), e);
throw new ServiceException("获取停机记录失败: " + e.getMessage());
}
}
/**
* PDA-
* shutEndTimeID
* shutEndTimeID
*/
@PostMapping("/shutDown/complete")
@Transactional(rollbackFor = Exception.class)
public AjaxResult completeShutDownForPda(@RequestBody DmsRecordShutDown shutDown) {
if (shutDown.getRecordShutDownId() == null) {
return error("recordShutDownId不能为空");
throw new ServiceException("recordShutDownId不能为空");
}
// 查询原记录以获取开始时间
DmsRecordShutDown origin = dmsRecordShutDownService.selectDmsRecordShutDownByRecordShutDownId(shutDown.getRecordShutDownId());
if (origin == null) {
return error("停机记录不存在");
if (shutDown.getShutReasonId() == null) {
throw new ServiceException("shutReasonId不能为空");
}
try {
// 查询原记录
DmsRecordShutDown origin = dmsRecordShutDownService.selectDmsRecordShutDownByRecordShutDownId(shutDown.getRecordShutDownId());
if (origin == null) {
throw new ServiceException("停机记录不存在");
}
Date end = new Date();
Date begin = origin.getShutBeginTime();
shutDown.setShutEndTime(end);
if (begin != null) {
long minutes = Math.max(0, (end.getTime() - begin.getTime()) / 60000);
shutDown.setShutTime(BigDecimal.valueOf(minutes));
}
// 构建更新对象,仅设置需要更新的字段
DmsRecordShutDown updateRecord = new DmsRecordShutDown();
updateRecord.setRecordShutDownId(shutDown.getRecordShutDownId());
updateRecord.setShutReasonId(shutDown.getShutReasonId());
int rows = dmsRecordShutDownService.updateDmsRecordShutDown(shutDown);
// 对指定设备OLD-01~OLD-05同步写入三色灯状态参数供设备状态统计使用
String deviceCode = shutDown.getDeviceCode() != null ? shutDown.getDeviceCode() : origin.getDeviceCode();
Long deviceId = shutDown.getDeviceId() != null ? shutDown.getDeviceId() : origin.getDeviceId();
if (deviceCode != null && deviceCode.startsWith("OLD-")) {
// 完成停机代表重新运行,三色灯置为“运行”
insertTriColorStatusParams(deviceCode, deviceId, true);
if (origin.getShutEndTime() == null) {
// 老设备:标记停机已结束
updateRecord.setDowntimeFlag("1");
// 老设备:补充结束时间和停机时长
Date end = new Date();
Date begin = origin.getShutBeginTime();
updateRecord.setShutEndTime(end);
if (begin != null) {
long minutes = Math.max(0, (end.getTime() - begin.getTime()) / 60000);
updateRecord.setShutTime(BigDecimal.valueOf(minutes));
}
}
// 新设备shutEndTime已有值仅更新shutReasonId无需额外处理
int rows = dmsRecordShutDownService.updateDmsRecordShutDown(updateRecord);
// 对老设备OLD-01~OLD-05同步写入三色灯状态参数
if (origin.getShutEndTime() == null && origin.getDeviceId() != null) {
// 原记录不含deviceCode需通过deviceId反查设备编号
BaseDeviceLedger deviceQuery = new BaseDeviceLedger();
deviceQuery.setObjId(origin.getDeviceId());
List<BaseDeviceLedger> devices = baseDeviceLedgerService.selectBaseDeviceLedgerList(deviceQuery);
if (!devices.isEmpty()) {
String deviceCode = devices.get(0).getDeviceCode();
if (deviceCode != null && deviceCode.startsWith("OLD-")) {
// 完成停机代表重新运行,三色灯置为"运行"
insertTriColorStatusParams(deviceCode, origin.getDeviceId(), true);
}
}
}
return rows > 0 ? success(origin.getRecordShutDownId()) : error("更新停机记录失败");
} catch (Exception e) {
log.error("PDA完成停机记录失败 | recordShutDownId={}, shutReasonId={}, 异常信息: {}",
shutDown.getRecordShutDownId(), shutDown.getShutReasonId(), e.getMessage(), e);
throw new ServiceException("完成停机失败: " + e.getMessage());
}
return rows > 0 ? success(origin.getRecordShutDownId()) : error("更新停机记录失败");
}
/**
@ -361,9 +429,9 @@ public class DmsMobileController extends BaseController {
List<BaseDeviceParamVal> records = new ArrayList<>();
String runVal = running ? "True" : "False";
String pauseVal = running ? "False" : "True";
records.add(buildParamVal("295", deviceCode, resolvedDeviceId, "机台状态-三色灯机器运行", runVal, now));
records.add(buildParamVal("296", deviceCode, resolvedDeviceId, "机台状态-三色灯机器暂停", pauseVal, now));
records.add(buildParamVal("297", deviceCode, resolvedDeviceId, "机台状态-三色灯机器报警", "False", now));
records.add(buildParamVal("991", deviceCode, resolvedDeviceId, "机台状态-三色灯机器运行", runVal, now));
records.add(buildParamVal("992", deviceCode, resolvedDeviceId, "机台状态-三色灯机器暂停", pauseVal, now));
records.add(buildParamVal("993", deviceCode, resolvedDeviceId, "机台状态-三色灯机器报警", "False", now));
for (BaseDeviceParamVal rec : records) {
baseDeviceParamValService.insertBaseDeviceParamVal(rec);

@ -8,8 +8,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
/**
* dms_record_shut_down
*
@ -31,6 +29,10 @@ public class DmsRecordShutDown extends DmsBaseEntity
@Excel(name = "停机类型ID关联dm_base_shut_type的shut_type_id")
private Long shutType;
/** 停机原因ID关联dms_base_shut_reason的shut_reason_id */
@Excel(name = "停机原因ID")
private Long shutReasonId;
/** 停机原因 */
@Excel(name = "停机原因")
private String shutReason;
@ -49,6 +51,10 @@ public class DmsRecordShutDown extends DmsBaseEntity
@Excel(name = "停机时长")
private BigDecimal shutTime;
/** 停机标识0未结束 1已结束 */
@Excel(name = "停机标识")
private String downtimeFlag;
/** 是否标识1-是2-否 */
@Excel(name = "是否标识1-是2-否")
private Long isFlag;
@ -56,6 +62,9 @@ public class DmsRecordShutDown extends DmsBaseEntity
/** 设备编码(查询用,非持久化字段) */
private String deviceCode;
/** 设备名称(查询用,非持久化字段) */
private String deviceName;
public String getDeviceCode() {
return deviceCode;
}
@ -64,6 +73,30 @@ public class DmsRecordShutDown extends DmsBaseEntity
this.deviceCode = deviceCode;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
public Long getShutReasonId() {
return shutReasonId;
}
public void setShutReasonId(Long shutReasonId) {
this.shutReasonId = shutReasonId;
}
public String getDowntimeFlag() {
return downtimeFlag;
}
public void setDowntimeFlag(String downtimeFlag) {
this.downtimeFlag = downtimeFlag;
}
public void setRecordShutDownId(Long recordShutDownId)
{
this.recordShutDownId = recordShutDownId;
@ -143,10 +176,14 @@ public class DmsRecordShutDown extends DmsBaseEntity
.append("recordShutDownId", getRecordShutDownId())
.append("deviceId", getDeviceId())
.append("shutType", getShutType())
.append("shutReasonId", getShutReasonId())
.append("shutReason", getShutReason())
.append("deviceCode", getDeviceCode())
.append("deviceName", getDeviceName())
.append("shutBeginTime", getShutBeginTime())
.append("shutEndTime", getShutEndTime())
.append("shutTime", getShutTime())
.append("downtimeFlag", getDowntimeFlag())
.append("isFlag", getIsFlag())
.append("remark", getRemark())
.append("createBy", getCreateBy())

@ -59,4 +59,11 @@ public interface DmsRecordShutDownMapper
* @return
*/
public int deleteDmsRecordShutDownByRecordShutDownIds(Long[] recordShutDownIds);
/**
* PDA ID=1
*
* @return
*/
public List<DmsRecordShutDown> selectPdaShutDownList();
}

@ -59,4 +59,11 @@ public interface IDmsRecordShutDownService
* @return
*/
public int deleteDmsRecordShutDownByRecordShutDownId(Long recordShutDownId);
/**
* PDA ID=1
*
* @return
*/
public List<DmsRecordShutDown> selectPdaShutDownList();
}

@ -99,4 +99,15 @@ public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService
{
return dmsRecordShutDownMapper.deleteDmsRecordShutDownByRecordShutDownId(recordShutDownId);
}
/**
* PDA ID=1
*
* @return
*/
@Override
public List<DmsRecordShutDown> selectPdaShutDownList()
{
return dmsRecordShutDownMapper.selectPdaShutDownList();
}
}

@ -8,67 +8,82 @@
<result property="recordShutDownId" column="record_shut_down_id"/>
<result property="deviceId" column="device_id"/>
<result property="shutType" column="shut_type"/>
<result property="shutReasonId" column="shut_reason_id"/>
<result property="shutReason" column="shut_reason"/>
<result property="shutBeginTime" column="shut_begin_time"/>
<result property="shutEndTime" column="shut_end_time"/>
<result property="shutTime" column="shut_time"/>
<result property="downtimeFlag" column="downtime_flag"/>
<result property="isFlag" column="is_flag"/>
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="deviceCode" column="device_code"/>
<result property="deviceName" column="device_name"/>
</resultMap>
<!-- 注意实际表字段名与XML定义不同已修正字段映射 -->
<!-- 关联base_deviceledger查询设备编码和名称使用resultMap映射物理列名 -->
<sql id="selectDmsRecordShutDownVo">
select record_shut_down_id,
machine_id as device_id,
shut_type_id as shut_type,
shut_reason,
shut_begin_time,
shut_end_time,
shut_time,
active_flag as is_flag,
remark,
create_by,
create_time,
update_by,
update_time
from dms_record_shut_down
select r.record_shut_down_id,
r.machine_id as device_id,
r.shut_type_id as shut_type,
r.shut_reason_id,
r.shut_reason,
r.shut_begin_time,
r.shut_end_time,
r.shut_time,
r.downtime_flag,
r.active_flag as is_flag,
r.remark,
r.create_by,
r.create_time,
r.update_by,
r.update_time,
d.device_code as device_code,
d.device_name as device_name
from dms_record_shut_down r
left join base_deviceledger d on r.machine_id = d.OBJ_ID
</sql>
<select id="selectDmsRecordShutDownList" parameterType="DmsRecordShutDown" resultMap="DmsRecordShutDownResult">
<include refid="selectDmsRecordShutDownVo"/>
<where>
<if test="shutType != null ">and shut_type_id = #{shutType}</if>
<if test="shutReason != null and shutReason != ''">and shut_reason = #{shutReason}</if>
<if test="shutType != null ">and r.shut_type_id = #{shutType}</if>
<if test="shutReason != null and shutReason != ''">and r.shut_reason = #{shutReason}</if>
<if test="params != null and params.beginTime != null and params.endTime != null">
and shut_begin_time between #{params.beginTime} and #{params.endTime}
and r.shut_begin_time between #{params.beginTime} and #{params.endTime}
</if>
<if test="shutBeginTime != null ">and shut_begin_time &gt;= #{shutBeginTime}</if>
<if test="shutEndTime != null ">and #{shutEndTime} &gt;= shut_end_time</if>
<if test="shutTime != null ">and shut_time = #{shutTime}</if>
<if test="deviceCode != null and deviceCode != ''">and machine_id in (select OBJ_ID from base_deviceledger where device_code = #{deviceCode})</if>
<if test="shutBeginTime != null ">and r.shut_begin_time &gt;= #{shutBeginTime}</if>
<if test="shutEndTime != null ">and #{shutEndTime} &gt;= r.shut_end_time</if>
<if test="shutTime != null ">and r.shut_time = #{shutTime}</if>
<if test="deviceCode != null and deviceCode != ''">and d.device_code = #{deviceCode}</if>
<if test="deviceName != null and deviceName != ''">and d.device_name like concat(concat('%', #{deviceName}), '%')</if>
</where>
</select>
<select id="selectDmsRecordShutDownByRecordShutDownId" parameterType="Long" resultMap="DmsRecordShutDownResult">
<include refid="selectDmsRecordShutDownVo"/>
where record_shut_down_id = #{recordShutDownId}
where r.record_shut_down_id = #{recordShutDownId}
</select>
<insert id="insertDmsRecordShutDown" parameterType="DmsRecordShutDown" useGeneratedKeys="true"
keyProperty="recordShutDownId">
<insert id="insertDmsRecordShutDown" parameterType="DmsRecordShutDown">
<selectKey keyProperty="recordShutDownId" resultType="long" order="BEFORE">
SELECT SEQ_DMS_REC_SHUT_DOWN.NEXTVAL FROM DUAL
</selectKey>
insert into dms_record_shut_down
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deviceId != null">device_id,</if>
<if test="shutType != null">shut_type,</if>
record_shut_down_id,
<if test="deviceId != null">machine_id,</if>
<if test="shutType != null">shut_type_id,</if>
<if test="shutReasonId != null">shut_reason_id,</if>
<if test="shutReason != null">shut_reason,</if>
<if test="shutBeginTime != null">shut_begin_time,</if>
<if test="shutEndTime != null">shut_end_time,</if>
<if test="shutTime != null">shut_time,</if>
<if test="isFlag != null">is_flag,</if>
<if test="downtimeFlag != null">downtime_flag,</if>
<if test="isFlag != null">active_flag,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
@ -76,12 +91,15 @@
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{recordShutDownId},
<if test="deviceId != null">#{deviceId},</if>
<if test="shutType != null">#{shutType},</if>
<if test="shutReasonId != null">#{shutReasonId},</if>
<if test="shutReason != null">#{shutReason},</if>
<if test="shutBeginTime != null">#{shutBeginTime},</if>
<if test="shutEndTime != null">#{shutEndTime},</if>
<if test="shutTime != null">#{shutTime},</if>
<if test="downtimeFlag != null">#{downtimeFlag},</if>
<if test="isFlag != null">#{isFlag},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
@ -94,13 +112,15 @@
<update id="updateDmsRecordShutDown" parameterType="DmsRecordShutDown">
update dms_record_shut_down
<trim prefix="SET" suffixOverrides=",">
<if test="deviceId != null">device_id = #{deviceId},</if>
<if test="shutType != null">shut_type = #{shutType},</if>
<if test="deviceId != null">machine_id = #{deviceId},</if>
<if test="shutType != null">shut_type_id = #{shutType},</if>
<if test="shutReasonId != null">shut_reason_id = #{shutReasonId},</if>
<if test="shutReason != null">shut_reason = #{shutReason},</if>
<if test="shutBeginTime != null">shut_begin_time = #{shutBeginTime},</if>
<if test="shutEndTime != null">shut_end_time = #{shutEndTime},</if>
<if test="shutTime != null">shut_time = #{shutTime},</if>
<if test="isFlag != null">is_flag = #{isFlag},</if>
<if test="downtimeFlag != null">downtime_flag = #{downtimeFlag},</if>
<if test="isFlag != null">active_flag = #{isFlag},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
@ -110,6 +130,13 @@
where record_shut_down_id = #{recordShutDownId}
</update>
<select id="selectPdaShutDownList" resultMap="DmsRecordShutDownResult">
<include refid="selectDmsRecordShutDownVo"/>
where r.active_flag = '1'
and (r.shut_end_time is null or r.shut_reason_id = 1)
order by r.create_time desc
</select>
<delete id="deleteDmsRecordShutDownByRecordShutDownId" parameterType="Long">
delete
from dms_record_shut_down

Loading…
Cancel
Save