feat: 新增停机原因推荐与树结构功能,优化列表排序规则

1. 新增停机原因相关VO类与控制器接口,实现停机原因树查询和推荐列表功能
2. 重构停机记录批量更新逻辑,补充停机类型和原因名称字段同步
3. 全模块列表统一改为主键倒序排序,解决分页顺序不稳定问题
4. 增加停机原因使用频次统计,支持按设备/产线/全局维度排序展示
master
zch 1 month ago
parent 1240402c94
commit 1f72d4837b

@ -116,7 +116,8 @@
to_date(#{params.endEndTime}, 'yyyy-mm-dd')
</if>
</where>
order by oi.material_name, order_code desc
<!-- 列表页按主键倒序展示,优先查看最新同步/维护的工单 -->
order by oi.obj_id desc
</select>
<select id="selectBaseOrderInfoByObjId" parameterType="Long" resultMap="BaseOrderInfoResult">
@ -134,7 +135,8 @@
</if>
<if test="workCenterCode != null ">and oi.work_center_code = #{workCenterCode}</if>
</where>
order by oi.material_name, order_code desc
<!-- 全量工单列表同样按主键倒序,保持后台列表入口展示规则一致 -->
order by oi.obj_id desc
</select>
<select id="selectPdaOrderListByMaterialCodes" resultMap="BaseOrderInfoResult">

@ -76,7 +76,8 @@
<if test="vbpos != null and vbpos != ''">and ob.vbpos = #{vbpos}</if>
<if test="ancestors != null and ancestors != ''">and ob.ancestors like concat(concat('%', #{ancestors}), '%')</if>
</where>
order by ob.parent_id, ob.sort
<!-- 列表页按主键倒序展示避免新增BOM被父项/排序号分散到旧数据中 -->
order by ob.obj_id desc
</select>
<select id="selectOrderBomInfoByObjId" parameterType="Long" resultMap="OrderBomInfoResult">

@ -107,5 +107,23 @@ public class DmsBaseShutReasonController extends BaseController
List<DmsBaseShutReason> list = dmsBaseShutReasonService.selectDmsBaseShutReasonList(dmsBaseShutReason);
return AjaxResult.success(list);
}
/**
*
*/
@GetMapping("/tree")
public AjaxResult tree(@RequestParam(value = "deviceId", required = false) Long deviceId)
{
return success(dmsBaseShutReasonService.selectShutReasonTree(deviceId));
}
/**
*
*/
@GetMapping("/recommend")
public AjaxResult recommend(@RequestParam(value = "deviceId", required = false) Long deviceId)
{
return success(dmsBaseShutReasonService.selectRecommendShutReasonList(deviceId));
}
}

@ -40,6 +40,15 @@ public class DmsBaseShutReason extends DmsBaseEntity
private String isFlag;
private String deviceName;
/** 近90天当前设备使用次数非持久化字段 */
private Long deviceFreq;
/** 近90天当前产线使用次数非持久化字段 */
private Long lineFreq;
/** 近180天全局使用次数非持久化字段 */
private Long globalFreq;
public String getDeviceName() {
return deviceName;
}
@ -103,6 +112,36 @@ public class DmsBaseShutReason extends DmsBaseEntity
return isFlag;
}
public Long getDeviceFreq()
{
return deviceFreq;
}
public void setDeviceFreq(Long deviceFreq)
{
this.deviceFreq = deviceFreq;
}
public Long getLineFreq()
{
return lineFreq;
}
public void setLineFreq(Long lineFreq)
{
this.lineFreq = lineFreq;
}
public Long getGlobalFreq()
{
return globalFreq;
}
public void setGlobalFreq(Long globalFreq)
{
this.globalFreq = globalFreq;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -112,6 +151,9 @@ public class DmsBaseShutReason extends DmsBaseEntity
.append("shutTypeId", getShutTypeId())
.append("shutReason", getShutReason())
.append("isFlag", getIsFlag())
.append("deviceFreq", getDeviceFreq())
.append("lineFreq", getLineFreq())
.append("globalFreq", getGlobalFreq())
.append("remark", getRemark())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())

@ -0,0 +1,32 @@
package com.aucma.dms.domain.vo;
import com.aucma.dms.domain.DmsBaseEntity;
import lombok.Data;
/**
*
*
* @author Codex
* @date 2026-04-21
*/
@Data
public class DmsShutReasonRecommendVo extends DmsBaseEntity
{
private static final long serialVersionUID = 1L;
private Long shutReasonId;
private String reasonCode;
private String shutReason;
private Long shutTypeId;
private String shutTypeName;
private Long deviceFreq;
private Long lineFreq;
private Long globalFreq;
}

@ -0,0 +1,36 @@
package com.aucma.dms.domain.vo;
import com.aucma.dms.domain.DmsBaseEntity;
import com.aucma.dms.domain.DmsBaseShutReason;
import lombok.Data;
import java.util.List;
/**
*
*
* @author Codex
* @date 2026-04-21
*/
@Data
public class DmsShutReasonTreeVo extends DmsBaseEntity
{
private static final long serialVersionUID = 1L;
private Long shutTypeId;
private String typeCode;
private String shutTypeName;
private Integer reasonCount;
private Long deviceFreq;
private Long lineFreq;
private Long globalFreq;
private List<DmsBaseShutReason> reasonList;
}

@ -1,6 +1,8 @@
package com.aucma.dms.mapper;
import com.aucma.dms.domain.DmsBaseShutReason;
import com.aucma.dms.domain.vo.DmsShutReasonRecommendVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -28,6 +30,22 @@ public interface DmsBaseShutReasonMapper
*/
public List<DmsBaseShutReason> selectDmsBaseShutReasonList(DmsBaseShutReason dmsBaseShutReason);
/**
*
*
* @param deviceId ID
* @return
*/
public List<DmsBaseShutReason> selectAvailableShutReasonList(@Param("deviceId") Long deviceId);
/**
*
*
* @param deviceId ID
* @return
*/
public List<DmsShutReasonRecommendVo> selectRecommendReasonList(@Param("deviceId") Long deviceId);
/**
*
*

@ -78,7 +78,9 @@ public interface DmsRecordShutDownMapper
* @return
*/
public int batchUpdateShutReason(@Param("recordShutDownIds") Long[] recordShutDownIds,
@Param("shutReasonId") Long shutReasonId,
@Param("updateBy") Long updateBy,
@Param("shutReasonId") Long shutReasonId,
@Param("shutTypeId") Long shutTypeId,
@Param("shutReason") String shutReason,
@Param("updateBy") Long updateBy,
@Param("updateTime") java.util.Date updateTime);
}

@ -1,6 +1,8 @@
package com.aucma.dms.service;
import com.aucma.dms.domain.DmsBaseShutReason;
import com.aucma.dms.domain.vo.DmsShutReasonRecommendVo;
import com.aucma.dms.domain.vo.DmsShutReasonTreeVo;
import java.util.List;
@ -28,6 +30,22 @@ public interface IDmsBaseShutReasonService
*/
public List<DmsBaseShutReason> selectDmsBaseShutReasonList(DmsBaseShutReason dmsBaseShutReason);
/**
*
*
* @param deviceId ID
* @return
*/
public List<DmsShutReasonTreeVo> selectShutReasonTree(Long deviceId);
/**
*
*
* @param deviceId ID
* @return
*/
public List<DmsShutReasonRecommendVo> selectRecommendShutReasonList(Long deviceId);
/**
*
*

@ -13,12 +13,22 @@ import com.aucma.common.exception.ServiceException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.SecurityUtils;
import com.aucma.dms.domain.DmsBaseShutReason;
import com.aucma.dms.domain.DmsBaseShutType;
import com.aucma.dms.domain.vo.DmsShutReasonRecommendVo;
import com.aucma.dms.domain.vo.DmsShutReasonTreeVo;
import com.aucma.dms.mapper.DmsBaseShutReasonMapper;
import com.aucma.dms.service.IDmsBaseShutReasonService;
import com.aucma.dms.service.IDmsBaseShutTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* Service
@ -32,6 +42,9 @@ public class DmsBaseShutReasonServiceImpl implements IDmsBaseShutReasonService
@Autowired
private DmsBaseShutReasonMapper dmsBaseShutReasonMapper;
@Autowired
private IDmsBaseShutTypeService dmsBaseShutTypeService;
/**
*
*
@ -56,6 +69,166 @@ public class DmsBaseShutReasonServiceImpl implements IDmsBaseShutReasonService
return dmsBaseShutReasonMapper.selectDmsBaseShutReasonList(dmsBaseShutReason);
}
/**
*
*
* @param deviceId ID
* @return
*/
@Override
public List<DmsShutReasonTreeVo> selectShutReasonTree(Long deviceId)
{
DmsBaseShutType typeQuery = new DmsBaseShutType();
typeQuery.setIsFlag("1");
List<DmsBaseShutType> typeList = dmsBaseShutTypeService.selectDmsBaseShutTypeList(typeQuery);
List<DmsBaseShutReason> reasonList = dmsBaseShutReasonMapper.selectAvailableShutReasonList(deviceId);
if (CollectionUtils.isEmpty(typeList) || CollectionUtils.isEmpty(reasonList))
{
return Collections.emptyList();
}
Map<Long, List<DmsBaseShutReason>> reasonMap = reasonList.stream()
.collect(Collectors.groupingBy(DmsBaseShutReason::getShutTypeId, LinkedHashMap::new, Collectors.toList()));
List<DmsShutReasonTreeVo> treeList = new ArrayList<>();
boolean deviceScope = deviceId != null;
for (DmsBaseShutType type : typeList)
{
List<DmsBaseShutReason> currentReasonList = reasonMap.get(type.getShutTypeId());
if (CollectionUtils.isEmpty(currentReasonList))
{
continue;
}
currentReasonList = new ArrayList<>(currentReasonList);
// 为什么这样做:同一个大类下优先展示现场更常选择的小类,减少班组维护停机原因时的查找成本。
currentReasonList.sort((left, right) -> compareReasonByFrequency(left, right, deviceScope));
DmsShutReasonTreeVo treeVo = new DmsShutReasonTreeVo();
treeVo.setShutTypeId(type.getShutTypeId());
treeVo.setTypeCode(type.getTypeCode());
treeVo.setShutTypeName(type.getShutTypeName());
treeVo.setReasonCount(currentReasonList.size());
treeVo.setDeviceFreq(sumDeviceFreq(currentReasonList));
treeVo.setLineFreq(sumLineFreq(currentReasonList));
treeVo.setGlobalFreq(sumGlobalFreq(currentReasonList));
treeVo.setReasonList(currentReasonList);
treeList.add(treeVo);
}
// 为什么这样做:大类按其下原因的频次汇总排序,高频问题域会自然排在树的前面。
treeList.sort((left, right) -> compareTypeByFrequency(left, right, deviceScope));
return treeList;
}
private int compareReasonByFrequency(DmsBaseShutReason left, DmsBaseShutReason right, boolean deviceScope)
{
int result;
if (deviceScope)
{
result = compareFrequencyDesc(left.getDeviceFreq(), right.getDeviceFreq());
if (result != 0)
{
return result;
}
result = compareFrequencyDesc(left.getLineFreq(), right.getLineFreq());
if (result != 0)
{
return result;
}
}
result = compareFrequencyDesc(left.getGlobalFreq(), right.getGlobalFreq());
if (result != 0)
{
return result;
}
result = compareStringAsc(left.getReasonCode(), right.getReasonCode());
if (result != 0)
{
return result;
}
return compareLongAsc(left.getShutReasonId(), right.getShutReasonId());
}
private int compareTypeByFrequency(DmsShutReasonTreeVo left, DmsShutReasonTreeVo right, boolean deviceScope)
{
int result;
if (deviceScope)
{
result = compareFrequencyDesc(left.getDeviceFreq(), right.getDeviceFreq());
if (result != 0)
{
return result;
}
result = compareFrequencyDesc(left.getLineFreq(), right.getLineFreq());
if (result != 0)
{
return result;
}
}
result = compareFrequencyDesc(left.getGlobalFreq(), right.getGlobalFreq());
if (result != 0)
{
return result;
}
result = compareStringAsc(left.getTypeCode(), right.getTypeCode());
if (result != 0)
{
return result;
}
return compareLongAsc(left.getShutTypeId(), right.getShutTypeId());
}
private int compareFrequencyDesc(Long left, Long right)
{
return Long.compare(nullToZero(right), nullToZero(left));
}
private int compareStringAsc(String left, String right)
{
String leftValue = left == null ? "" : left;
String rightValue = right == null ? "" : right;
return leftValue.compareTo(rightValue);
}
private int compareLongAsc(Long left, Long right)
{
return Long.compare(nullToZero(left), nullToZero(right));
}
private Long sumDeviceFreq(List<DmsBaseShutReason> reasonList)
{
return reasonList.stream().mapToLong(reason -> nullToZero(reason.getDeviceFreq())).sum();
}
private Long sumLineFreq(List<DmsBaseShutReason> reasonList)
{
return reasonList.stream().mapToLong(reason -> nullToZero(reason.getLineFreq())).sum();
}
private Long sumGlobalFreq(List<DmsBaseShutReason> reasonList)
{
return reasonList.stream().mapToLong(reason -> nullToZero(reason.getGlobalFreq())).sum();
}
private long nullToZero(Long value)
{
return value == null ? 0L : value;
}
/**
*
*
* @param deviceId ID
* @return
*/
@Override
public List<DmsShutReasonRecommendVo> selectRecommendShutReasonList(Long deviceId)
{
if (deviceId == null)
{
return Collections.emptyList();
}
return dmsBaseShutReasonMapper.selectRecommendReasonList(deviceId);
}
/**
*
*

@ -2,10 +2,13 @@ package com.aucma.dms.service.impl;
import com.aucma.common.exception.ServiceException;
import com.aucma.common.utils.DateUtils;
import com.aucma.common.utils.SecurityUtils;
import com.aucma.dms.domain.DmsBaseShutReason;
import com.aucma.dms.domain.DmsRecordShutDown;
import com.aucma.dms.mapper.DmsRecordShutDownMapper;
import com.aucma.dms.service.IDmsBaseShutReasonService;
import com.aucma.dms.service.IDmsRecordShutDownService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -25,6 +28,9 @@ public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService{
@Autowired
private DmsRecordShutDownMapper dmsRecordShutDownMapper;
@Autowired
private IDmsBaseShutReasonService dmsBaseShutReasonService;
/**
*
*
@ -58,6 +64,7 @@ public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService{
@Override
public int insertDmsRecordShutDown(DmsRecordShutDown dmsRecordShutDown)
{
fillShutReasonFields(dmsRecordShutDown);
dmsRecordShutDown.setCreateBy(SecurityUtils.getLoginUser()==null ? SecurityUtils.getUserId() :SecurityUtils.getLoginUser().getUser().getUserId());
dmsRecordShutDown.setCreateTime(DateUtils.getNowDate());
return dmsRecordShutDownMapper.insertDmsRecordShutDown(dmsRecordShutDown);
@ -72,6 +79,7 @@ public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService{
@Override
public int updateDmsRecordShutDown(DmsRecordShutDown dmsRecordShutDown)
{
fillShutReasonFields(dmsRecordShutDown);
dmsRecordShutDown.setUpdateBy(SecurityUtils.getLoginUser()==null ? SecurityUtils.getUserId() :SecurityUtils.getLoginUser().getUser().getUserId());
dmsRecordShutDown.setUpdateTime(DateUtils.getNowDate());
return dmsRecordShutDownMapper.updateDmsRecordShutDown(dmsRecordShutDown);
@ -129,10 +137,37 @@ public class DmsRecordShutDownServiceImpl implements IDmsRecordShutDownService{
}
if (shutReasonId == null)
{
throw new RuntimeException("停机原因不能为空");
throw new ServiceException("停机原因不能为空");
}
DmsBaseShutReason shutReason = dmsBaseShutReasonService.selectDmsBaseShutReasonByShutReasonId(shutReasonId);
if (shutReason == null)
{
throw new ServiceException("停机原因不存在");
}
Long updateBy = SecurityUtils.getLoginUser() == null ? SecurityUtils.getUserId() : SecurityUtils.getLoginUser().getUser().getUserId();
return dmsRecordShutDownMapper.batchUpdateShutReason(recordShutDownIds, shutReasonId, updateBy, DateUtils.getNowDate());
return dmsRecordShutDownMapper.batchUpdateShutReason(recordShutDownIds, shutReasonId,
shutReason.getShutTypeId(), shutReason.getShutReason(), updateBy, DateUtils.getNowDate());
}
/**
* IDID
* PDA
*/
private void fillShutReasonFields(DmsRecordShutDown dmsRecordShutDown)
{
if (dmsRecordShutDown.getShutReasonId() == null)
{
return;
}
DmsBaseShutReason shutReason = dmsBaseShutReasonService
.selectDmsBaseShutReasonByShutReasonId(dmsRecordShutDown.getShutReasonId());
if (shutReason == null)
{
throw new ServiceException("停机原因不存在");
}
dmsRecordShutDown.setShutType(shutReason.getShutTypeId());
dmsRecordShutDown.setShutReason(shutReason.getShutReason());
}
}

@ -11,6 +11,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="shutTypeId" column="shut_type_id" />
<result property="shutReason" column="shut_reason" />
<result property="isFlag" column="is_flag" />
<result property="deviceFreq" column="device_freq" />
<result property="lineFreq" column="line_freq" />
<result property="globalFreq" column="global_freq" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
@ -23,9 +26,75 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectDmsBaseShutReasonList" parameterType="DmsBaseShutReason" resultMap="DmsBaseShutReasonResult">
select a.shut_reason_id, a.reason_code, a.device_id, a.shut_type_id, a.shut_reason, a.is_flag, a.remark, a.create_by, a.create_time, a.update_by, a.update_time
select a.shut_reason_id,
a.reason_code,
a.device_id,
a.shut_type_id,
a.shut_reason,
a.is_flag,
nvl(df.freq, 0) as device_freq,
nvl(lf.freq, 0) as line_freq,
nvl(gf.freq, 0) as global_freq,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time
from dms_base_shut_reason a
left join base_deviceledger b on a.device_id = b.OBJ_ID
left join (
<choose>
<when test="deviceId != null">
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.machine_id = #{deviceId}
and r.shut_begin_time &gt;= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
</when>
<otherwise>
select cast(null as number) as shut_reason_id,
0 as freq
from dual
where 1 = 0
</otherwise>
</choose>
) df on df.shut_reason_id = a.shut_reason_id
left join (
<choose>
<when test="deviceId != null">
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
join base_deviceledger d
on d.obj_id = r.machine_id
join base_deviceledger current_device
on current_device.obj_id = #{deviceId}
where d.product_line_code = current_device.product_line_code
and r.shut_begin_time &gt;= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
</when>
<otherwise>
select cast(null as number) as shut_reason_id,
0 as freq
from dual
where 1 = 0
</otherwise>
</choose>
) lf on lf.shut_reason_id = a.shut_reason_id
left join (
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.shut_begin_time &gt;= sysdate - 180
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
) gf on gf.shut_reason_id = a.shut_reason_id
<where>
<if test="reasonCode != null and reasonCode != ''"> and a.reason_code = #{reasonCode}</if>
<if test="deviceId != null "> and a.device_id = #{deviceId}</if>
@ -34,6 +103,170 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shutReason != null and shutReason != ''"> and a.shut_reason = #{shutReason}</if>
<if test="isFlag != null and isFlag != ''"> and a.is_flag = #{isFlag}</if>
</where>
<!-- 为什么这样做:停机原因维护和导出都优先呈现高频项,现场录入时可以更快定位真实高发原因。 -->
order by
<choose>
<when test="deviceId != null">
nvl(df.freq, 0) desc,
nvl(lf.freq, 0) desc,
nvl(gf.freq, 0) desc,
</when>
<otherwise>
nvl(gf.freq, 0) desc,
</otherwise>
</choose>
a.reason_code,
a.shut_reason_id
</select>
<select id="selectAvailableShutReasonList" resultMap="DmsBaseShutReasonResult">
select a.shut_reason_id,
a.reason_code,
a.device_id,
a.shut_type_id,
a.shut_reason,
a.is_flag,
nvl(df.freq, 0) as device_freq,
nvl(lf.freq, 0) as line_freq,
nvl(gf.freq, 0) as global_freq,
a.remark,
a.create_by,
a.create_time,
a.update_by,
a.update_time
from dms_base_shut_reason a
left join (
<choose>
<when test="deviceId != null">
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.machine_id = #{deviceId}
and r.shut_begin_time &gt;= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
</when>
<otherwise>
select cast(null as number) as shut_reason_id,
0 as freq
from dual
where 1 = 0
</otherwise>
</choose>
) df on df.shut_reason_id = a.shut_reason_id
left join (
<choose>
<when test="deviceId != null">
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
join base_deviceledger d
on d.obj_id = r.machine_id
join base_deviceledger current_device
on current_device.obj_id = #{deviceId}
where d.product_line_code = current_device.product_line_code
and r.shut_begin_time &gt;= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
</when>
<otherwise>
select cast(null as number) as shut_reason_id,
0 as freq
from dual
where 1 = 0
</otherwise>
</choose>
) lf on lf.shut_reason_id = a.shut_reason_id
left join (
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.shut_begin_time &gt;= sysdate - 180
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
) gf on gf.shut_reason_id = a.shut_reason_id
where a.is_flag = '1'
<if test="deviceId != null">
and (a.device_id is null or a.device_id = #{deviceId})
</if>
order by
<choose>
<when test="deviceId != null">
nvl(df.freq, 0) desc,
nvl(lf.freq, 0) desc,
nvl(gf.freq, 0) desc,
</when>
<otherwise>
nvl(gf.freq, 0) desc,
</otherwise>
</choose>
a.shut_type_id,
a.reason_code,
a.shut_reason_id
</select>
<select id="selectRecommendReasonList" resultType="com.aucma.dms.domain.vo.DmsShutReasonRecommendVo">
with device_freq as (
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.machine_id = #{deviceId}
and r.shut_begin_time >= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
),
line_freq as (
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
join base_deviceledger d
on d.obj_id = r.machine_id
join base_deviceledger current_device
on current_device.obj_id = #{deviceId}
where d.product_line_code = current_device.product_line_code
and r.shut_begin_time >= sysdate - 90
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
),
global_freq as (
select r.shut_reason_id,
count(1) as freq
from dms_record_shut_down r
where r.shut_begin_time >= sysdate - 180
and r.shut_reason_id is not null
and r.active_flag = 1
group by r.shut_reason_id
)
select sr.shut_reason_id as shutReasonId,
sr.reason_code as reasonCode,
sr.shut_reason as shutReason,
sr.shut_type_id as shutTypeId,
st.shut_type_name as shutTypeName,
nvl(df.freq, 0) as deviceFreq,
nvl(lf.freq, 0) as lineFreq,
nvl(gf.freq, 0) as globalFreq
from dms_base_shut_reason sr
join dms_base_shut_type st
on st.shut_type_id = sr.shut_type_id
and st.is_flag = '1'
left join device_freq df
on df.shut_reason_id = sr.shut_reason_id
left join line_freq lf
on lf.shut_reason_id = sr.shut_reason_id
left join global_freq gf
on gf.shut_reason_id = sr.shut_reason_id
where sr.is_flag = '1'
and (sr.device_id is null or sr.device_id = #{deviceId})
order by nvl(df.freq, 0) desc,
nvl(lf.freq, 0) desc,
nvl(gf.freq, 0) desc,
sr.reason_code,
sr.shut_reason_id
</select>
<select id="selectDmsBaseShutReasonByShutReasonId" parameterType="Long" resultMap="DmsBaseShutReasonResult">

@ -114,7 +114,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
<if test="deviceCode != null and deviceCode != ''"> and device_id in (select OBJ_ID from base_deviceledger where device_code = #{deviceCode})</if>
</where>
order by create_time desc
<!-- 故障工单列表按主键倒序,优先展示最新报修实例 -->
order by repair_instance_id desc
</select>
<select id="selectDmsBillsFaultInstanceByRepairInstanceId" parameterType="Long" resultMap="DmsBillsFaultInstanceResult">
@ -257,6 +258,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
</where>
<!-- 关联设备的故障工单列表按主键倒序,保持列表入口排序一致 -->
order by dbfi.repair_instance_id desc
</select>
@ -370,7 +372,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
<if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
</where>
order by create_time desc
<!-- 已完成故障工单列表按主键倒序,避免相同创建时间下分页顺序不稳定 -->
order by repair_instance_id desc
</select>
<select id="getDmsPartsList" resultType="com.aucma.dms.domain.DmsFaultCompentsParts"
parameterType="java.lang.Long">

@ -67,7 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="inspectStatus != null and inspectStatus != ''"> and a.inspect_status = #{inspectStatus}</if>
<if test="isFlag != null and isFlag != ''"> and a.is_flag = #{isFlag}</if>
</where>
order by a.create_time desc
<!-- 点巡检工单列表按主键倒序,优先展示最新生成的点巡检实例 -->
order by a.inspect_instance_id desc
</select>
<select id="selectPoint" parameterType="DmsBillsInspectInstance" resultMap="DmsBillsInspectInstanceResult">
<include refid="selectDmsBillsInspectInstanceVo"/>

@ -71,7 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)
</if>
</where>
order by create_time desc
<!-- 保养工单列表按主键倒序,优先展示最新生成的保养实例 -->
order by a.maint_instance_id desc
</select>
<select id="selectDmsBillsMaintInstanceByMaintInstanceId" parameterType="Long" resultMap="DmsBillsMaintInstanceResult">

@ -74,7 +74,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
and is_flag = '1'
</where>
order by create_time desc
<!-- 派工计划列表按主键倒序,优先展示最新生成的派工计划 -->
order by plan_id desc
</select>
<select id="selectDmsDispatchPlanByPlanId" parameterType="Long" resultMap="DmsDispatchPlanResult">

@ -67,6 +67,8 @@
<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>
<!-- 停机记录后台列表按主键倒序,确保最新登记的数据优先展示且分页顺序稳定 -->
order by r.record_shut_down_id desc
</select>
<select id="selectDmsRecordShutDownByRecordShutDownId" parameterType="Long" resultMap="DmsRecordShutDownResult">
@ -145,6 +147,8 @@
<update id="batchUpdateShutReason">
update dms_record_shut_down
set shut_reason_id = #{shutReasonId},
shut_type_id = #{shutTypeId},
shut_reason = #{shutReason},
update_by = #{updateBy},
update_time = #{updateTime}
where record_shut_down_id in

@ -89,7 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
and is_flag = '1'
</where>
order by create_time desc
<!-- 维修记录列表按主键倒序,避免相同创建时间下分页顺序不稳定 -->
order by record_id desc
</select>
<select id="selectDmsRepairRecordByRecordId" parameterType="Long" resultMap="DmsRepairRecordResult">

@ -41,6 +41,8 @@
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
</where>
<!-- 分派记录列表按主键倒序,优先展示最新分派动作 -->
order by assignment_id desc
</select>
<select id="selectAndonEventAssignmentByAssignmentId" parameterType="Long" resultMap="AndonEventAssignmentResult">
@ -123,4 +125,4 @@
#{assignmentId}
</foreach>
</delete>
</mapper>
</mapper>

@ -71,6 +71,8 @@
<if test="resolveDeadline != null "> and resolve_deadline = #{resolveDeadline}</if>
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
</where>
<!-- 安灯事件列表按事件主键倒序,便于优先处理最新呼叫 -->
order by event_id desc
</select>
<select id="selectAndonEventByEventId" parameterType="Long" resultMap="AndonEventResult">
@ -198,4 +200,4 @@
#{eventId}
</foreach>
</delete>
</mapper>
</mapper>

Loading…
Cancel
Save