TWorkOrderMapper.xml 14.3 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
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
<?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="com.zehong.system.mapper.TWorkOrderMapper">
    
    <resultMap type="TWorkOrder" id="TWorkOrderResult">
        <result property="workId"    column="work_id"    />
        <result property="workTitle"    column="work_title"    />
        <result property="workType"    column="work_type"    />
        <result property="workContent"    column="work_content"    />
        <result property="workCreateEnterpriseName"    column="work_create_enterprise_name"    />
        <result property="workCreateEnterpriseId"    column="work_create_enterprise_id"    />
        <result property="workAssignEnterproseName"    column="work_assign_enterprose_name"    />
        <result property="workAssignEnterproseId"    column="work_assign_enterprose_id"    />
        <result property="workAssignManId"    column="work_assign_man_id"    />
        <result property="workAssignMan"    column="work_assign_man"    />
        <result property="workStatus"    column="work_status"    />
        <result property="inspectionDate"    column="inspection_date"    />
        <result property="inspectionRoute"    column="inspection_route"    />
        <result property="problemDescription"    column="problem_description"    />
        <result property="iconUrl"    column="icon_url"    />
        <result property="rectificationPlan"    column="rectification_plan"    />
        <result property="rectificationResult"    column="rectification_result"    />
        <result property="responsibleUnit"    column="responsible_unit"    />
        <result property="responsiblePerson"    column="responsible_person"    />
        <result property="expiryDate"    column="expiry_date"    />
        <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="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTWorkOrderVo">
37 38 39 40 41 42 43 44 45 46
        SELECT
            workOrder.work_id,
            workOrder.work_title,
            workOrder.work_type,
            workOrder.work_content,
            workOrder.work_create_enterprise_name,
            workOrder.work_create_enterprise_id,
            info.enterprise_name AS work_assign_enterprose_name,
            workOrder.work_assign_enterprose_id,
            workOrder.work_assign_man_id,
47
            usr.nick_name AS work_assign_man,
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
            workOrder.work_status,
            workOrder.inspection_date,
            workOrder.inspection_route,
            workOrder.problem_description,
            workOrder.icon_url,
            workOrder.rectification_plan,
            workOrder.rectification_result,
            workOrder.responsible_unit,
            workOrder.responsible_person,
            workOrder.expiry_date,
            workOrder.create_by,
            workOrder.create_time,
            workOrder.update_by,
            workOrder.update_time,
            workOrder.is_del,
            workOrder.remarks
        FROM
            t_work_order workOrder
        LEFT JOIN sys_user usr ON usr.user_id = workOrder.work_assign_man_id
        LEFT JOIN t_enterprise_info info ON info.enterprise_id = workOrder.work_assign_enterprose_id

耿迪迪's avatar
耿迪迪 committed
69 70 71 72
    </sql>

    <select id="selectTWorkOrderList" parameterType="TWorkOrder" resultMap="TWorkOrderResult">
        <include refid="selectTWorkOrderVo"/>
耿迪迪's avatar
耿迪迪 committed
73 74
        <where>
            workOrder.is_del = '0'
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
            <if test="workTitle != null  and workTitle != ''"> and workOrder.work_title like concat('%', #{workTitle}, '%')</if>
            <if test="workType != null  and workType != ''"> and workOrder.work_type = #{workType}</if>
            <if test="workContent != null  and workContent != ''"> and workOrder.work_content = #{workContent}</if>
            <if test="workCreateEnterpriseName != null  and workCreateEnterpriseName != ''"> and workOrder.work_create_enterprise_name like concat('%', #{workCreateEnterpriseName}, '%')</if>
            <if test="workCreateEnterpriseId != null  and workCreateEnterpriseId != ''"> and workOrder.work_create_enterprise_id = #{workCreateEnterpriseId}</if>
            <if test="workAssignEnterproseName != null  and workAssignEnterproseName != ''"> and info.work_assign_enterprose_name like concat('%', #{workAssignEnterproseName}, '%')</if>
            <if test="workAssignEnterproseId != null "> and workOrder.work_assign_enterprose_id = #{workAssignEnterproseId}</if>
            <if test="workAssignManId != null "> and workOrder.work_assign_man_id = #{workAssignManId}</if>
            <if test="workAssignMan != null  and workAssignMan != ''"> and user.work_assign_man = #{workAssignMan}</if>
            <if test="workStatus != null  and workStatus != ''"> and workOrder.work_status = #{workStatus}</if>
            <if test="inspectionDate != null "> and workOrder.inspection_date = #{inspectionDate}</if>
            <if test="inspectionRoute != null  and inspectionRoute != ''"> and workOrder.inspection_route = #{inspectionRoute}</if>
            <if test="problemDescription != null  and problemDescription != ''"> and workOrder.problem_description = #{problemDescription}</if>
            <if test="iconUrl != null  and iconUrl != ''"> and workOrder.icon_url = #{iconUrl}</if>
            <if test="rectificationPlan != null  and rectificationPlan != ''"> and workOrder.rectification_plan = #{rectificationPlan}</if>
            <if test="rectificationResult != null  and rectificationResult != ''"> and workOrder.rectification_result = #{rectificationResult}</if>
            <if test="responsibleUnit != null  and responsibleUnit != ''"> and workOrder.responsible_unit = #{responsibleUnit}</if>
            <if test="responsiblePerson != null  and responsiblePerson != ''"> and workOrder.responsible_person = #{responsiblePerson}</if>
            <if test="expiryDate != null "> and workOrder.expiry_date = #{expiryDate}</if>
            <if test="isDel != null  and isDel != ''"> and workOrder.is_del = #{isDel}</if>
            <if test="remarks != null  and remarks != ''"> and workOrder.remarks = #{remarks}</if>
耿迪迪's avatar
耿迪迪 committed
96
        </where>
97
        ORDER BY workOrder.create_time DESC
耿迪迪's avatar
耿迪迪 committed
98 99 100 101
    </select>
    
    <select id="selectTWorkOrderById" parameterType="Long" resultMap="TWorkOrderResult">
        <include refid="selectTWorkOrderVo"/>
102
        where workOrder.work_id = #{workId}
耿迪迪's avatar
耿迪迪 committed
103
    </select>
104 105 106 107 108 109

    <select id="countTWorkOrder" resultType="HomepageVo">
        select COUNT(t.work_id) AS taskTotal,
			   SUM(CASE t.work_status WHEN '2' THEN 1 ELSE 0 END) AS taskFeedbackTotal
        from (select * from t_work_order where is_del = '0') t
    </select>
耿迪迪's avatar
耿迪迪 committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
        
    <insert id="insertTWorkOrder" parameterType="TWorkOrder" useGeneratedKeys="true" keyProperty="workId">
        insert into t_work_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="workTitle != null">work_title,</if>
            <if test="workType != null">work_type,</if>
            <if test="workContent != null">work_content,</if>
            <if test="workCreateEnterpriseName != null">work_create_enterprise_name,</if>
            <if test="workCreateEnterpriseId != null">work_create_enterprise_id,</if>
            <if test="workAssignEnterproseName != null">work_assign_enterprose_name,</if>
            <if test="workAssignEnterproseId != null">work_assign_enterprose_id,</if>
            <if test="workAssignManId != null">work_assign_man_id,</if>
            <if test="workAssignMan != null">work_assign_man,</if>
            <if test="workStatus != null">work_status,</if>
            <if test="inspectionDate != null">inspection_date,</if>
            <if test="inspectionRoute != null">inspection_route,</if>
            <if test="problemDescription != null">problem_description,</if>
            <if test="iconUrl != null">icon_url,</if>
            <if test="rectificationPlan != null">rectification_plan,</if>
            <if test="rectificationResult != null">rectification_result,</if>
            <if test="responsibleUnit != null">responsible_unit,</if>
            <if test="responsiblePerson != null">responsible_person,</if>
            <if test="expiryDate != null">expiry_date,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="workTitle != null">#{workTitle},</if>
            <if test="workType != null">#{workType},</if>
            <if test="workContent != null">#{workContent},</if>
            <if test="workCreateEnterpriseName != null">#{workCreateEnterpriseName},</if>
            <if test="workCreateEnterpriseId != null">#{workCreateEnterpriseId},</if>
            <if test="workAssignEnterproseName != null">#{workAssignEnterproseName},</if>
            <if test="workAssignEnterproseId != null">#{workAssignEnterproseId},</if>
            <if test="workAssignManId != null">#{workAssignManId},</if>
            <if test="workAssignMan != null">#{workAssignMan},</if>
            <if test="workStatus != null">#{workStatus},</if>
            <if test="inspectionDate != null">#{inspectionDate},</if>
            <if test="inspectionRoute != null">#{inspectionRoute},</if>
            <if test="problemDescription != null">#{problemDescription},</if>
            <if test="iconUrl != null">#{iconUrl},</if>
            <if test="rectificationPlan != null">#{rectificationPlan},</if>
            <if test="rectificationResult != null">#{rectificationResult},</if>
            <if test="responsibleUnit != null">#{responsibleUnit},</if>
            <if test="responsiblePerson != null">#{responsiblePerson},</if>
            <if test="expiryDate != null">#{expiryDate},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTWorkOrder" parameterType="TWorkOrder">
        update t_work_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="workTitle != null">work_title = #{workTitle},</if>
            <if test="workType != null">work_type = #{workType},</if>
            <if test="workContent != null">work_content = #{workContent},</if>
            <if test="workCreateEnterpriseName != null">work_create_enterprise_name = #{workCreateEnterpriseName},</if>
            <if test="workCreateEnterpriseId != null">work_create_enterprise_id = #{workCreateEnterpriseId},</if>
            <if test="workAssignEnterproseName != null">work_assign_enterprose_name = #{workAssignEnterproseName},</if>
            <if test="workAssignEnterproseId != null">work_assign_enterprose_id = #{workAssignEnterproseId},</if>
179
            <if test="workAssignManId == null and workAssignMan == ''">work_assign_man_id = null,</if>
耿迪迪's avatar
耿迪迪 committed
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
            <if test="workAssignManId != null">work_assign_man_id = #{workAssignManId},</if>
            <if test="workAssignMan != null">work_assign_man = #{workAssignMan},</if>
            <if test="workStatus != null">work_status = #{workStatus},</if>
            <if test="inspectionDate != null">inspection_date = #{inspectionDate},</if>
            <if test="inspectionRoute != null">inspection_route = #{inspectionRoute},</if>
            <if test="problemDescription != null">problem_description = #{problemDescription},</if>
            <if test="iconUrl != null">icon_url = #{iconUrl},</if>
            <if test="rectificationPlan != null">rectification_plan = #{rectificationPlan},</if>
            <if test="rectificationResult != null">rectification_result = #{rectificationResult},</if>
            <if test="responsibleUnit != null">responsible_unit = #{responsibleUnit},</if>
            <if test="responsiblePerson != null">responsible_person = #{responsiblePerson},</if>
            <if test="expiryDate != null">expiry_date = #{expiryDate},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where work_id = #{workId}
    </update>

    <delete id="deleteTWorkOrderById" parameterType="Long">
        delete from t_work_order where work_id = #{workId}
    </delete>

    <delete id="deleteTWorkOrderByIds" parameterType="String">
        delete from t_work_order where work_id in 
        <foreach item="workId" collection="array" open="(" separator="," close=")">
            #{workId}
        </foreach>
    </delete>
212
    <select id="selectWorkOrderNum" resultType="java.util.HashMap">
213
        SELECT  IFNULL(SUM(IF(work_status=3,1,0)),0) AS typeOne,
zhangjianqian's avatar
zhangjianqian committed
214
        IFNULL(SUM(IF(work_status!=3,1,0)),0) AS typeTwo,
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
        (SELECT COUNT(employed_people_id)  FROM t_employed_people_info WHERE is_del = 0
            AND beyond_enterprise_id IN
            <foreach item="enterpriseId" collection="enterpriseIds" open="(" separator="," close=")">
                #{enterpriseId}
            </foreach>
        ) AS peopleNum,
        (SELECT CAST(SUM(pipe_length) AS  DECIMAL(20,0))  FROM t_pipe_info WHERE  is_del = 0
                AND beyond_enterprise_id IN
                <foreach item="enterpriseId" collection="enterpriseIds" open="(" separator="," close=")">
                    #{enterpriseId}
                </foreach>
        )AS allPipeLength
        FROM t_work_order WHERE  is_del = 0
            AND work_assign_enterprose_id IN
            <foreach item="enterpriseId" collection="enterpriseIds" open="(" separator="," close=")">
                #{enterpriseId}
            </foreach>
    </select>
耿迪迪's avatar
耿迪迪 committed
233
</mapper>