懒羊羊
2023-11-14 8286c62256f23bc2367a6729c0f46f84215e380b
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
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
179
180
181
182
183
184
185
186
187
188
<?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="cn.stylefeng.guns.modular.om.productionOrdeInfo.mapper.ProductionOrdeInfoMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.stylefeng.guns.modular.om.productionOrdeInfo.entity.ProductionOrdeInfo">
        <id column="id" property="id" />
        <result column="sales_order_no" property="salesOrderNo" />
        <result column="work_order_no" property="workOrderNo" />
        <result column="production_line" property="productionLine" />
        <result column="drawing_no" property="drawingNo" />
        <result column="material_code" property="materialCode" />
        <result column="material_name" property="materialName" />
        <result column="plan_qty" property="planQty" />
        <result column="actual_qty" property="actualQty" />
        <result column="scrap_qty" property="scrapQty" />
        <result column="repair_qty" property="repairQty" />
        <result column="actual_online_qty" property="actualOnlineQty" />
        <result column="online_completion_mark" property="onlineCompletionMark" />
        <result column="demand_date" property="demandDate" />
        <result column="plan_start_time" property="planStartTime" />
        <result column="plan_end_time" property="planEndTime" />
        <result column="actual_start_time" property="actualStartTime" />
        <result column="actual_end_time" property="actualEndTime" />
        <result column="serial_number" property="serialNumber" />
        <result column="order_status" property="orderStatus" />
        <result column="spare_field_1" property="spareField1" />
        <result column="spare_field_2" property="spareField2" />
        <result column="spare_field_3" property="spareField3" />
        <result column="spare_field_4" property="spareField4" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_user" property="createUser" />
        <result column="update_user" property="updateUser" />
        <result column="remarks" property="remarks" />
        <result column="stream_number" property="streamNumber" />
        <result column="custom" property="custom" />
        <result column="market_area_code" property="marketAreaCode" />
        <result column="software_version_code" property="softwareVersionCode" />
        <result column="product_company_code" property="productCompanyCode" />
 
 
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        custom AS "custom", stream_number AS "streamNumber", id AS "id", sales_order_no AS "salesOrderNo", work_order_no AS "workOrderNo", production_line AS "productionLine", drawing_no AS "drawingNo", material_code AS "materialCode", material_name AS "materialName", plan_qty AS "planQty", actual_qty AS "actualQty", scrap_qty AS "scrapQty", repair_qty AS "repairQty", actual_online_qty AS "actualOnlineQty", online_completion_mark AS "onlineCompletionMark", demand_date AS "demandDate", plan_start_time AS "planStartTime", plan_end_time AS "planEndTime", actual_start_time AS "actualStartTime", actual_end_time AS "actualEndTime", serial_number AS "serialNumber", order_status AS "orderStatus", spare_field_1 AS "spareField1", spare_field_2 AS "spareField2", spare_field_3 AS "spareField3", spare_field_4 AS "spareField4", create_time AS "createTime", update_time AS "updateTime",
        create_user AS "createUser", update_user AS "updateUser", remarks AS "remarks",
        market_area_code AS "marketAreaCode",software_version_code AS "softwareVersionCode",product_company_code AS "productCompanyCode"
    </sql>
 
 
    <select id="customList" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult" parameterType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam">
        select
        <include refid="Base_Column_List"/>
        from om_production_orde_info where 1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.materialCode != null and paramCondition.materialCode != ''">
            and material_code like CONCAT('%',#{paramCondition.materialCode},'%')
        </if>
        <if test="paramCondition.orderStatus != null and paramCondition.orderStatus != ''">
            and order_status = #{paramCondition.orderStatus}
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        order by serial_number desc
    </select>
 
    <select id="customMapList" resultType="map" parameterType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam">
        select
        <include refid="Base_Column_List"/>
        from om_production_orde_info where 1 = 1
    </select>
 
    <select id="customPageList" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult" parameterType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam">
        select
        <include refid="Base_Column_List"/>
        from om_production_orde_info where 1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.materialCode != null and paramCondition.materialCode != ''">
            and material_code like CONCAT('%',#{paramCondition.materialCode},'%')
        </if>
        <if test="paramCondition.orderStatus != null and paramCondition.orderStatus != ''">
            and order_status = #{paramCondition.orderStatus}
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        order by serial_number desc
    </select>
 
    <select id="customPageMapList" resultType="map" parameterType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam">
        select
        <include refid="Base_Column_List"/>
        from om_production_orde_info where 1 = 1
    </select>
 
    <!--    <select id="lineFinishQty" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">-->
    <!--        SELECT production_line as name,sum(actual_qty)as value  FROM om_production_orde_info GROUP BY production_line-->
    <!--    </select>-->
    <select id="lineFinishQty" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        <![CDATA[
        SELECT TOP 7 actual_start_time as actualStartTime,actual_qty as actualQty FROM om_production_orde_info WHERE actual_start_time is not null AND actual_qty IS NOT NULL ORDER BY actual_start_time DESC
        ]]>
    </select>
 
    <select id="getOrderWeek" resultType="Map">
        SELECT SUM(plan_qty) AS planQty,COALESCE( SUM(actual_qty) ,0) AS actualQty FROM om_production_orde_info WHERE DateDiff(month,create_time,getdate())=0
    </select>
 
    <select id="getPlanQtyByDate" parameterType="java.lang.String" resultType="java.lang.Integer">
        select SUM(plan_qty) as planQty FROM om_production_orde_info WHERE CONVERT ( VARCHAR ( 100 ), create_time, 23 ) = #{paramCondition}
    </select>
 
    <select id="getActualQtyByDate" parameterType="string" resultType="integer">
        select SUM(actual_qty) as actualQty FROM om_production_orde_info WHERE CONVERT ( VARCHAR ( 100 ), create_time, 23 ) = #{testdate}
    </select>
 
    <!--    <select id="getListMonth" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">-->
    <!--        <![CDATA[-->
    <!--        select * from om_production_orde_info where datediff(dd, plan_start_time,getdate())<=6-->
    <!--        ]]>-->
    <!--    </select>-->
 
    <select id="getListMonth" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        <![CDATA[
        SELECT TOP 10 * FROM om_production_orde_info ORDER BY actual_start_time DESC
        ]]>
    </select>
 
    <select id="getColumnarDate" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        SELECT DISTINCT
            FORMAT ( actual_start_time, 'yyyy-MM-dd' ) AS actual_start_time
        FROM
            om_production_orde_info
        ORDER BY
            actual_start_time DESC OFFSET 0 ROWS FETCH NEXT 7 ROWS ONLY;
    </select>
 
    <select id="customResult" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult" parameterType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.params.ProductionOrdeInfoParam">
        select
        <include refid="Base_Column_List"/>
        from om_production_orde_info where 1 = 1
        <if test="paramCondition.workOrderNo != null and paramCondition.workOrderNo != ''">
            and work_order_no like CONCAT('%',#{paramCondition.workOrderNo},'%')
        </if>
        <if test="paramCondition.materialCode != null and paramCondition.materialCode != ''">
            and material_code like CONCAT('%',#{paramCondition.materialCode},'%')
        </if>
        <if test="paramCondition.orderStatus != null and paramCondition.orderStatus != ''">
            and order_status = #{paramCondition.orderStatus}
        </if>
        <if test="paramCondition.productionLine != null and paramCondition.productionLine != ''">
            and production_line like CONCAT('%',#{paramCondition.productionLine},'%')
        </if>
        order by serial_number desc
    </select>
 
    <select id="bottomLeftChart" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        SELECT
            DATE_FORMAT( create_time, '%Y-%m-%d' ) AS createTime,
            SUM(plan_qty) AS planQty,
            SUM(actual_qty) AS actualQty
        FROM
            om_production_orde_info
        GROUP BY
            DATE_FORMAT( create_time, '%Y-%m-%d' )
        ORDER BY
            create_time DESC
    </select>
 
    <select id="centerRight2" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        SELECT MONTH(create_time) AS month, SUM(plan_qty) AS num
        FROM om_production_orde_info
        WHERE create_time >= DATE_SUB(CURRENT_DATE, INTERVAL 5 MONTH)
        GROUP BY month
        ORDER BY month DESC;
    </select>
 
    <select id="getLastOrder" resultType="cn.stylefeng.guns.modular.om.productionOrdeInfo.model.result.ProductionOrdeInfoResult">
        SELECT * FROM om_production_orde_info ORDER BY create_time DESC LIMIT 1
    </select>
</mapper>