From 92f00c92b4e6c1c61ce8461d9b72fd2969e66802 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期五, 23 二月 2024 17:12:53 +0800
Subject: [PATCH] 流程卡新增

---
 north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml |  327 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 252 insertions(+), 75 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml b/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
index 4bf7021..9383dd5 100644
--- a/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
+++ b/north-glass-erp/src/main/resources/mapper/pp/FolwCard.xml
@@ -4,104 +4,281 @@
         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.example.erp.mapper.pp.FlowCardMapper">
     <resultMap id="flowCardMap" type="com.example.erp.entity.pp.FlowCard">
-
         <result column="order_id" property="orderId"/>
-        <result column="production_id" property="productionId"/>
-        <result column="splitting_status" property="splittingStatus"/>
+        <result column="process_Id" property="processId"/>
+        <result column="quantity" property="quantity"/>
+        <result column="founder" property="founder"/>
         <result column="create_time" property="createTime"/>
         <!--鎺ユ敹鍏朵粬澶栭敭瀹炰綋绫绘暟鎹�-->
         <association property="order" javaType="com.example.erp.entity.sd.Order">
+            <result column="project" property="project"/>
+            <result column="order_id" property="orderId"/>
+            <result column="customer_name" property="customerName"/>
             <result column="batch" property="batch"/>
+            <result column="other_remarks" property="otherRemarks"/>
+            <result column="icon" property="icon"/>
+            <result column="order_type" property="orderType"/>
+            <result column="salesman" property="salesman"/>
+            <result column="processing_note" property="processingNote"/>
+            <result column="delivery_address" property="deliveryAddress"/>
         </association>
         <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
+            <result column="product_id" property="productId"/>
             <result column="product_name" property="productName"/>
-            <result column="compute_area" property="computeArea"/>
+            <result column="compute_gross_area" property="computeGrossArea"/>
+            <result column="processing_note" property="processingNote"/>
             <result column="quantity" property="quantity"/>
             <result column="compute_gross_area" property="computeGrossArea"/>
             <result column="perimeter" property="perimeter"/>
-            <result column="bend_radius" property="bendRadius"/>
-            <result column="processing_note" property="processingNote"/>
+            <result column="order_number" property="orderNumber"/>
+            <result column="width" property="width"/>
+            <result column="height" property="height"/>
+            <result column="shape" property="shape"/>
+            <result column="weight" property="weight"/>
+        </association>
+        <association property="orderGlassDetail" javaType="com.example.erp.entity.sd.OrderGlassDetail">
+            <result column="production_id" property="productionId"/>
+        </association>
+        <association property="product" javaType="com.example.erp.entity.sd.Product">
+            <result column="total_thickness" property="totalThickness"/>
+            <result column="thickness" property="thickness"/>
         </association>
 
         <!--<result column="g_typeId" property="glassTypes.typeId"/>
         <result column="g_type" property="glassTypes.type"/>-->
 
     </resultMap>
+    <!--    娴佺▼鍗$鐞嗘煡璇�-->
     <select id="selectFlowCard" resultMap="flowCardMap">
         select
-        a.order_id,
-        a.production_id,
-        c.batch,
-        b.product_name,
-        b.compute_area,
-        b.quantity,
-        b.compute_gross_area,
-        b.perimeter,
-        b.bend_radius,
-        b.processing_note
-        from order_glass_detail as a
-        LEFT JOIN order_detail as b on a.order_id=b.order_id and a.order_number=b.order_number LEFT JOIN
-        `order` as c on a.order_id=c.order_id
-        <where>
-            <if test="orderGlassDetail.orderId != null and orderGlassDetail.orderId != ''">
-                and a.order_id regexp #{orderGlassDetail.orderId}
-            </if>
-            <if test="orderGlassDetail.productionId != null and orderGlassDetail.productionId != ''">
-                and a.production_id regexp #{orderGlassDetail.productionId}
-            </if>
-            <if test="orderGlassDetail.order.batch != null and orderGlassDetail.order.batch != ''">
-                and c.batch regexp #{orderGlassDetail.order.batch}
-            </if>
-            <if test="orderGlassDetail.orderDetail.productName != null and orderGlassDetail.orderDetail.productName!= ''">
-                and b.product_name regexp #{orderGlassDetail.orderDetail.productName}
-            </if>
-            <if test="orderGlassDetail.splittingStatus=0 " >
-                and a.splitting_status regexp #{state}
-            </if>
-            <if test="orderGlassDetail.splittingStatus=1">
-                and a.splitting_status regexp #{state}
-            </if>
-            <if test="orderGlassDetail.createTime != ''">
-                and DATE_FORMAT((a.create_time),'%Y-%m-%d')  BETWEEN #{ selectTime1 } AND #{ selectTime2 }
-            </if>
-        </where>
-        group by a.production_id,a.order_number
-        order by a.id desc
+        a.order_Id,
+        a.process_Id,
+        c.product_id,
+        c.product_name,
+        b.project,
+        a.quantity,
+        c.compute_gross_area,
+        a.founder,
+        c.processing_note
+        from flow_card as a left join sd.`order` as b on a.order_Id=b.order_id
+        left join sd.order_detail as c on a.order_Id=c.order_id and a.order_Number=c.order_number
+        where a.create_time between #{selectTime1} and #{selectTime2}
+                    <if test="flowCard.orderId != null and flowCard.orderId != ''">
+                        and a.order_id regexp #{flowCard.orderId}
+                    </if>
+                    <if test="flowCard.productionId != null and flowCard.productionId != ''">
+                        and a.process_Id regexp #{flowCard.productionId}
+                    </if>
+                    <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
+                        and c.product_id regexp #{flowCard.orderDetail.productId}
+                    </if>
+                    <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName!= ''">
+                        and c.product_name regexp #{flowCard.orderDetail.productName}
+                    </if>
 
+                    <if test="flowCard.order.project != null and flowCard.order.project!= ''">
+                        and b.project regexp #{flowCard.order.project}
+                    </if>
+
+
+        group by a.process_Id;
+    </select>
+
+    <!--鍒嗘灦鏌ヨ-->
+    <select id="selectFlowCardMp" resultMap="flowCardMap">
+        select o.order_id,
+        o.customer_name,
+        o.project,
+        o.batch,
+        o.other_remarks,
+        o.icon,
+        o.order_type,
+        o.salesman,
+        o.processing_note,
+        o.delivery_address
+        from sd.`order` as o
+        left join sd.order_glass_detail ogd on o.order_id = ogd.order_id
+        where o.production_order=2 and ogd.splitting_status=0 and o.create_time between #{selectTime1} and #{selectTime2}
+
+        <if test="flowCard.order.orderId != null and flowCard.order.orderId != ''">
+            and o.order_id, regexp #{flowCard.order.orderId}
+        </if>
+        <if test="flowCard.order.customerName != null and flowCard.order.customerName != ''">
+            and o.customer_name regexp #{flowCard.order.customerName}
+        </if>
+        <if test="flowCard.order.project != null and flowCard.order.project != ''">
+            and o.project regexp #{flowCard.order.project}
+        </if>
+        <if test="flowCard.order.batch != null and flowCard.order.batch!= ''">
+            and o.batch regexp #{flowCard.order.batch}
+        </if>
+
+        <if test="flowCard.order.otherRemarks != null and flowCard.order.otherRemarks!= ''">
+            and o.other_remarks regexp #{flowCard.order.otherRemarks}
+        </if>
+
+        <if test="flowCard.order.icon != null and flowCard.order.icon!= ''">
+            and o.icon regexp #{flowCard.order.icon}
+        </if>
+        <if test="flowCard.order.orderType != null and flowCard.order.orderType!= ''">
+            and o.order_type regexp #{flowCard.order.orderType}
+        </if>
+        <if test="flowCard.order.salesman != null and flowCard.order.salesman!= ''">
+            and o.salesman regexp #{flowCard.order.salesman}
+        </if>
+        group by o.order_id
 
         ;
     </select>
 
-    <!--    <select id="getPageTotal" >-->
-    <!--        select-->
-    <!--        CEILING(count(a.id)/#{pageSize})-->
-    <!--        from product as a-->
-    <!--        left join basic_glass_type bgt on bgt.type_id = a.type_id-->
-    <!--        <where>-->
-    <!--            <if test="glassTypeId != null and glassTypeId != ''">-->
-    <!--                and a.type_id regexp #{glassTypeId}-->
-    <!--            </if>-->
-    <!--            <if test="product.id != null and product.id != ''">-->
-    <!--                and a.id regexp #{product.id}-->
-    <!--            </if>-->
-    <!--            <if test="product.productName != null and product.productName != ''">-->
-    <!--                and a.product_name regexp #{product.productName}-->
-    <!--            </if>-->
-    <!--            <if test="product.basicGlassType.typeName != null and product.basicGlassType.typeName!= ''">-->
-    <!--                and bgt.type_name regexp #{product.basicGlassType.typeName}-->
-    <!--            </if>-->
-    <!--            <if test="product.query != null and product.query != ''">-->
-    <!--                and a.query regexp #{product.query}-->
-    <!--            </if>-->
-    <!--            <if test="product.creator != null and product.creator != ''">-->
-    <!--                and a.creator regexp #{product.creator}-->
-    <!--            </if>-->
-    <!--            <if test="product.createTime != null and product.createTime != ''">-->
-    <!--                and date(a.create_time) regexp #{product.createTime}-->
-    <!--            </if>-->
-    <!--        </where>-->
+<!--    鍒嗘灦鏄庣粏鏌ヨ-->
+    <select id="DetailsSelectMp" resultMap="flowCardMap">
+        select od.order_id,
+        ogd.production_id,
+        od.product_id,
+        od.product_name,
+        SUM( od.quantity) as quantity,
+        SUM(od.compute_gross_area) as compute_gross_area,
+        od.perimeter
+        from  sd.order_detail as od left join sd.order_glass_detail as ogd
+        on od.order_id=ogd.order_id and od.order_number=ogd.order_number
+        where od.order_id = #{orderId} and ogd.splitting_status=0
+        <if test="flowCard.orderDetail.orderId != null and flowCard.orderDetail.orderId != ''">
+            and od.order_id regexp #{flowCard.orderDetail.orderId}
+        </if>
+        <if test="flowCard.orderGlassDetail.productionId != null and flowCard.orderGlassDetail.productionId != ''">
+            and ogd.production_id regexp #{flowCard.orderGlassDetail.productionId}
+        </if>
+        <if test="flowCard.orderDetail.productId != null and flowCard.orderDetail.productId != ''">
+            and od.product_id regexp #{flowCard.orderDetail.productId}
+        </if>
+        <if test="flowCard.orderDetail.productName != null and flowCard.orderDetail.productName != ''">
+            and od.product_name regexp #{flowCard.orderDetail.productName}
+        </if>
+        group by od.order_id, ogd.production_id
+    </select>
 
-    <!--        order by a.id desc-->
-    <!--        ;-->
-    <!--    </select>-->
+    <update id="UpdateDeleteState">
+        update sd.order_glass_detail as ogd
+        set ogd.production_id=null,
+            ogd.production_time=null,
+            ogd.founder=null
+        where ogd.production_id = #{processId}
+
+    </update>
+
+    <!--    鍒犻櫎娴佺▼鍗�-->
+    <update id="DeleteFlowCardMp">
+        update sd.order_detail as od left join sd.order_glass_detail as ogd
+            on od.order_id = ogd.order_id and od.order_number = ogd.order_number
+        set ogd.production_id=null,
+            ogd.production_time=null,
+            ogd.founder=null
+        where od.order_id = #{orderId}
+          and ogd.production_id = #{processId}
+    </update>
+
+    <!--    鍒嗘灦鏂板鏄庣粏鏌ヨ-->
+
+    <!--resultMap="flowCardMap"-->
+    <select id="SelectNoCardMp" >
+
+        select
+        od.order_number,
+        od.order_number AS 'orderNumber',
+        od.width,
+        od.height,
+        od.shape,
+        od.quantity,
+        od.compute_gross_area,
+        p.total_thickness,
+        od.quantity as baiscQuantity,
+        od.compute_gross_area as 'computeGrossArea',
+        p.total_thickness AS 'totalThickness',
+        p.thickness,
+        od.weight
+        from
+        sd.order_detail as od
+        left join sd.order_glass_detail as ogd on od.order_id=ogd.order_id and od.order_number=ogd.order_number
+        left join sd.product as p on od.product_name=p.product_name
+        where od.order_id=#{orderId} and ogd.production_id=#{productionId} and ogd.splitting_status=0
+        GROUP BY od.order_number;
+
+
+    </select>
+
+    <!--淇敼鎺掔増鐘舵��-->
+    <update id="UpdateLayoutStatusMp">
+        update flow_card as fc
+        set fc.layout_status=2
+        where fc.process_id = #{processId}
+    </update>
+
+<!--    鏌ヨ瀵瑰簲娴佺▼鍗″彿鎺掔増鐘舵��-->
+    <select id="SelectLayoutStatus">
+        select fc.layout_status
+        from flow_card as fc
+        where fc.process_id = #{processId}
+        LIMIT 1
+    </select>
+
+<!--    鏌ヨ鎶ュ伐琛ㄥ唴鏄惁鏈夊搴旀祦绋嬪崱-->
+    <select id="ReportingWorkCount">
+        select COUNT(rw.process_id)
+        from reporting_work as rw
+        where rw.process_id = #{processId}
+    </select>
+<!--    鎻掑叆Flow_card琛�-->
+    <insert id="AddFlowCardMp">
+        insert into
+            flow_card (
+            order_id,
+            production_id,
+            process_id,
+            landing_sequence,
+            order_number,
+            technology_number,
+            quantity,
+            founder,
+            splitFrame_time,
+            create_time
+        )
+        select
+            ogd.order_id,
+            ogd.production_id,
+            #{processId},
+            #{landingSequence},
+            ogd.order_number,
+            ogd.technology_number,
+            #{quantity},
+            #{userName},
+            NOW(),
+            NOW()
+
+
+
+        from sd.order_glass_detail as ogd
+        where ogd.production_id=#{productionId} and ogd.order_number=#{orderNumber}
+        GROUP BY ogd.technology_number
+    </insert>
+
+<!--    鏇存柊鍒嗘灦鐘舵��-->
+    <update id="UpdateFlowState">
+        update sd.order_glass_detail as ogd
+        set ogd.splitting_status=1
+        where ogd.production_id=#{productionId} and ogd.order_number=#{orderNumber}
+    </update>
+<!--    鏌ヨ鏈垎鏋剁殑鏉℃暟-->
+    <select id="SelectFlowCount">
+        select COUNT(*)
+        from sd.order_glass_detail as ogd
+        where ogd.order_id = left(#{productionId},10)
+          and ogd.splitting_status = 0
+    </select>
+<!--   淇敼璁㈠崟琛ㄥ垎鏋剁姸鎬�-->
+    <update id="UpdateProcessingCard">
+        update sd.`order` as o
+        set o.processing_card=#{state}
+        where o.order_id=left(#{productionId},10)
+    </update>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0