Browse Source

库存管理系统添加调度单据

hurixing 5 months ago
parent
commit
bc45e7bfe6

+ 8 - 1
inventory-system/src/main/java/com/ruoyi/system/mapper/BillsDetailsMapper.java

@@ -9,7 +9,7 @@ import java.util.List;
  *
  * @date 2024-10-14
  */
-public interface BillsDetailsMapper
+public interface BillsDetailsMapper<updateBatchByBillsId>
 {
     /**
      * 查询单据详情
@@ -58,4 +58,11 @@ public interface BillsDetailsMapper
      * @return 结果
      */
     public int deleteBillsDetailsByIds(Long[] ids);
+
+    /**
+     * 批量修改
+     * @param billsDetailsList
+     * @return
+     */
+    public int updateBatchByBillsId(List<BillsDetails> billsDetailsList);
 }

+ 7 - 0
inventory-system/src/main/java/com/ruoyi/system/mapper/GoodsMapper.java

@@ -67,4 +67,11 @@ public interface GoodsMapper
      */
     public List<Goods> selectGoodsIds(@Param("ids") List<Long> ids);
 
+
+    /**
+     * 批量修改
+     * @param goodsList
+     * @return
+     */
+    int updateBatchByGoodsCode(List<Goods> goodsList);
 }

+ 7 - 0
inventory-system/src/main/java/com/ruoyi/system/service/IBillsDetailsService.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service;
 
+import com.ruoyi.system.domain.Bills;
 import com.ruoyi.system.domain.BillsDetails;
 import com.ruoyi.system.domain.vo.BillsDetailsVo;
 
@@ -59,4 +60,10 @@ public interface IBillsDetailsService
      * @return 结果
      */
     public int deleteBillsDetailsById(Long id);
+
+    /**
+     * 批量修改
+     * @param billsDetails
+     */
+    public void updateBatchByBillsId(List<BillsDetails> billsDetails);
 }

+ 5 - 0
inventory-system/src/main/java/com/ruoyi/system/service/IGoodsService.java

@@ -58,4 +58,9 @@ public interface IGoodsService
      * @return 结果
      */
     public int deleteGoodsById(Long id);
+
+    /**
+     * 批量修改
+     */
+    void updateBatchByGoodsCode(List<Goods> goodsList);
 }

+ 9 - 0
inventory-system/src/main/java/com/ruoyi/system/service/impl/BillsDetailsServiceImpl.java

@@ -151,4 +151,13 @@ public class BillsDetailsServiceImpl implements IBillsDetailsService
     {
         return billsDetailsMapper.deleteBillsDetailsById(id);
     }
+
+    /**
+     * 批量修改
+     * @param billsDetails
+     */
+    @Override
+    public void updateBatchByBillsId(List<BillsDetails> billsDetails) {
+        billsDetailsMapper.updateBatchByBillsId(billsDetails);
+    }
 }

+ 49 - 0
inventory-system/src/main/java/com/ruoyi/system/service/impl/BillsServiceImpl.java

@@ -2,11 +2,18 @@ package com.ruoyi.system.service.impl;
 
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.system.domain.Bills;
+import com.ruoyi.system.domain.BillsDetails;
+import com.ruoyi.system.domain.Goods;
 import com.ruoyi.system.mapper.BillsMapper;
+import com.ruoyi.system.service.IBillsDetailsService;
 import com.ruoyi.system.service.IBillsService;
+import com.ruoyi.system.service.IGoodsService;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -20,6 +27,12 @@ public class BillsServiceImpl implements IBillsService
     @Resource
     private BillsMapper billsMapper;
 
+    @Resource
+    private IBillsDetailsService billsDetailsService;
+
+    @Resource
+    private IGoodsService goodsService;
+
     /**
      * 查询单据
      *
@@ -63,10 +76,46 @@ public class BillsServiceImpl implements IBillsService
      * @param bills 单据
      * @return 结果
      */
+    @Transactional(rollbackFor = Exception.class)
     @Override
     public int updateBills(Bills bills)
     {
         bills.setUpdateTime(DateUtils.getNowDate());
+
+        // 查询单据详情
+        BillsDetails billsDetails = new BillsDetails();
+        billsDetails.setBillsId(bills.getId());
+        List<BillsDetails> billsDetailsList = billsDetailsService.selectBillsDetailsList(billsDetails);
+
+        List<BillsDetails> updateBillsDetailsList = new ArrayList<>();
+        List<Goods> goodsList = new ArrayList<>();
+        for (BillsDetails details : billsDetailsList) {
+            Goods goods = new Goods();
+            goods.setGoodsCode(details.getGoodsCode());
+            goods.setUpdateTime(new Date());
+
+            BillsDetails updateBillsDetails = new BillsDetails();
+            updateBillsDetails.setBillsId(details.getBillsId());
+            updateBillsDetails.setUpdateTime(new Date());
+            // 入库单据
+            if (bills.getBillsType().equals("0")){
+                goods.setGoodsStatus("0");
+                updateBillsDetails.setGoodsStatus("0");
+            }else if (bills.getBillsType().equals("1")){
+                // 出库单据
+                goods.setGoodsStatus("1");
+                updateBillsDetails.setGoodsStatus("1");
+            }else {
+                // 出调单据
+                goods.setGoodsStatus("2");
+                updateBillsDetails.setGoodsStatus("2");
+            }
+            goodsList.add(goods);
+            updateBillsDetailsList.add(updateBillsDetails);
+        }
+        goodsService.updateBatchByGoodsCode(goodsList);
+        billsDetailsService.updateBatchByBillsId(updateBillsDetailsList);
+
         return billsMapper.updateBills(bills);
     }
 

+ 9 - 0
inventory-system/src/main/java/com/ruoyi/system/service/impl/GoodsServiceImpl.java

@@ -93,4 +93,13 @@ public class GoodsServiceImpl implements IGoodsService
     {
         return goodsMapper.deleteGoodsById(id);
     }
+
+
+    /**
+     * 批量修改
+     */
+    @Override
+    public void updateBatchByGoodsCode(List<Goods> goodsList) {
+        goodsMapper.updateBatchByGoodsCode(goodsList);
+    }
 }

+ 15 - 0
inventory-system/src/main/resources/mapper/system/BillsDetailsMapper.xml

@@ -83,6 +83,21 @@
         where id = #{id}
     </update>
 
+    <update id="updateBatchByBillsId" parameterType="java.util.List">
+        update bills_details
+        <trim prefix="SET" suffixOverrides=",">
+            <trim prefix="goods_status = CASE" suffix="END,">
+                <foreach collection="list" item="item">
+                    WHEN bills_id = #{item.billsId} THEN #{item.goodsStatus}
+                </foreach>
+            </trim>
+        </trim>
+        where bills_id in
+        <foreach collection="list" item="item" open="(" separator="," close=")">
+            #{item.billsId}
+        </foreach>
+    </update>
+
     <delete id="deleteBillsDetailsById" parameterType="Long">
         delete from bills_details where id = #{id}
     </delete>

+ 16 - 0
inventory-system/src/main/resources/mapper/system/GoodsMapper.xml

@@ -30,6 +30,7 @@
             <if test="goodsType != null  and goodsType != ''"> and goods_type = #{goodsType}</if>
             <if test="quantityStock != null "> and quantity_stock = #{quantityStock}</if>
             <if test="goodsStatus != null "> and goods_status = #{goodsStatus}</if>
+            <if test="remark != null  and remark != ''"> and remark like concat('%', #{remark}, '%')</if>
         </where>
     </select>
 
@@ -85,6 +86,21 @@
         where id = #{id}
     </update>
 
+    <update id="updateBatchByGoodsCode" parameterType="java.util.List">
+        update goods
+        <trim prefix="SET" suffixOverrides=",">
+            <trim prefix="goods_status = CASE" suffix="END,">
+                <foreach collection="list" item="item">
+                    WHEN goods_code = #{item.goodsCode} THEN #{item.goodsStatus}
+                </foreach>
+            </trim>
+        </trim>
+        where goods_code in
+        <foreach collection="list" item="item" open="(" separator="," close=")">
+            #{item.goodsCode}
+        </foreach>
+    </update>
+
     <delete id="deleteGoodsById" parameterType="Long">
         delete from goods where id = #{id}
     </delete>

+ 10 - 2
inventory-ui/src/views/inventory/bills/index.vue

@@ -91,7 +91,7 @@
             type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
-            v-hasPermi="['system:bills:edit']"
+            v-hasPermi="['inventory:bills:edit']"
           >修改</el-button>
           <el-button size="mini" type="text" icon="el-icon-share" @click="selectBillsDetails(scope.row)">查看单据详情</el-button>
           <el-button
@@ -99,7 +99,7 @@
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
-            v-hasPermi="['system:bills:remove']"
+            v-hasPermi="['inventory:bills:remove']"
           >删除</el-button>
         </template>
       </el-table-column>
@@ -247,6 +247,14 @@
         </template>
       </el-table-column>
       </el-table>
+
+      <pagination
+      v-show="detailsTotal>0"
+      :total="detailsTotal"
+      :page.sync="billsDetailsParams.pageNum"
+      :limit.sync="billsDetailsParams.pageSize"
+      @pagination="getBillsDetailsList"
+    />
     </el-dialog>
   </div>
 </template>

+ 2 - 1
inventory-ui/vue.config.js

@@ -35,7 +35,8 @@ module.exports = {
     proxy: {
       // detail: https://cli.vuejs.org/config/#devserver-proxy
       [process.env.VUE_APP_BASE_API]: {
-        target: `https://yaorong.yaorongmedical.com/`,
+        // target: `https://yaorong.yaorongmedical.com/`,
+        target: `http://localhost:8088`,
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''