Browse Source

添加仓库模块调拨功能

阿伏兔 4 years ago
parent
commit
394b96045a

+ 215 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/warehouseBusiness/TWarehouseStockTransferController.java

@@ -0,0 +1,215 @@
+package com.ruoyi.web.controller.warehouse.warehouseBusiness;
+
+import com.ruoyi.common.annotation.DataScope;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.ServletUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import com.ruoyi.framework.web.service.TokenService;
+import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
+import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 仓库调拨主表Controller
+ *
+ * @author ruoyi
+ * @date 2020-12-11
+ */
+@RestController
+@RequestMapping("/warehouseBusiness/stockTransfer")
+public class TWarehouseStockTransferController extends BaseController {
+    @Autowired
+    private ITWarehouseBillsService itWarehouseBillsService;
+
+    /**
+     * 查询出库详情主表列表
+     */
+    @GetMapping("/getWarehouseStockTransfer")
+    @DataScope(deptAlias = "d", userAlias = "u")
+    public String getWarehouseStockTransferBillsNo(TWarehouseBills tWarehouseBills) {
+        return itWarehouseBillsService.getWarehouseInStockBillsNo(tWarehouseBills);
+    }
+
+    /**
+     * 查询入库详情主表列表
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:list')")
+    @DataScope(deptAlias = "d", userAlias = "u")
+    @GetMapping("/list")
+    public TableDataInfo list(TWarehouseBills tWarehouseBills) {
+        System.out.println(tWarehouseBills.toString());
+        startPage();
+        tWarehouseBills.setfBilltype("CKDB");
+        List<Map<String, Object>> list = itWarehouseBillsService.selectWarehouseBusinessList(tWarehouseBills);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 导出入库详情主表列表
+     */
+    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:export')")
+    @Log(title = "详情主表", businessType = BusinessType.EXPORT)
+    @DataScope(deptAlias = "d", userAlias = "u")
+    @GetMapping("/export")
+    public AjaxResult export(TWarehouseBills tWarehouseBills) {
+        tWarehouseBills.setfBilltype("CKDB");
+        List<TWarehouseBills> list = itWarehouseBillsService.selectTWarehousebillsList(tWarehouseBills);
+        ExcelUtil<TWarehouseBills> util = new ExcelUtil<TWarehouseBills>(TWarehouseBills.class);
+        return util.exportExcel(list, "warehousebills");
+    }
+
+    /**
+     * 获取入库仓库详细信息
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:query')")
+    @GetMapping(value = "/{fId}")
+    @RepeatSubmit
+    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
+        return AjaxResult.success(itWarehouseBillsService.selectTWarehousebillsById(fId));
+    }
+
+    /**
+     * 入库暂存
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:add')")
+    @Log(title = "详情主表", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/add")
+    @RepeatSubmit
+    public AjaxResult add(@RequestParam("warehouseBills") String warehouseBills,
+                          @RequestParam("tEnclosure") String tEnclosure,
+                          @RequestParam("warehousebillsfeesCr") String warehousebillsfeesCr,
+                          @RequestParam("warehousebillsfeesDr") String warehousebillsfeesDr,
+                          @RequestParam("warehousebillsitems") String warehousebillsitems) {
+        String billsType = "CKDB";
+        if (StringUtils.isNull(warehouseBills) || "{}".equals(warehouseBills)) {
+            return AjaxResult.error("未找到仓库主表数据,请确认");
+        }
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return itWarehouseBillsService.insertTWarehousebills(warehouseBills, warehousebillsfeesCr,
+                warehousebillsfeesDr, warehousebillsitems, tEnclosure, loginUser, billsType);
+    }
+
+    /**
+     * 调拨提交
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:add')")
+    @Log(title = "详情主表", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/warehouseSubmission")
+    @RepeatSubmit
+    public AjaxResult warehouseSubmission(@RequestParam("warehouseBills") String warehouseBills,
+                                          @RequestParam("tEnclosure") String tEnclosure,
+                                          @RequestParam("warehousebillsfeesCr") String warehousebillsfeesCr,
+                                          @RequestParam("warehousebillsfeesDr") String warehousebillsfeesDr,
+                                          @RequestParam("warehousebillsitems") String warehousebillsitems) {
+        String billsType = "CKDB";
+        if (StringUtils.isNull(warehouseBills) || "{}".equals(warehouseBills)) {
+            return AjaxResult.error("未找到仓库主表数据,请确认");
+        }
+        if (StringUtils.isNull(warehousebillsitems) || "[]".equals(warehousebillsitems)) {
+            return AjaxResult.error("未找到仓库明细数据,请确认");
+        }
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return itWarehouseBillsService.warehouseSubmission(warehouseBills, warehousebillsfeesCr,
+                warehousebillsfeesDr, warehousebillsitems, tEnclosure, loginUser, billsType);
+    }
+
+    /**
+     * 修改入库详情主表
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:edit')")
+    @Log(title = "详情主表", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody TWarehouseBills tWarehouseBills) {
+        return toAjax(itWarehouseBillsService.updateTWarehousebills(tWarehouseBills));
+    }
+
+    /**
+     * 删除入库详情主表
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:remove')")
+    @Log(title = "详情主表", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{fIds}")
+    @RepeatSubmit
+    public AjaxResult remove(@PathVariable Long[] fIds) {
+        return toAjax(itWarehouseBillsService.deleteTWarehousebillsByIds(fIds));
+    }
+
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:remove')")
+    @Log(title = "详情主表", businessType = BusinessType.DELETE)
+    @DeleteMapping("/queryRemove/{fId}")
+    public AjaxResult queryRemove(@PathVariable("fId") Long fId) {
+        return itWarehouseBillsService.queryRemove(fId);
+    }
+
+    /**
+     * 撤销入库信息
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:revoke')")
+    @Log(title = "详情主表", businessType = BusinessType.UPDATE)
+    @GetMapping("/get/{fId}")
+    @RepeatSubmit
+    public AjaxResult revoke(@PathVariable("fId") Long fId) {
+        String billsType = "CKDBRevoke";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return itWarehouseBillsService.revokeTWarehousebillsById(fId, loginUser, billsType);
+    }
+
+    /**
+     * 撤销入库
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:add')")
+    @Log(title = "详情主表", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/updateCredit")
+    public AjaxResult deleteCredit(@RequestParam("warehouseBills") String warehouseBills,
+                                   @RequestParam("tEnclosure") String tEnclosure,
+                                   @RequestParam("warehousebillsfeesCr") String warehousebillsfeesCr,
+                                   @RequestParam("warehousebillsfeesDr") String warehousebillsfeesDr,
+                                   @RequestParam("warehousebillsitems") String warehousebillsitems) {
+        String billsType = "CKDBRevoke";
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return itWarehouseBillsService.revokeTWarehousebillsById1(warehouseBills, warehousebillsitems,
+                tEnclosure, warehousebillsfeesCr, warehousebillsfeesDr, loginUser, billsType);
+    }
+
+    /**
+     * 调拨确认   状态 改为 -->  已入库
+     */
+//    @PreAuthorize("@ss.hasPermi('warehouseBusiness:StockTransfer:add')")
+    @Log(title = "详情主表", businessType = BusinessType.INSERT)
+    @PostMapping(value = "/addCredit")
+    @RepeatSubmit
+    public AjaxResult addCredit(@RequestParam("warehouseBills") String warehouseBills,
+                                @RequestParam("tEnclosure") String tEnclosure,
+                                @RequestParam("warehousebillsfeesCr") String warehousebillsfeesCr,
+                                @RequestParam("warehousebillsfeesDr") String warehousebillsfeesDr,
+                                @RequestParam("warehousebillsitems") String warehousebillsitems) {
+        String billsType = "CKDB";
+        if (StringUtils.isNull(warehouseBills) || "{}".equals(warehouseBills)) {
+            return AjaxResult.error("未找到主表信息,请确认");
+        }
+        if (StringUtils.isNull(warehousebillsitems) || "[]".equals(warehousebillsitems)) {
+            return AjaxResult.error("未找到明细信息,请确认");
+        }
+        // 获取当前的用户
+        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
+        return itWarehouseBillsService.updateCredit(warehouseBills, warehousebillsitems, tEnclosure, warehousebillsfeesCr,
+                warehousebillsfeesDr, loginUser, billsType);
+    }
+
+}

+ 0 - 158
ruoyi-admin/src/main/java/com/ruoyi/web/controller/warehouse/warehouseBusiness/TWarehouseTransferController.java

@@ -1,158 +0,0 @@
-package com.ruoyi.web.controller.warehouse.warehouseBusiness;
-
-import com.ruoyi.common.annotation.DataScope;
-import com.ruoyi.common.annotation.Log;
-import com.ruoyi.common.annotation.RepeatSubmit;
-import com.ruoyi.common.core.controller.BaseController;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.common.utils.ServletUtils;
-import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.common.utils.spring.SpringUtils;
-import com.ruoyi.framework.web.service.TokenService;
-import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
-import com.ruoyi.warehouseBusiness.service.ITWarehouseBillsService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * 仓储调拨Controller
- *
- * @author ruoyi
- * @date 2020-12-28
- */
-@RestController
-@RequestMapping("/warehouseBusiness/transfer")
-public class TWarehouseTransferController extends BaseController {
-    @Autowired
-    private ITWarehouseBillsService itWarehouseBillsService;
-
-    /**
-     * 查询调拨详情主表列表
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:list')")
-    @DataScope(deptAlias = "d", userAlias = "u")
-    @GetMapping("/list")
-    public TableDataInfo list(TWarehouseBills tWarehouseBills) {
-        startPage();
-        tWarehouseBills.setfBilltype("CKDB");
-        List<Map<String, Object>> list = itWarehouseBillsService.selectWarehouseBusinessList(tWarehouseBills);
-        return getDataTable(list);
-    }
-
-
-    /**
-     * 查询调拨详情主表列表
-     */
-    @DataScope(deptAlias = "d", userAlias = "u")
-    @GetMapping("/getWarehouseTransfer")
-    public String getWarehouseInStockBillsNo(TWarehouseBills tWarehouseBills) {
-        return itWarehouseBillsService.getWarehouseInStockBillsNo(tWarehouseBills);
-    }
-
-
-    /**
-     * 导出调拨详情主表列表
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:export')")
-    @Log(title = "详情主表", businessType = BusinessType.EXPORT)
-    @GetMapping("/export")
-    @RepeatSubmit
-    public AjaxResult export(TWarehouseBills tWarehouseBills) {
-        List<TWarehouseBills> list = itWarehouseBillsService.selectTWarehousebillsList(tWarehouseBills);
-        ExcelUtil<TWarehouseBills> util = new ExcelUtil<TWarehouseBills>(TWarehouseBills.class);
-        return util.exportExcel(list, "warehousebills");
-    }
-
-    /**
-     * 获取调拨仓库详细信息
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:query')")
-    @GetMapping(value = "/{fId}")
-    @RepeatSubmit
-    public AjaxResult getInfo(@PathVariable("fId") Long fId) {
-        return AjaxResult.success(itWarehouseBillsService.selectTWarehousebillsById(fId));
-    }
-
-    /**
-     * 新增调拨详情主表
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:add')")
-    @Log(title = "详情主表", businessType = BusinessType.INSERT)
-    @PostMapping(value = "/add")
-    @RepeatSubmit
-    public AjaxResult add(@RequestParam("tWarehouseBills") String tWarehouseBills,
-                          @RequestParam("tWhgenleg") String tWhgenleg,
-                          @RequestParam("tWarehousebillsfeesCr") String tWarehousebillsfeesCr,
-                          @RequestParam("tWarehousebillsfeesDr") String tWarehousebillsfeesDr,
-                          @RequestParam("tWarehousebillsitems") String tWarehousebillsitems) {
-        System.out.println("主表:" + tWarehouseBills);
-        System.out.println("附件:" + tWhgenleg);
-        System.out.println("付款:" + tWarehousebillsfeesCr);
-        System.out.println("收款:" + tWarehousebillsfeesDr);
-        System.out.println("明细:" + tWarehousebillsitems);
-        String billsType = "CKDB";
-        /*if (StringUtils.isEmpty(tWarehouseBills)) {
-            return AjaxResult.error("提交失败:请检查主表数据");
-        }
-        if (tWarehousebillsitems.equals("[]")) {
-            return AjaxResult.error("提交失败:请检查库存明细数据");
-        }
-        if (tWhgenleg.equals("[]")) {
-            return AjaxResult.error("提交失败:请检查附件信息");
-        }
-        if (tWarehousebillsfeesDr.equals("[]")) {
-            return AjaxResult.error("提交失败:请检查收款明细数据");
-        }
-        if (tWarehousebillsfeesCr.equals("[]")) {
-            return AjaxResult.error("提交失败:请检查付款明细数据");
-        }*/
-        // 获取当前的用户
-        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
-        return itWarehouseBillsService.insertTWarehousebills(tWarehouseBills, tWarehousebillsfeesCr,
-                tWarehousebillsfeesDr, tWarehousebillsitems, tWhgenleg, loginUser, billsType);
-    }
-
-    /**
-     * 修改调拨详情主表
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:edit')")
-    @Log(title = "详情主表", businessType = BusinessType.UPDATE)
-    @PutMapping
-    @RepeatSubmit
-    public AjaxResult edit(@RequestBody TWarehouseBills tWarehouseBills) {
-        return toAjax(itWarehouseBillsService.updateTWarehousebills(tWarehouseBills));
-    }
-
-    /**
-     * 删除调拨详情主表
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:remove')")
-    @Log(title = "详情主表", businessType = BusinessType.DELETE)
-    @DeleteMapping("/{fIds}")
-    @RepeatSubmit
-    public AjaxResult remove(@PathVariable Long[] fIds) {
-        return toAjax(itWarehouseBillsService.deleteTWarehousebillsByIds(fIds));
-    }
-
-    /**
-     *  撤销调拨信息
-     */
-    @PreAuthorize("@ss.hasPermi('warehouseBusiness:transfer:revoke')")
-    @Log(title = "详情主表", businessType = BusinessType.UPDATE)
-    @GetMapping("/get/{fId}")
-    @RepeatSubmit
-    public AjaxResult revoke(@PathVariable("fId") Long fId) {
-        String  billsType="CKDBRevoke";
-        // 获取当前的用户
-        LoginUser loginUser = SpringUtils.getBean(TokenService.class).getLoginUser(ServletUtils.getRequest());
-        return itWarehouseBillsService.revokeTWarehousebillsById(fId,loginUser,billsType);
-    }
-
-}

+ 13 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/domain/TWarehousebillsitems.java

@@ -63,6 +63,10 @@ public class TWarehousebillsitems extends BaseEntity {
     @Excel(name = "入库库区,存储库区ID,显示仓库 库位 库区,t_warehouse_area中的f_id")
     private Long fWarehouselocid;
 
+    /** 调拨库区 */
+    @Excel(name = "调拨库区")
+    private Long fTransferWarehouselocid;
+
     /**
      * 原始入库业务编号
      */
@@ -338,6 +342,14 @@ public class TWarehousebillsitems extends BaseEntity {
         return fWarehouselocid;
     }
 
+    public void setfTransferWarehouselocid(Long fTransferWarehouselocid) {
+        this.fTransferWarehouselocid = fTransferWarehouselocid;
+    }
+
+    public Long getfTransferWarehouselocid() {
+        return fTransferWarehouselocid;
+    }
+
     public void setfStorageFeeDeadline(Date fStorageFeeDeadline) {
         this.fStorageFeeDeadline = fStorageFeeDeadline;
     }
@@ -629,6 +641,7 @@ public class TWarehousebillsitems extends BaseEntity {
                 .append("fBillno", getfBillno())
                 .append("fMblno", getfMblno())
                 .append("fWarehouselocid", getfWarehouselocid())
+                .append("fTransferWarehouselocid", getfTransferWarehouselocid())
                 .append("fOriginalbillno", getfOriginalbillno())
                 .append("fBsdate", getfBsdate())
                 .append("fBoxno", getfBoxno())

+ 48 - 23
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -178,8 +178,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     goodsId.add(fGoodsid.longValue());
                 }
                 if (StringUtils.isNotNull(wb.get("fWarehouselocid"))) {
-                    Integer fWarehouselocid = (Integer) wb.get("fWarehouselocid");
-                    warehouseAreaId.add(fWarehouselocid.longValue());
+                    Long fWarehouselocid = Long.valueOf(String.valueOf(wb.get("fWarehouselocid")));
+                    Long fTransferWarehouselocid = Long.valueOf(String.valueOf(wb.get("fTransferWarehouselocid")));
+                    warehouseAreaId.add(fWarehouselocid);
+                    warehouseAreaId.add(fTransferWarehouselocid);
                 }
             }
             map.put("warehouseBillsItem", mapList);
@@ -313,9 +315,14 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         if ("SJRK".equals(warehouseBills.getfBilltype()) || "HQZY".equals(warehouseBills.getfBilltype())) {
             tWhgenleg.setfOriginalbilldate(new Date());
         }
-        if ("HQZY".equals(warehouseBills.getfBilltype())) {
-            // 客户
-            tWhgenleg.setfCorpid(warehouseBills.getfTocorpid());
+        if ("HQZY".equals(warehouseBills.getfBilltype()) || "CKDB".equals(warehouseBills.getfBilltype())) {
+            if ("CKDB".equals(warehouseBills.getfBilltype())) {
+                tWhgenleg.setfCorpid(warehouseBills.getfCorpid());
+                tWhgenleg.setfOriginalbilldate(warehousebillsitems.getfOriginalbilldate());
+            } else {
+                // 客户
+                tWhgenleg.setfCorpid(warehouseBills.getfTocorpid());
+            }
             // 提单号
             tWhgenleg.setfMblno(warehousebillsitems.getfMblno());
             // 原始单号
@@ -425,6 +432,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             JSONArray warehouseJSON = JSONArray.parseArray(tWarehousebillsitems);
             List<TWarehousebillsitems> warehousebillsitemsList = JSONObject.parseArray(warehouseJSON.toJSONString(), TWarehousebillsitems.class);
             for (TWarehousebillsitems wbItem : warehousebillsitemsList) {
+                boolean warehouseStatus = "SJRK".equals(billsType) || "SJCK".equals(billsType);
                 // 仓储计费日期
                 wbItem.setfChargedate(warehouseBills.getfChargedate());
                 wbItem.setfBilltype(billsType);
@@ -432,21 +440,23 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     wbItem.setfBillingway(warehouseBills.getfBillingway());
                 }
                 if (null != wbItem.getfId()) {
-                    wbItem.setUpdateBy(loginUser.getUser().getUserName());
                     wbItem.setUpdateTime(new Date());
+                    wbItem.setUpdateBy(loginUser.getUser().getUserName());
                     tWarehousebillsitemsMapper.updateTWarehousebillsitems(wbItem);
                 } else {
                     // 添加主表 业务单号
                     wbItem.setfBillno(warehouseBills.getfBillno());
-                    if (!"HQZY".equals(billsType)) {
+                    if (!warehouseStatus) {
                         wbItem.setfMblno(warehouseBills.getfMblno());
+                        wbItem.setfBillstatus(1L);
+                    } else {
+                        wbItem.setfBillstatus(10L);
                     }
                     wbItem.setfPid(fPid);
                     wbItem.setCreateBy(loginUser.getUser().getUserName());
                     wbItem.setCreateTime(new Date());
-                    wbItem.setfBillstatus(10L);
                     tWarehousebillsitemsMapper.insertTWarehousebillsitems(wbItem);
-                    if (!"HQZY".equals(billsType)) {
+                    if (!warehouseStatus) {
                         // 添加状态log
                         insertTWarehousebillsLog(wbItem, 10L, loginUser);
                     }
@@ -523,11 +533,10 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             actId = 120L;
             key = "warehouse.outStock.ApprovalFlow";
         } else if ("CKDB".equals(billsType)) {
-            // 调拨业务待维护
-            actId = 130L;
-            key = "warehouse.adjustment.ApprovalFlow";
-        } else if ("HQZY".equals(billsType)) {
             actId = 140L;
+            key = "warehouse.stockTransfer.ApprovalFlow";
+        } else if ("HQZY".equals(billsType)) {
+            actId = 130L;
             key = "warehouse.transfer.ApprovalFlow";
         }
         SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
@@ -681,7 +690,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
             }
             return approvalFlow;
         } else {
-            AjaxResult ajaxResult = storageFeeFollow(fPid, 6L);
+            AjaxResult ajaxResult = warehouseFollow(fPid, 6L);
             String code = ajaxResult.get("code").toString();
 //                Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
             if ("500".equals(code)) {
@@ -897,7 +906,11 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         Long fPid = null;
         Map<String, Object> map = new HashMap<>();
         TWarehouseBills tWarehouseBills = JSONArray.parseObject(warehouseBills, TWarehouseBills.class);
-        tWarehouseBills.setfItemsStatus(4L);
+        if ("SJCK".equals(billsType)) {
+            tWarehouseBills.setfItemsStatus(4L);
+        } else {
+            tWarehouseBills.setfItemsStatus(6L);
+        }
         tWarehouseBills.setfBilltype(billsType);
         if (StringUtils.isNotNull(tWarehouseBills.getfId())) {
             tWarehouseBills.setUpdateBy(loginUser.getUser().getUserName());
@@ -921,6 +934,13 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         List<TFees> feesList = new ArrayList<>();
         List<TWarehousebillsfees> warehousebillsfees = new ArrayList<>();
         for (TWarehousebillsitems wbItem : warehousebillsitemsList) {
+            long warehouselocId = 0L;
+            long transferWarehouselocid = 0L;
+            if ("CKDB".equals(billsType)) {
+                warehouselocId = wbItem.getfWarehouselocid();
+                transferWarehouselocid = wbItem.getfTransferWarehouselocid();
+//                wbItem.setfWarehouselocid(transferWarehouselocid);
+            }
             // 查询总账是否存在
             TWhgenleg tWhgenle = queryTWhgenleg(tWarehouseBills, wbItem);
             //  入库数特殊不判断入账
@@ -929,7 +949,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     return AjaxResult.error("库存明细第" + i + "行库存为空");
                 } else { // 非空修改库存总账
-                    //  库存 <  出库件数
+                    //  库存 <  出库件数
                     if (tWhgenle.getfQtyblc() < wbItem.getfQty()) {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return AjaxResult.error("库存明细第" + i + "行库存不足");
@@ -983,10 +1003,11 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return AjaxResult.error("库存明细第" + i + "行库存不足");
                     } else {  // 2、 库存足够 先 进行出库操作
+                        wbItem.setfWarehouselocid(warehouselocId);
                         updateTWhgenlegData(wbItem, tWhgenle.getfId(), "SJCK");
                     }
                     // 3、 进行入库操作 查询是否存在库存
-                    tWarehouseBills.setfCorpid(tWarehouseBills.getfTocorpid()); // 新货权方
+                    wbItem.setfWarehouselocid(transferWarehouselocid); // 新库区
                     TWhgenleg tWhgenle1 = queryTWhgenleg(tWarehouseBills, wbItem);
                     if (StringUtils.isNull(tWhgenle1)) {   // 5、 不存在 进行新增库存
                         instalTWhgenleg(tWarehouseBills, wbItem, loginUser.getUser());
@@ -994,6 +1015,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         updateTWhgenlegData(wbItem, tWhgenle1.getfId(), "SJRK");
                     }
                 }
+                wbItem.setfBillstatus(6L);
             } else if ("HQZY".equals(billsType)) { // 货转
                 wbItem.setfBillstatus(6L);
                 wbItem.setfChargedate(tWarehouseBills.getfChargedate());
@@ -1762,6 +1784,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return AjaxResult.error("第" + i + "行撤销数大于库存结余数");
                     }
+                    wb.setfBillstatus(10L);
                 } else if ("SJCKRevoke".equals(billsType)) { // 撤销出库
                     if (StringUtils.isNotNull(tWhgenle)) { // 非空
                         updateTWhgenlegData(wb, tWhgenle.getfId(), billsType);
@@ -1769,24 +1792,26 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return AjaxResult.error("第" + i + "行未查询到库存信息");
                     }
+                    wb.setfBillstatus(10L);
                 } else if ("CKDBRevoke".equals(billsType)) { // 调拨 撤销
-                    Long fCorpid = tWarehousebills.getfCorpid();// 原货权方
-                    Long fTocorpid = tWarehousebills.getfTocorpid(); // 新货权方
+                    Long warehouselocid = wb.getfWarehouselocid();// 原货仓库
+                    Long transferWarehouselocid = wb.getfTransferWarehouselocid(); // 新仓库
                     //  1、新货权方撤销入库
                     // 查询库存总账
-                    tWarehousebills.setfCorpid(fTocorpid);
+                    wb.setfWarehouselocid(transferWarehouselocid);
                     TWhgenleg tWhgenle1 = queryTWhgenleg(tWarehousebills, wb);
                     if (StringUtils.isNotNull(tWhgenle1) && (wb.getfQty() <= tWhgenle1.getfQtyblc())) {
                         updateTWhgenlegData(wb, tWhgenle1.getfId(), "SJRKRevoke");
                     } else {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
-                        return AjaxResult.error("第" + i + "行撤销数大于库存结余数");
+                        return AjaxResult.error("第" + i + "行撤销数大于库存结余数") ;
                     }
                     //  2、原货权方撤销出库
                     // 查询库存总账
-                    tWarehousebills.setfCorpid(fCorpid);
+                    wb.setfWarehouselocid(warehouselocid);
                     TWhgenleg tWhgenle2 = queryTWhgenleg(tWarehousebills, wb);
                     updateTWhgenlegData(wb, tWhgenle2.getfId(), "SJCKRevoke");
+                    wb.setfBillstatus(1L);
                 } else if ("HQZYRevoke".equals(billsType)) { // 货转撤销
                     Long fCorpid = tWarehousebills.getfCorpid();// 原货权方
                     Long fTocorpid = tWarehousebills.getfTocorpid(); // 新货权方
@@ -1805,9 +1830,9 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
                     tWarehousebills.setfCorpid(fCorpid);
                     TWhgenleg tWhgenle2 = queryTWhgenleg(tWarehousebills, wb);
                     updateTWhgenlegData(wb, tWhgenle2.getfId(), "SJCKRevoke");
+                    wb.setfBillstatus(1L);
                 }
                 i++;
-                wb.setfBillstatus(10L);
                 wb.setUpdateBy(loginUser.getUser().getUserName());
                 wb.setUpdateTime(new Date());
                 if (tWarehousebillsitemsMapper.updateTWarehousebillsitems(wb) <= 0) {

+ 35 - 29
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsitemsMapper.xml

@@ -14,6 +14,7 @@
         <result property="fMblno" column="f_mblno"/>
         <result property="fWarehouselocid" column="f_warehouselocid"/>
         <result property="fOriginalbillno" column="f_originalbillno"/>
+        <result property="fTransferWarehouselocid" column="f_transfer_warehouselocid"/>
         <result property="fBsdate" column="f_bsdate"/>
         <result property="fBoxno" column="f_boxno"/>
         <result property="fCntqty" column="f_cntqty"/>
@@ -56,8 +57,8 @@
     </resultMap>
 
     <sql id="selectTWarehousebillsitemsVo">
-        select f_id, f_pid, f_lineno, f_srcid, f_billno, f_goodsid, f_mblno, f_warehouselocid, f_originalbillno, f_bsdate, f_cntqty, f_boxno, f_cntrtype, f_goodsval, f_originalbilldate, f_planqty, f_billingway, f_planvolumn, f_packagespecs, f_chargedate, f_plangrossweight, f_plannetweight, f_qty, f_grossweight, f_volumn, f_netweight, f_cntrno, f_truckno, f_billstatus, del_flag, create_by, create_time, update_by, update_time, remark, f_marks, f_inventory_days, f_storage_fee_deadline, f_amt, f_billing_days, f_driver_name, f_driver_tel, f_driver_id_car, f_serial_number, f_is_pass, f_billtype, f_billing_qty, f_billing_deadline from t_warehousebillsitems
-      </sql>
+        select f_id, f_pid, f_srcid, f_lineno, f_billno, f_goodsid, f_warehouselocid, f_mblno, f_bsdate, f_originalbillno, f_boxno, f_cntqty, f_goodsval, f_cntrtype, f_billingway, f_transfer_warehouselocid, f_planvolumn, f_planqty, f_originalbilldate, f_plangrossweight, f_packagespecs, f_chargedate, f_plannetweight, f_qty, f_volumn, f_grossweight, f_netweight, f_cntrno, f_truckno, f_billstatus, del_flag, create_by, create_time, update_by, update_time, remark, f_marks, f_inventory_days, f_storage_fee_deadline, f_amt, f_billing_days, f_driver_name, f_driver_tel, f_driver_id_car, f_serial_number, f_is_pass, f_billtype, f_billing_qty, f_billing_deadline from t_warehousebillsitems
+    </sql>
 
     <select id="selectTWarehousebillsitemsList" parameterType="TWarehousebillsitems"
             resultMap="TWarehousebillsitemsResult">
@@ -74,6 +75,7 @@
             <if test="fBoxno != null  and fBoxno != ''">and f_boxno = #{fBoxno}</if>
             <if test="fOriginalbilldate != null ">and f_originalbilldate = #{fOriginalbilldate}</if>
             <if test="fStorageFeeDeadline != null "> and f_storage_fee_deadline = #{fStorageFeeDeadline}</if>
+            <if test="fTransferWarehouselocid != null "> and f_transfer_warehouselocid = #{fTransferWarehouselocid}</if>
             <if test="fCntqty != null ">and f_cntqty = #{fCntqty}</if>
             <if test="fGoodsval != null ">and f_goodsval = #{fGoodsval}</if>
             <if test="fCntrtype != null  and fCntrtype != ''">and f_cntrtype = #{fCntrtype}</if>
@@ -132,6 +134,7 @@
             item.f_plangrossweight AS fPlangrossweight,
             item.f_originalbilldate AS fOriginalbilldate,
             item.f_plannetweight AS fPlannetweight,
+            item.f_transfer_warehouselocid AS fTransferWarehouselocid,
             item.f_qty AS fQty,
             item.f_volumn AS fVolumn,
             item.f_driver_name AS fDriverName,
@@ -164,29 +167,30 @@
         insert into t_warehousebillsitems
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="fPid != null">f_pid,</if>
-            <if test="fLineno != null">f_lineno,</if>
             <if test="fSrcid != null">f_srcid,</if>
+            <if test="fLineno != null">f_lineno,</if>
             <if test="fBillno != null">f_billno,</if>
             <if test="fGoodsid != null">f_goodsid,</if>
-            <if test="fMblno != null">f_mblno,</if>
             <if test="fWarehouselocid != null">f_warehouselocid,</if>
-            <if test="fOriginalbillno != null">f_originalbillno,</if>
+            <if test="fMblno != null">f_mblno,</if>
             <if test="fBsdate != null">f_bsdate,</if>
-            <if test="fCntqty != null">f_cntqty,</if>
+            <if test="fOriginalbillno != null">f_originalbillno,</if>
             <if test="fBoxno != null">f_boxno,</if>
-            <if test="fCntrtype != null">f_cntrtype,</if>
+            <if test="fCntqty != null">f_cntqty,</if>
             <if test="fGoodsval != null">f_goodsval,</if>
-            <if test="fOriginalbilldate != null">f_originalbilldate,</if>
-            <if test="fPlanqty != null">f_planqty,</if>
+            <if test="fCntrtype != null">f_cntrtype,</if>
             <if test="fBillingway != null">f_billingway,</if>
+            <if test="fTransferWarehouselocid != null">f_transfer_warehouselocid,</if>
             <if test="fPlanvolumn != null">f_planvolumn,</if>
+            <if test="fPlanqty != null">f_planqty,</if>
+            <if test="fOriginalbilldate != null">f_originalbilldate,</if>
+            <if test="fPlangrossweight != null">f_plangrossweight,</if>
             <if test="fPackagespecs != null">f_packagespecs,</if>
             <if test="fChargedate != null">f_chargedate,</if>
-            <if test="fPlangrossweight != null">f_plangrossweight,</if>
             <if test="fPlannetweight != null">f_plannetweight,</if>
             <if test="fQty != null">f_qty,</if>
-            <if test="fGrossweight != null">f_grossweight,</if>
             <if test="fVolumn != null">f_volumn,</if>
+            <if test="fGrossweight != null">f_grossweight,</if>
             <if test="fNetweight != null">f_netweight,</if>
             <if test="fCntrno != null">f_cntrno,</if>
             <if test="fTruckno != null">f_truckno,</if>
@@ -213,29 +217,30 @@
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fPid != null">#{fPid},</if>
-            <if test="fLineno != null">#{fLineno},</if>
             <if test="fSrcid != null">#{fSrcid},</if>
+            <if test="fLineno != null">#{fLineno},</if>
             <if test="fBillno != null">#{fBillno},</if>
             <if test="fGoodsid != null">#{fGoodsid},</if>
-            <if test="fMblno != null">#{fMblno},</if>
             <if test="fWarehouselocid != null">#{fWarehouselocid},</if>
-            <if test="fOriginalbillno != null">#{fOriginalbillno},</if>
+            <if test="fMblno != null">#{fMblno},</if>
             <if test="fBsdate != null">#{fBsdate},</if>
-            <if test="fCntqty != null">#{fCntqty},</if>
+            <if test="fOriginalbillno != null">#{fOriginalbillno},</if>
             <if test="fBoxno != null">#{fBoxno},</if>
-            <if test="fCntrtype != null">#{fCntrtype},</if>
+            <if test="fCntqty != null">#{fCntqty},</if>
             <if test="fGoodsval != null">#{fGoodsval},</if>
-            <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
-            <if test="fPlanqty != null">#{fPlanqty},</if>
+            <if test="fCntrtype != null">#{fCntrtype},</if>
             <if test="fBillingway != null">#{fBillingway},</if>
+            <if test="fTransferWarehouselocid != null">#{fTransferWarehouselocid},</if>
             <if test="fPlanvolumn != null">#{fPlanvolumn},</if>
+            <if test="fPlanqty != null">#{fPlanqty},</if>
+            <if test="fOriginalbilldate != null">#{fOriginalbilldate},</if>
+            <if test="fPlangrossweight != null">#{fPlangrossweight},</if>
             <if test="fPackagespecs != null">#{fPackagespecs},</if>
             <if test="fChargedate != null">#{fChargedate},</if>
-            <if test="fPlangrossweight != null">#{fPlangrossweight},</if>
             <if test="fPlannetweight != null">#{fPlannetweight},</if>
             <if test="fQty != null">#{fQty},</if>
-            <if test="fGrossweight != null">#{fGrossweight},</if>
             <if test="fVolumn != null">#{fVolumn},</if>
+            <if test="fGrossweight != null">#{fGrossweight},</if>
             <if test="fNetweight != null">#{fNetweight},</if>
             <if test="fCntrno != null">#{fCntrno},</if>
             <if test="fTruckno != null">#{fTruckno},</if>
@@ -266,29 +271,30 @@
         update t_warehousebillsitems
         <trim prefix="SET" suffixOverrides=",">
             <if test="fPid != null">f_pid = #{fPid},</if>
-            <if test="fLineno != null">f_lineno = #{fLineno},</if>
             <if test="fSrcid != null">f_srcid = #{fSrcid},</if>
+            <if test="fLineno != null">f_lineno = #{fLineno},</if>
             <if test="fBillno != null">f_billno = #{fBillno},</if>
             <if test="fGoodsid != null">f_goodsid = #{fGoodsid},</if>
-            <if test="fMblno != null">f_mblno = #{fMblno},</if>
             <if test="fWarehouselocid != null">f_warehouselocid = #{fWarehouselocid},</if>
-            <if test="fOriginalbillno != null">f_originalbillno = #{fOriginalbillno},</if>
+            <if test="fMblno != null">f_mblno = #{fMblno},</if>
             <if test="fBsdate != null">f_bsdate = #{fBsdate},</if>
-            <if test="fCntqty != null">f_cntqty = #{fCntqty},</if>
+            <if test="fOriginalbillno != null">f_originalbillno = #{fOriginalbillno},</if>
             <if test="fBoxno != null">f_boxno = #{fBoxno},</if>
-            <if test="fCntrtype != null">f_cntrtype = #{fCntrtype},</if>
+            <if test="fCntqty != null">f_cntqty = #{fCntqty},</if>
             <if test="fGoodsval != null">f_goodsval = #{fGoodsval},</if>
-            <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
-            <if test="fPlanqty != null">f_planqty = #{fPlanqty},</if>
+            <if test="fCntrtype != null">f_cntrtype = #{fCntrtype},</if>
             <if test="fBillingway != null">f_billingway = #{fBillingway},</if>
+            <if test="fTransferWarehouselocid != null">f_transfer_warehouselocid = #{fTransferWarehouselocid},</if>
             <if test="fPlanvolumn != null">f_planvolumn = #{fPlanvolumn},</if>
+            <if test="fPlanqty != null">f_planqty = #{fPlanqty},</if>
+            <if test="fOriginalbilldate != null">f_originalbilldate = #{fOriginalbilldate},</if>
+            <if test="fPlangrossweight != null">f_plangrossweight = #{fPlangrossweight},</if>
             <if test="fPackagespecs != null">f_packagespecs = #{fPackagespecs},</if>
             <if test="fChargedate != null">f_chargedate = #{fChargedate},</if>
-            <if test="fPlangrossweight != null">f_plangrossweight = #{fPlangrossweight},</if>
             <if test="fPlannetweight != null">f_plannetweight = #{fPlannetweight},</if>
             <if test="fQty != null">f_qty = #{fQty},</if>
-            <if test="fGrossweight != null">f_grossweight = #{fGrossweight},</if>
             <if test="fVolumn != null">f_volumn = #{fVolumn},</if>
+            <if test="fGrossweight != null">f_grossweight = #{fGrossweight},</if>
             <if test="fNetweight != null">f_netweight = #{fNetweight},</if>
             <if test="fCntrno != null">f_cntrno = #{fCntrno},</if>
             <if test="fTruckno != null">f_truckno = #{fTruckno},</if>