yangys
2025-09-29 4c7296d45efe849dc70a3b2e2240c905481a91c9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.springblade.mdm.machinefile.mapper.MachineFileMapper">
    <resultMap id="BaseResultMap" type="org.springblade.mdm.machinefile.entity.MachineFile">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="node_type" property="dirType"/>
        <result column="status" property="status"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--删除没有引用的,且标记为删除的文件记录-->
    <delete id="deleteNotUseRecords">
        delete from mdm_machine_file_change_his where machine_file_id in (select id mdm_machine_file where id not in (select machine_file_id from mdm_machine_accepted_file) and status=4);
        delete from mdm_machine_file where id not in (select machine_file_id from mdm_machine_accepted_file) and status=4;
    </delete>
 
    <!--待接收机床文件分页查询-->
    <select id="filePageForAccept" resultType="org.springblade.mdm.machinefile.entity.MachineFile">
        select f.id,f.name,f.machine_code,f.file_create_time,f.md5,f.file_size,f.dir_type,f.program_status
        from mdm_machine_file f join mdm_machine m on f.machine_code=m.code and m.is_deleted=0
        <where>
            f.status=1 and f.is_deleted=0
 
            <if test="query.machineSpec!=null and query.machineSpec!=''">
                and m.machine_spec=#{query.machineSpec,jdbcType=VARCHAR}
            </if>
            <if test="query.keyword!=null and query.keyword!=''">
                and (
                    m.code like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%') or m.name like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%')
                or f.name like CONCAT('%', #{query.keyword,jdbcType=VARCHAR},'%')
                )
            </if>
 
            <if test="query.machineCode!=null and query.machineCode!=''">
                and   m.code= #{query.machineCode,jdbcType=VARCHAR}
            </if>
            <if test="query.deptIds!=null and query.deptIds.size()&gt;0">
                and  m.owner_dept in
                <foreach item="item" collection="query.deptIds" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="query.dirType!=null and query.dirType!=''">
                and  f.dir_type= #{query.dirType,jdbcType=VARCHAR}
            </if>
            <if test="query.dirType==null or query.dirType==''">
                and f.dir_type='TEMP'
            </if>
        </where>
        order by f.file_create_time desc
    </select>
    <!--
    <select id="handlePageQuery" resultType="org.springblade.mdm.machinefile.vo.MachineAcceptedFileVO">
        select f.id,f.name,f.machine_code,f.file_create_time arrived_time,f.md5,f.file_size,f.determine_time
        from mdm_machine_file f join mdm_machine m on f.machine_code=m.code and m.is_deleted=0
        <where>
            f.dir_type='TEMP' and f.status=2 and f.is_deleted=0
 
            <if test="query.confirmTimeBegin!=null">
                and f.determine_time&gt;=#{query.confirmTimeBegin}
            </if>
            <if test="query.confirmTimeEnd!=null">
                and f.determine_time&lt;=#{query.confirmTimeEnd}
            </if>
            order by f.file_create_time desc
        </where>
    </select>
    -->
    <!--工控网首页文件查询-->
    <select id="pageQuery" resultType="org.springblade.mdm.machinefile.entity.MachineFile">
        select f.id,f.name,f.machine_code,f.dir_type,f.file_create_time, f.file_modify_time,f.md5,f.oss_name,f.file_size,f.create_time,f.update_time
        from mdm_machine_file f join mdm_machine m on f.machine_code=m.code and m.is_deleted=0
        <where>
            f.is_deleted=0 and f.status &lt;&gt; 4
 
            <if test="query.name!=null and query.name!=''">
                and f.name like CONCAT('%', #{query.name,jdbcType=VARCHAR},'%')
            </if>
 
            <if test="query.machineCode!=null and query.machineCode!=''">
                and   f.machine_code= #{query.machineCode,jdbcType=VARCHAR}
            </if>
            <if test="query.deptIds!=null and query.deptIds.size()&gt;0">
                and  m.owner_dept in
                <foreach item="item" collection="query.deptIds" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
            <if test="query.dirType!=null and query.dirType!=''">
                and  f.dir_type= #{query.dirType,jdbcType=VARCHAR}
            </if>
        </where>
        order by f.file_create_time desc
    </select>
 
    <!--异常文件记录查询-->
    <select id="exceptionFilePageQuery" resultType="org.springblade.mdm.machinefile.entity.MachineFile">
        select f.id,f.name,f.machine_code,f.file_create_time, f.file_modify_time,f.md5,f.file_size,f.exception_type,f.create_time,f.update_time
        from mdm_machine_file f join mdm_machine m on f.machine_code=m.code and m.is_deleted=0
        <where>
            f.status &lt;&gt; 4 and f.dir_type='REC' and f.is_deleted=0 and f.exception_type is not null and f.exception_type &lt;&gt; 0
 
            <if test="query.name!=null and query.name!=''">
                and f.name like CONCAT('%', #{query.name,jdbcType=VARCHAR},'%')
            </if>
 
            <if test="query.fileCreateTimeBegin!=null">
                and  f.file_create_time &gt;= #{query.fileCreateTimeBegin}
            </if>
            <if test="query.fileCreateTimeEnd!=null">
                and  f.file_create_time &lt;= #{query.fileCreateTimeEnd}
            </if>
        </where>
        order by f.file_create_time desc
    </select>
</mapper>