Fancy
2024-10-12 5253013811d7fee3599d73ad3c92eecb5e6f964e
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
120
121
122
123
124
125
126
127
<?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.dy.pmsGlobal.daoOth.OthStatisticWorkloadMapper">
 
    <resultMap id="BaseResultMap" type="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload">
            <id property="id" column="id" jdbcType="BIGINT"/>
            <result property="statisticDate" column="statistic_date" jdbcType="DATE"/>
            <result property="userId" column="user_id" jdbcType="BIGINT"/>
            <result property="userName" column="user_name" jdbcType="VARCHAR"/>
            <result property="type" column="type" jdbcType="VARCHAR"/>
            <result property="nodeContent" column="node_content" jdbcType="VARCHAR"/>
            <result property="number" column="number" jdbcType="INTEGER"/>
    </resultMap>
 
    <sql id="Base_Column_List">
        id,statistic_date,user_id,
        user_name,type,node_content,
        number
    </sql>
 
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from oth_statistic_workload
        where  id = #{id,jdbcType=BIGINT} 
    </select>
    <select id="selectMaxDate" resultType="java.util.Date">
        select max(statistic_date) from oth_statistic_workload
    </select>
 
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        delete from oth_statistic_workload
        where  id = #{id,jdbcType=BIGINT} 
    </delete>
    <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload" useGeneratedKeys="true">
        insert into oth_statistic_workload
        ( id,statistic_date,user_id
        ,user_name,type,node_content
        ,number)
        values (#{id,jdbcType=BIGINT},#{statisticDate,jdbcType=DATE},#{userId,jdbcType=BIGINT}
        ,#{userName,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{nodeContent,jdbcType=VARCHAR}
        ,#{number,jdbcType=INTEGER})
    </insert>
    <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload" useGeneratedKeys="true">
        insert into oth_statistic_workload
        <trim prefix="(" suffix=")" suffixOverrides=",">
                <if test="id != null">id,</if>
                <if test="statisticDate != null">statistic_date,</if>
                <if test="userId != null">user_id,</if>
                <if test="userName != null">user_name,</if>
                <if test="type != null">type,</if>
                <if test="nodeContent != null">node_content,</if>
                <if test="number != null">number,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                <if test="id != null">#{id,jdbcType=BIGINT},</if>
                <if test="statisticDate != null">#{statisticDate,jdbcType=DATE},</if>
                <if test="userId != null">#{userId,jdbcType=BIGINT},</if>
                <if test="userName != null">#{userName,jdbcType=VARCHAR},</if>
                <if test="type != null">#{type,jdbcType=VARCHAR},</if>
                <if test="nodeContent != null">#{nodeContent,jdbcType=VARCHAR},</if>
                <if test="number != null">#{number,jdbcType=INTEGER},</if>
        </trim>
    </insert>
    <insert id="insertBatch">
        INSERT INTO oth_statistic_workload
        (statistic_date,user_id
        ,user_name,type,node_content
        ,number)
         WITH  total as (select
             DISTINCT(t.device_no),t.curr_node,t.node_content,t.number,p.pro_name, p.plan_name,u.id user_id,u.`name` user_name
            FROM
              (select * from sta_device_production_log_past
               where repair_id IS NULL and out_time BETWEEN #{startDt} AND #{endDt}
               union
               select * from sta_device_production_log
               where repair_id IS NULL and out_time BETWEEN #{startDt} AND #{endDt}
               ) t
               left join (select pap.id,pap.`name` as plan_name,pp.`name` as pro_name
               from  pr_assembly_plan pap, plt_product pp where pap.pro_id = pp.id) p on t.plan_id = p.id
               left JOIN ba_user u on u.id=t.updated_by)
        select  DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id, user_name,'计划任务' AS type, node_content ,sum(number) as number  from total where curr_node IS NOT NULL GROUP BY user_id,user_name,node_content
        UNION
        select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date, user_id,  user_name,'临时任务' AS type, node_content, sum(number) as number  from total where curr_node IS NULL AND (device_no !='' AND device_no IS NOT NULL)
        GROUP BY user_id,user_name,node_content
        UNION
        select DATE_FORMAT(#{startDt}, '%Y-%m-%d') as statistic_date,user_id , user_name,'临时任务(无设备码)' AS type,node_content, sum(number) as number  from total where curr_node IS NULL AND (device_no IS NULL OR device_no ='')
        GROUP BY user_id,user_name,node_content;
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload">
        update oth_statistic_workload
        <set>
                <if test="statisticDate != null">
                    statistic_date = #{statisticDate,jdbcType=DATE},
                </if>
                <if test="userId != null">
                    user_id = #{userId,jdbcType=BIGINT},
                </if>
                <if test="userName != null">
                    user_name = #{userName,jdbcType=VARCHAR},
                </if>
                <if test="type != null">
                    type = #{type,jdbcType=VARCHAR},
                </if>
                <if test="nodeContent != null">
                    node_content = #{nodeContent,jdbcType=VARCHAR},
                </if>
                <if test="number != null">
                    number = #{number,jdbcType=INTEGER},
                </if>
        </set>
        where   id = #{id,jdbcType=BIGINT} 
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dy.pmsGlobal.pojoOth.OthStatisticWorkload">
        update oth_statistic_workload
        set 
            statistic_date =  #{statisticDate,jdbcType=DATE},
            user_id =  #{userId,jdbcType=BIGINT},
            user_name =  #{userName,jdbcType=VARCHAR},
            type =  #{type,jdbcType=VARCHAR},
            node_content =  #{nodeContent,jdbcType=VARCHAR},
            number =  #{number,jdbcType=INTEGER}
        where   id = #{id,jdbcType=BIGINT} 
    </update>
</mapper>