diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java index 684f538a..2e182fa2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/controller/WarehouseInventoryCheckController.java @@ -1,15 +1,13 @@ package com.ruoyi.warehouse.controller; import java.util.List; + +import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; @@ -84,7 +82,7 @@ public class WarehouseInventoryCheckController extends BaseController @Log(title = "仓库库存盘点", businessType = BusinessType.INSERT) @PostMapping("/add") @ResponseBody - public AjaxResult addSave(WarehouseInventoryCheck warehouseInventoryCheck) + public AjaxResult addSave(@RequestBody WarehouseInventoryCheck warehouseInventoryCheck) { return toAjax(warehouseInventoryCheckService.insertWarehouseInventoryCheck(warehouseInventoryCheck)); } @@ -113,4 +111,27 @@ public class WarehouseInventoryCheckController extends BaseController } + + /** + * 物料信息弹出页面 + */ + @GetMapping("/materialSelect") + public String materialSelect() + { + return prefix + "/materialSelect"; + } + + + /** + * 查找与库存查询有关的物料信息 + * */ + @ResponseBody + @PostMapping("/getAllMaterialInfo") + public TableDataInfo getAllMaterialInfo(){ + startPage(); + List list = warehouseInventoryCheckService.selectAllMaterialInfo(); + return getDataTable(list); + } + + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseMaterialVO.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseMaterialVO.java new file mode 100644 index 00000000..92d12b9b --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/VO/WarehouseMaterialVO.java @@ -0,0 +1,30 @@ +package com.ruoyi.warehouse.domain.VO; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import lombok.Data; + +@Data +public class WarehouseMaterialVO extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** 料号 */ + @Excel(name = "料号") + private String materialNo; + + /** 物料名称 */ + @Excel(name = "物料名称") + private String materialName; + + /** 物料单位 */ + @Excel(name = "物料单位") + private String materialUnit; + + /** 物料描述 */ + @Excel(name = "物料描述") + private String materialDescribe; + + + +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java index 922fe115..978e5f6d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseInventoryCheck.java @@ -1,6 +1,8 @@ package com.ruoyi.warehouse.domain; import java.util.Date; +import java.util.List; + import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -57,6 +59,8 @@ public class WarehouseInventoryCheck extends BaseEntity @Excel(name = "数量合计") private Integer numTotal; + private List inventoryCheckDetails; + public void setInventoryCheckId(Long inventoryCheckId) { this.inventoryCheckId = inventoryCheckId; @@ -148,6 +152,15 @@ public class WarehouseInventoryCheck extends BaseEntity return numTotal; } + + public List getInventoryCheckDetails() { + return inventoryCheckDetails; + } + + public void setInventoryCheckDetails(List inventoryCheckDetails) { + this.inventoryCheckDetails = inventoryCheckDetails; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) @@ -166,6 +179,7 @@ public class WarehouseInventoryCheck extends BaseEntity .append("createBy", getCreateBy()) .append("updateBy", getUpdateBy()) .append("updateTime", getUpdateTime()) + .append("inventoryCheckDetails",getInventoryCheckDetails()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java index 178ce8fa..577b2497 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/IWarehouseInventoryCheckService.java @@ -2,6 +2,7 @@ package com.ruoyi.warehouse.service; import java.util.List; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; +import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; /** * 仓库库存盘点Service接口 @@ -43,4 +44,10 @@ public interface IWarehouseInventoryCheckService */ public int updateWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck); + + /** + * 查找与库存查询有关的物料信息 + * */ + public List selectAllMaterialInfo(); + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java index 642fea59..13214bc9 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseInventoryCheckServiceImpl.java @@ -2,6 +2,8 @@ package com.ruoyi.warehouse.service.impl; import java.text.DecimalFormat; import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -9,12 +11,18 @@ import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.erp.domain.ErpMaterialVo; +import com.ruoyi.erp.mapper.ErpMaterialMapper; +import com.ruoyi.warehouse.domain.VO.WarehouseMaterialVO; +import com.ruoyi.warehouse.domain.WarehouseInventoryCheckDetail; +import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckDetailMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.warehouse.mapper.WarehouseInventoryCheckMapper; import com.ruoyi.warehouse.domain.WarehouseInventoryCheck; import com.ruoyi.warehouse.service.IWarehouseInventoryCheckService; -import com.ruoyi.common.core.text.Convert; +import org.springframework.transaction.annotation.Transactional; /** * 仓库库存盘点Service业务层处理 @@ -22,12 +30,19 @@ import com.ruoyi.common.core.text.Convert; * @author 刘晓旭 * @date 2024-06-07 */ +@Slf4j @Service public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCheckService { @Autowired private WarehouseInventoryCheckMapper warehouseInventoryCheckMapper; + @Autowired + private ErpMaterialMapper erpMaterialMapper; + + @Autowired + private WarehouseInventoryCheckDetailMapper inventoryCheckDetailMapper; + /** * 查询仓库库存盘点 * @@ -58,20 +73,42 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh * @param warehouseInventoryCheck 仓库库存盘点 * @return 结果 */ + @Transactional @Override public int insertWarehouseInventoryCheck(WarehouseInventoryCheck warehouseInventoryCheck) { + String loginName = ShiroUtils.getLoginName(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); String prefix = "KCPD" + simpleDateFormat.format(new Date()).replace("-", ""); String maxCode = warehouseInventoryCheckMapper.findMaxRoundCode(prefix); String newCode = generateCode(prefix,maxCode); - warehouseInventoryCheck.setInventoryCheckCode(newCode); warehouseInventoryCheck.setCreateTime(DateUtils.getNowDate()); - String loginName = ShiroUtils.getLoginName(); warehouseInventoryCheck.setCreateBy(loginName); + List inventoryCheckDetails = warehouseInventoryCheck.getInventoryCheckDetails(); + + if (StringUtils.isEmpty(inventoryCheckDetails)){ + log.warn("仓库盘点物料相关信息为空:{}",inventoryCheckDetails); + } + + for (WarehouseInventoryCheckDetail tempInventoryCheckDetail : inventoryCheckDetails) { + WarehouseInventoryCheckDetail inventoryCheckDetail = new WarehouseInventoryCheckDetail(); + inventoryCheckDetail.setInventoryCheckCode(newCode); + inventoryCheckDetail.setMaterialNo(tempInventoryCheckDetail.getMaterialNo()); + inventoryCheckDetail.setMaterialName(tempInventoryCheckDetail.getMaterialName()); + inventoryCheckDetail.setMaterialDescribe(tempInventoryCheckDetail.getMaterialDescribe()); + inventoryCheckDetail.setMaterialUnit(tempInventoryCheckDetail.getMaterialUnit()); + inventoryCheckDetail.setInventoryCheckNum(tempInventoryCheckDetail.getInventoryCheckNum()); + inventoryCheckDetail.setInventoryAccountNum(tempInventoryCheckDetail.getInventoryAccountNum()); + inventoryCheckDetail.setRemark(tempInventoryCheckDetail.getRemark()); + inventoryCheckDetail.setWarehouseStoreAddress(tempInventoryCheckDetail.getWarehouseStoreAddress()); + inventoryCheckDetail.setCreateBy(loginName); + inventoryCheckDetail.setCreateTime(new Date()); + inventoryCheckDetailMapper.insertWarehouseInventoryCheckDetail(inventoryCheckDetail); + } + return warehouseInventoryCheckMapper.insertWarehouseInventoryCheck(warehouseInventoryCheck); } @@ -90,6 +127,25 @@ public class WarehouseInventoryCheckServiceImpl implements IWarehouseInventoryCh return warehouseInventoryCheckMapper.updateWarehouseInventoryCheck(warehouseInventoryCheck); } + /** + * 查找与库存查询有关的物料信息 + * */ + @Override + public List selectAllMaterialInfo() { + + List warehouseMaterialVOs = new ArrayList<>(); + List erpMaterialVos = erpMaterialMapper.selectAllErpMaterialList(); + for (ErpMaterialVo erpMaterialVo : erpMaterialVos) { + WarehouseMaterialVO warehouseMaterialVO = new WarehouseMaterialVO(); + warehouseMaterialVO.setMaterialNo(erpMaterialVo.getMaterialNo()); + warehouseMaterialVO.setMaterialName(erpMaterialVo.getMaterialName()); + warehouseMaterialVO.setMaterialDescribe(erpMaterialVo.getDescribe()); + warehouseMaterialVO.setMaterialUnit(erpMaterialVo.getUnit()); + warehouseMaterialVOs.add(warehouseMaterialVO); + } + return warehouseMaterialVOs; + } + /** *库存盘点单号生成规则 diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html index bdde0e9f..0cbad494 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html @@ -41,26 +41,203 @@ + + +
+
+
+ 选择物料 + + 选择物料 + +
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html index 505b0630..81a5be0e 100644 --- a/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html +++ b/ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html @@ -49,12 +49,6 @@ 添加 - - 修改 - - - 删除 - 导出 @@ -67,9 +61,6 @@ + + \ No newline at end of file