Parcourir la source

修复单据删除问题

LinWuTai il y a 1 an
Parent
commit
ca8708eedc

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/mapper/TbOrderDetailMapper.java

@@ -53,6 +53,8 @@ public interface TbOrderDetailMapper
      */
     public int deleteTbOrderDetailById(Long id);
 
+    int deleteTbOrderDetailByOrderNumber(String orderNumber);
+
     /**
      * 批量删除单据明细
      * 
@@ -61,6 +63,8 @@ public interface TbOrderDetailMapper
      */
     public int deleteTbOrderDetailByIds(Long[] ids);
 
+    int deleteTbOrderDetailByOrderNumbers(List<String> orderNumbers);
+
     /**
      * 获取单据详细信息
      *

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/mapper/TbOrderMapper.java

@@ -28,6 +28,8 @@ public interface TbOrderMapper
      */
     public List<TbOrder> selectTbOrderList(TbOrder tbOrder);
 
+    List<TbOrder> selectTbOrderByIDs(Long[] ids);
+
     /**
      * 新增资产单据
      * 

+ 4 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/service/ITbOrderDetailService.java

@@ -59,6 +59,10 @@ public interface ITbOrderDetailService
      */
     public int deleteTbOrderDetailById(Long id);
 
+    int deleteTbOrderDetailByOrderNumber(String orderNumber);
+
+    int deleteTbOrderDetailByOrderNumbers(List<String> orderNumbers);
+
     /**
      * 获取单据详细信息
      *

+ 2 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/service/ITbOrderService.java

@@ -30,6 +30,8 @@ public interface ITbOrderService
      */
     public List<TbOrder> selectTbOrderList(TbOrder tbOrder);
 
+    List<TbOrder> selectTbOrderByIds(Long[] ids);
+
     /**
      * 新增资产单据
      * 

+ 10 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/service/impl/TbOrderDetailServiceImpl.java

@@ -92,6 +92,16 @@ public class TbOrderDetailServiceImpl implements ITbOrderDetailService
     }
 
     @Override
+    public int deleteTbOrderDetailByOrderNumber(String orderNumber) {
+        return tbOrderDetailMapper.deleteTbOrderDetailByOrderNumber(orderNumber);
+    }
+
+    @Override
+    public int deleteTbOrderDetailByOrderNumbers(List<String> orderNumbers) {
+        return tbOrderDetailMapper.deleteTbOrderDetailByOrderNumbers(orderNumbers);
+    }
+
+    @Override
     public List<TbOrderDetail> selectTbOrderDetailByOrderNumber(String orderNumber) {
         return tbOrderDetailMapper.selectTbOrderDetailByOrderNumber(orderNumber);
     }

+ 15 - 0
ruoyi-admin/src/main/java/com/ruoyi/order/service/impl/TbOrderServiceImpl.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.stream.Collectors;
 
 import cn.hutool.core.lang.func.LambdaUtil;
 import cn.hutool.core.util.IdUtil;
@@ -68,6 +69,11 @@ public class TbOrderServiceImpl implements ITbOrderService
         return tbOrderMapper.selectTbOrderList(tbOrder);
     }
 
+    @Override
+    public List<TbOrder> selectTbOrderByIds(Long[] ids) {
+        return tbOrderMapper.selectTbOrderByIDs(ids);
+    }
+
     /**
      * 新增资产单据
      * 
@@ -101,6 +107,10 @@ public class TbOrderServiceImpl implements ITbOrderService
     @Override
     public int deleteTbOrderByIds(Long[] ids)
     {
+        List<TbOrder> tbOrders = selectTbOrderByIds(ids);
+        ids = tbOrders.stream().filter(tbOrder -> tbOrder.getRecordStatus() < 0).map(TbOrder::getId).toArray(Long[]::new);
+        List<String> orderNumbers = tbOrders.stream().filter(tbOrder -> tbOrder.getRecordStatus() < 0).map(TbOrder::getOrderNumber).collect(Collectors.toList());
+        tbOrderDetailMapper.deleteTbOrderDetailByOrderNumbers(orderNumbers);
         return tbOrderMapper.deleteTbOrderByIds(ids);
     }
 
@@ -113,6 +123,11 @@ public class TbOrderServiceImpl implements ITbOrderService
     @Override
     public int deleteTbOrderById(Long id)
     {
+        TbOrder tbOrder = selectTbOrderById(id);
+        if (tbOrder == null) {
+            return 0;
+        }
+        tbOrderDetailMapper.deleteTbOrderDetailByOrderNumber(tbOrder.getOrderNumber());
         return tbOrderMapper.deleteTbOrderById(id);
     }
 

+ 11 - 0
ruoyi-admin/src/main/resources/mapper/order/TbOrderDetailMapper.xml

@@ -96,10 +96,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         delete from tb_order_detail where id = #{id}
     </delete>
 
+    <delete id="deleteTbOrderDetailByOrderNumber" parameterType="String">
+        delete from tb_order_detail where order_number = #{orderNumber}
+    </delete>
+
     <delete id="deleteTbOrderDetailByIds" parameterType="String">
         delete from tb_order_detail where id in 
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteTbOrderDetailByOrderNumbers" parameterType="String">
+        delete from tb_order_detail where order_number in
+        <foreach item="number" collection="array" open="(" separator="," close=")">
+            #{number}
+        </foreach>
+    </delete>
 </mapper>

+ 10 - 0
ruoyi-admin/src/main/resources/mapper/order/TbOrderMapper.xml

@@ -32,6 +32,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select id, order_number, order_type, application_date, application_department, adjustment_asset_number, adjustment_original_asset_info, allocation_call_out_department, allocation_call_out_by, allocation_call_out_date, allocation_call_in_department, allocation_call_in_by, allocation_call_in_date, lend_department, lend_by_sponsor, lend_passing_unit, reason, prepared_by, prepared_department, corporation, record_status from tb_order
     </sql>
 
+    <select id="selectTbOrderByIDs" parameterType="String" resultMap="TbOrderResult">
+        <include refid="selectTbOrderVo"/>
+        <where>
+            id in
+            <foreach item="id" collection="array" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </where>
+    </select>
+
     <select id="selectTbOrderList" parameterType="TbOrder" resultMap="TbOrderResult">
         <include refid="selectTbOrderVo"/>
         <where>  

Fichier diff supprimé car celui-ci est trop grand
+ 154 - 668
ruoyi-ui/src/views/order/order/index.vue


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff