功能修改

This commit is contained in:
hayu 2025-02-11 09:21:44 +08:00
parent 7cb7484618
commit 06fda2ebf7
4 changed files with 50 additions and 19 deletions

View File

@ -48,7 +48,9 @@ public class MachineController extends BaseController {
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(Machine machine) public TableDataInfo list(Machine machine)
{ {
startPage(); if (machine.getPrefix()==null || machine.getPrefix()==null){
startPage();
}
List<MachineVo> list = machineService.selectMachineList(machine); List<MachineVo> list = machineService.selectMachineList(machine);
return getDataTable(list); return getDataTable(list);
} }

View File

@ -167,4 +167,10 @@ public class Machine extends BaseEntity
@ApiModelProperty("资产属性ID") @ApiModelProperty("资产属性ID")
private String assetsId; private String assetsId;
@ApiModelProperty("前缀")
private Integer prefix;
@ApiModelProperty("后缀")
private Integer suffix;
} }

View File

@ -1,5 +1,6 @@
package com.bonus.material.ma.service.impl; package com.bonus.material.ma.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.alibaba.nacos.common.utils.CollectionUtils; import com.alibaba.nacos.common.utils.CollectionUtils;
@ -61,16 +62,21 @@ public class MachineServiceImpl implements IMachineService
@Override @Override
public List<MachineVo> selectMachineList(Machine machine) public List<MachineVo> selectMachineList(Machine machine)
{ {
List<MachineVo> list = machineMapper.selectMachineList(machine); try {
Map<String, String> machineStatus = remoteConfig.getDictValue("ma_machine_status"); List<MachineVo> list = machineMapper.selectMachineList(machine);
if (CollectionUtils.isNotEmpty(list)) { Map<String, String> machineStatus = remoteConfig.getDictValue("ma_machine_status");
list.forEach(machineVo -> { if (CollectionUtils.isNotEmpty(list)) {
if (StringUtils.isNotBlank(machineVo.getMaStatus())) { list.forEach(machineVo -> {
machineVo.setStatusName(StringUtils.isBlank(machineStatus.get(machineVo.getMaStatus())) ? "" : machineStatus.get(machineVo.getMaStatus())); if (StringUtils.isNotBlank(machineVo.getMaStatus())) {
} machineVo.setStatusName(StringUtils.isBlank(machineStatus.get(machineVo.getMaStatus())) ? "" : machineStatus.get(machineVo.getMaStatus()));
}); }
});
}
return list;
} catch (Exception e){
return new ArrayList<>();
} }
return list;
} }
/** /**

View File

@ -41,6 +41,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql> </sql>
<select id="selectMachineList" resultType="com.bonus.material.ma.domain.vo.MachineVo"> <select id="selectMachineList" resultType="com.bonus.material.ma.domain.vo.MachineVo">
select a.*
from (
SELECT SELECT
ma.ma_id as maId, ma.ma_id as maId,
ma.type_id as typeId, ma.type_id as typeId,
@ -72,11 +74,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
ma.update_time as updateTime, ma.update_time as updateTime,
ma.inspect_man as inspectMan, ma.inspect_man as inspectMan,
ma.inspect_status as inspectStatus, ma.inspect_status as inspectStatus,
ma.phone as phone ma.phone as phone,
CASE
WHEN RIGHT(ma.ma_code, 4) REGEXP '^[0-9]{4}$' THEN CAST(RIGHT(ma.ma_code, 4) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 3) REGEXP '^[0-9]{3}$' THEN CAST(RIGHT(ma.ma_code, 3) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 2) REGEXP '^[0-9]{2}$' THEN CAST(RIGHT(ma.ma_code, 2) AS UNSIGNED)
WHEN RIGHT(ma.ma_code, 1) REGEXP '^[0-9]$' THEN CAST(RIGHT(ma.ma_code, 1) AS UNSIGNED)
ELSE '0'
END AS result
FROM FROM
ma_machine ma ma_machine ma
LEFT JOIN ma_type mt ON ma.type_id = mt.type_id LEFT JOIN ma_type mt ON ma.type_id = mt.type_id
and mt.`level` = '4' and mt.del_flag = '0' and mt.`level` = '4' and mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
and mt2.`level` = '3' and mt2.del_flag = '0' and mt2.`level` = '3' and mt2.del_flag = '0'
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
@ -87,13 +96,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where where
1 = 1 1 = 1
<if test="keyWord != null and keyWord != ''"> <if test="keyWord != null and keyWord != ''">
and ( and (
ma.ma_code like concat('%', #{keyWord}, '%') ma.ma_code like concat('%', #{keyWord}, '%')
or ma.assets_code like concat('%', #{keyWord}, '%') or ma.assets_code like concat('%', #{keyWord}, '%')
or ma.pre_code like concat('%', #{keyWord}, '%') or ma.pre_code like concat('%', #{keyWord}, '%')
or ma.buy_task like concat('%', #{keyWord}, '%') or ma.buy_task like concat('%', #{keyWord}, '%')
or ma.own_house like concat('%', #{keyWord}, '%') or ma.own_house like concat('%', #{keyWord}, '%')
) )
</if> </if>
<if test="typeId != null"> <if test="typeId != null">
and ma.type_id = #{typeId} and ma.type_id = #{typeId}
@ -102,19 +111,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and ma.ma_status = #{maStatus} and ma.ma_status = #{maStatus}
</if> </if>
<if test="maCode != null and maCode != ''"> <if test="maCode != null and maCode != ''">
and ma.ma_code like concat('%', #{maCode}, '%') and ma.ma_code like concat('%', #{maCode}, '%')
</if> </if>
<if test="qrCode != null and qrCode != ''"> <if test="qrCode != null and qrCode != ''">
and ma.qr_code like concat('%', #{qrCode}, '%') and ma.qr_code like concat('%', #{qrCode}, '%')
</if> </if>
<if test="materialType != null and materialType != ''"> <if test="materialType != null and materialType != ''">
and mt3.type_name like concat('%', #{materialType}, '%') and mt3.type_name like concat('%', #{materialType}, '%')
</if> </if>
<if test="materialName != null and materialName != ''"> <if test="materialName != null and materialName != ''">
and mt2.type_name like concat('%', #{materialName}, '%') and mt2.type_name like concat('%', #{materialName}, '%')
</if> </if>
<if test="materialModel != null and materialModel != ''"> <if test="materialModel != null and materialModel != ''">
and mt.type_name like concat('%', #{materialModel}, '%') and mt.type_name like concat('%', #{materialModel}, '%')
</if> </if>
<if test="isAssets != null"> <if test="isAssets != null">
<if test="isAssets == 0"> <if test="isAssets == 0">
@ -125,7 +134,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND (ma.assets_code IS NULL OR ma.assets_code = '') AND (ma.assets_code IS NULL OR ma.assets_code = '')
</if> </if>
</if> </if>
order by ma.create_time desc
) a
where
1=1
<if test="prefix != null and suffix !=null">
and a.result BETWEEN #{prefix} and #{suffix}
</if>
order by a.createTime desc
</select> </select>
<select id="selectMachineByMaId" resultType="com.bonus.material.ma.domain.vo.MachineVo"> <select id="selectMachineByMaId" resultType="com.bonus.material.ma.domain.vo.MachineVo">