diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 50fc93eb..5c2ea0e2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -214,15 +214,13 @@ public class PurchaseOrderController extends BaseController /** * 新增采购入库通知单 */ - @RequiresPermissions("purchase:purchaseOrder:addPurchaseOrderStorage") + @RequiresPermissions("purchase:purchaseOrder:addPurchaseStorage") @Log(title = "采购订单", businessType = BusinessType.INSERT) - @PostMapping("/addPurchaseOrderStorageSave") + @PostMapping("/addPurchaseStorage") @ResponseBody - public AjaxResult addPurchaseOrderStorageSave(@RequestBody WarehouseStorageOrder warehouseStorageOrder) { - // 数据校验,确保前端传入数据格式正确 - // 生成采购订单编号 - // 执行主表插入操作 - return toAjax(purchaseOrderService.addPurchaseOrderStorage(warehouseStorageOrder)); // 假设toAjax方法处理成功逻辑 + public AjaxResult addPurchaseStorageSave(@RequestBody PurchaseOrder purchaseOrder) { + + return toAjax(purchaseOrderService.addPurchaseStorageSave(purchaseOrder)); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java index 55ddc6e9..fb1e7667 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/domain/PurchaseOrder.java @@ -31,8 +31,8 @@ public class PurchaseOrder extends BaseEntity @Excel(name = "采购计划单号") private String purchasePlanCode; - /** 采购入库状态(0待采购、1采购中、2待暂收、3部分暂收、4全部暂收、5已暂收、6待入库、7部分入库、8全部入库、9已入库) */ - @Excel(name = "采购入库状态",dictType = "eceiptStatus") + /** 入库状态(0待暂收、1已暂收、2待入库、3部分入库、4全部入库) */ + @Excel(name = "采购入库状态",dictType = "warehouse_storage_status") private String warehouseStorageStatus; /** 打款结案状态(0待打款、1部分打款、2全部打款、3部分结案、4已结案) */ @@ -67,6 +67,11 @@ public class PurchaseOrder extends BaseEntity @Excel(name = "入库数") private Integer storageSum; + /** 通知已到货总数 */ + @Excel(name = "通知已到货总数") + private Integer notifyHasArrivedSum; + + /** 不含税总价(RMB) */ @Excel(name = "不含税总价(RMB)") private BigDecimal noRmbSum; @@ -249,6 +254,14 @@ public class PurchaseOrder extends BaseEntity return noRmbSum; } + public Integer getNotifyHasArrivedSum() { + return notifyHasArrivedSum; + } + + public void setNotifyHasArrivedSum(Integer notifyHasArrivedSum) { + this.notifyHasArrivedSum = notifyHasArrivedSum; + } + public void setNoRmbSum(BigDecimal noRmbSum) { this.noRmbSum = noRmbSum; } @@ -457,6 +470,7 @@ public class PurchaseOrder extends BaseEntity .append("sharedInventoryOccupancySum", getSharedInventoryOccupancySum()) .append("refundsExchangesSum", getRefundsExchangesSum()) .append("storageSum", getStorageSum()) + .append("notifyHasArrivedSum", getNotifyHasArrivedSum()) .append("noRmbSum", getNoRmbSum()) .append("rmbSum", getRmbSum()) .append("eceiptType", getEceiptType()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseStorageChildMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseStorageChildMapper.java index 9dcd401f..346edf6b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseStorageChildMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/mapper/PurchaseStorageChildMapper.java @@ -74,4 +74,9 @@ public interface PurchaseStorageChildMapper * @return 结果 */ public int restorePurchaseStorageChildById(Long purchaseStorageChildId); + + /** + * 批量新增采购入库单子表 + * */ + int insertBatchPurchaseStorageChild(List purchaseStorageChildren); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java index 40052372..06bff188 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/IPurchaseOrderService.java @@ -122,4 +122,9 @@ public interface IPurchaseOrderService AjaxResult uploadSingleFile(MultipartFile file,String purchaseOrderCode); + /** + * 创建采购入库单 + * */ + + int addPurchaseStorageSave(PurchaseOrder purchaseOrder); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java index 69273fba..1a424d63 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java @@ -31,10 +31,7 @@ import com.ruoyi.process.general.service.IProcessService; import com.ruoyi.process.todoitem.mapper.BizTodoItemMapper; import com.ruoyi.purchase.domain.*; import com.ruoyi.purchase.domain.Vo.*; -import com.ruoyi.purchase.mapper.PurchaseOrderChildMapper; -import com.ruoyi.purchase.mapper.PurchaseOrderMapper; -import com.ruoyi.purchase.mapper.PurchasePlanChildMapper; -import com.ruoyi.purchase.mapper.PurchasePlanMapper; +import com.ruoyi.purchase.mapper.*; import com.ruoyi.purchase.service.IPurchaseOrderService; import com.ruoyi.system.domain.SysAttachFile; import com.ruoyi.system.domain.SysCompanyInformation; @@ -97,12 +94,23 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService @Autowired private PurchasePlanMapper purchasePlanMapper; + + @Autowired + private PurchaseStorageMapper purchaseStorageMapper; + + + @Autowired + private PurchaseStorageChildMapper purchaseStorageChildMapper; + @Autowired private RedisCache redisCache; @Autowired private WarehouseStorageOrderMapper warehouseStorageOrderMapper; + @Autowired + private WarehouseStorageOrderDetailMapper warehouseStorageOrderDetailMapper; + @Autowired private WarehouseStorageOrderDetailMapper storageOrderDetailMapper; @@ -1156,6 +1164,243 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService } + /** + * 创建采购入库单 + * */ + @Transactional(rollbackFor = Exception.class) + @Override + public int addPurchaseStorageSave(PurchaseOrder purchaseOrder) { + Long purchaseOrderId = purchaseOrder.getPurchaseOrderId(); + + List purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); + + + //过滤掉通知已到货数为空的数据 + purchaseOrderChildList = purchaseOrderChildList.stream().filter(item -> item.getNotifyArriveNum() != null).collect(Collectors.toList()); + + boolean allNotifyArriveNum = purchaseOrderChildList.stream().allMatch(item -> item.getNotifyArriveNum() == 0); + if (allNotifyArriveNum){ + throw new BusinessException("通知到货数不能都为0"); + } + + + //过滤掉通知到货数为0的数据 + List filterPurchaseOrderChildList = purchaseOrderChildList.stream().filter(item -> item.getNotifyArriveNum() != 0).collect(Collectors.toList()); + + + purchaseOrder = purchaseOrderMapper.selectPurchaseOrderById(purchaseOrderId); + + + String warehouseStorageCode = redisCache.generateBillNo("RK"); + + + //生成采购入库单子表 + buildPurchaseStorageChild(purchaseOrder, warehouseStorageCode,filterPurchaseOrderChildList); + + //生成采购入库单主表 + buildPurchaseStorage(purchaseOrder, filterPurchaseOrderChildList, warehouseStorageCode); + + //生成仓库入库单 + buildWarehouseStorage(purchaseOrder, warehouseStorageCode,filterPurchaseOrderChildList); + + //生成仓库入库单子表 + buildWarehouseChild(purchaseOrder, warehouseStorageCode,filterPurchaseOrderChildList); + + //更新采购订单子表 + updatePurchaseOrderChildData(purchaseOrder, filterPurchaseOrderChildList); + + int allNotifyArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyArriveNum).sum(); + int allNotifyHasArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyHasArrivedNum).sum(); + + if (allNotifyHasArrivedNum == 0){ + purchaseOrder.setNotifyHasArrivedSum(allNotifyArrivedNum); + }else { + purchaseOrder.setNotifyHasArrivedSum(allNotifyHasArrivedNum + allNotifyArrivedNum); + } + + if (purchaseOrder.getNotifyHasArrivedSum().equals(purchaseOrder.getActualPurchaseSum())){ + purchaseOrder.setWarehouseStorageStatus("4"); + }if (purchaseOrder.getNotifyHasArrivedSum() < purchaseOrder.getActualPurchaseSum()){ + purchaseOrder.setWarehouseStorageStatus("3"); + } + + return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); + } + + //采购入库更新采购订单子表的数据 + private void updatePurchaseOrderChildData(PurchaseOrder purchaseOrder, List filterPurchaseOrderChildList) { + + for (PurchaseOrderChild purchaseOrderChild : filterPurchaseOrderChildList) { + if (purchaseOrderChild.getNotifyHasArrivedNum() == 0 || purchaseOrderChild.getNotifyHasArrivedNum() == null){ + purchaseOrderChild.setNotifyHasArrivedNum(purchaseOrderChild.getNotifyArriveNum()); + }else { + purchaseOrderChild.setNotifyHasArrivedNum(purchaseOrderChild.getNotifyHasArrivedNum() + purchaseOrderChild.getNotifyArriveNum()); + } + int updatePurchaseOrderChild = purchaseOrderChildMapper.updatePurchaseOrderChild(purchaseOrderChild); + if (updatePurchaseOrderChild <= 0){ + throw new BusinessException("更新采购订单子表数据失败"); + } + } + } + + + //采购入库生成采购入库单主表 + private void buildPurchaseStorage(PurchaseOrder purchaseOrder, List filterPurchaseOrderChildList, String warehouseStorageCode) { + PurchaseStorage purchaseStorage = new PurchaseStorage(); + + PurchaseOrderChild purchaseOrderChild = filterPurchaseOrderChildList.get(0); + purchaseStorage.setWarehouseStorageStatus("0"); + purchaseStorage.setWarehouseStorageType("5"); + purchaseStorage.setWarehouseDeptType(purchaseOrderChild.getWarehouseDept()); + purchaseStorage.setWarehouseQualityStatus("0"); + purchaseStorage.setWarehouseOrderType("0"); + + + purchaseStorage.setArrivedTime(purchaseOrder.getArrivedTime()); + purchaseStorage.setRelatedOrderCode(purchaseOrder.getPurchaseOrderCode()); + purchaseStorage.setSupplierCode(purchaseOrder.getSupplierCode()); + purchaseStorage.setSupplierName(purchaseOrder.getSupplierName()); + purchaseStorage.setWarehouseStorageCode(warehouseStorageCode); + + int allNotifyArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyArriveNum).sum(); + int allNotifyHasArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyHasArrivedNum).sum(); + + if (allNotifyHasArrivedNum == 0){ + purchaseStorage.setNotifyArrivedSum(allNotifyArrivedNum); + }else { + purchaseStorage.setNotifyArrivedSum(allNotifyHasArrivedNum + allNotifyArrivedNum); + } + purchaseStorage.setActualArrivedSum(allNotifyArrivedNum); + int insertResult = purchaseStorageMapper.insertPurchaseStorage(purchaseStorage); + if (insertResult <= 0){ + throw new BusinessException("生成采购入库单数据失败"); + } + + } + + //采购入库生成仓库入库主表数据 + private void buildWarehouseStorage(PurchaseOrder purchaseOrder, String warehouseStorageCode, List filterPurchaseOrderChildList) { + + PurchaseOrderChild purchaseOrderChild = filterPurchaseOrderChildList.get(0); + WarehouseStorageOrder warehouseStorageOrder = new WarehouseStorageOrder(); + warehouseStorageOrder.setWarehouseStorageCode(warehouseStorageCode); + warehouseStorageOrder.setWarehouseStorageStatus("0"); + warehouseStorageOrder.setWarehouseStorageType("5"); + warehouseStorageOrder.setWarehouseDeptType(purchaseOrderChild.getWarehouseDept()); + warehouseStorageOrder.setWarehouseQualityStatus("0"); + warehouseStorageOrder.setWarehouseOrderType("0"); + int allNotifyArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyArriveNum).sum(); + int allNotifyHasArrivedNum = filterPurchaseOrderChildList.stream().mapToInt(PurchaseOrderChild::getNotifyHasArrivedNum).sum(); + if (allNotifyHasArrivedNum == 0){ + warehouseStorageOrder.setNotifyArrivedNum(allNotifyArrivedNum); + }else { + warehouseStorageOrder.setNotifyArrivedNum(allNotifyHasArrivedNum + allNotifyArrivedNum); + } + warehouseStorageOrder.setActualArrivedNum(allNotifyArrivedNum); + warehouseStorageOrder.setArrivedTime(purchaseOrder.getArrivedTime()); + warehouseStorageOrder.setRelatedOrderCode(purchaseOrder.getPurchaseOrderCode()); + warehouseStorageOrder.setCreateTime(new Date()); + warehouseStorageOrder.setCreateBy(ShiroUtils.getLoginName()); + + int insertResult = warehouseStorageOrderMapper.insertWarehouseStorageOrder(warehouseStorageOrder); + if (insertResult <= 0){ + throw new BusinessException("生成仓库入库单数据失败"); + } + + } + + //采购入库生成仓库入库子表数据 + private void buildWarehouseChild(PurchaseOrder purchaseOrder, String warehouseStorageCode, List filterPurchaseOrderChildList) { + + String purchaseOrderCode = purchaseOrder.getPurchaseOrderCode(); + List warehouseStorageOrderDetailChildren = new ArrayList<>(); + for (PurchaseOrderChild purchaseOrderChild : filterPurchaseOrderChildList) { + WarehouseStorageOrderDetail warehouseStorageOrderDetail = new WarehouseStorageOrderDetail(); + warehouseStorageOrderDetail.setWarehouseStorageCode(warehouseStorageCode); + warehouseStorageOrderDetail.setRelatedOrderCode(purchaseOrderCode); + warehouseStorageOrderDetail.setMaterialNo(purchaseOrderChild.getMaterialNo()); + warehouseStorageOrderDetail.setMaterialName(purchaseOrderChild.getMaterialName()); + warehouseStorageOrderDetail.setMaterialPhotourl(purchaseOrderChild.getMaterialPhotourl()); + warehouseStorageOrderDetail.setMaterialBrand(purchaseOrderChild.getMaterialBrand()); + warehouseStorageOrderDetail.setMaterialDescribe(purchaseOrderChild.getMaterialDescribe()); + warehouseStorageOrderDetail.setMaterialModel(purchaseOrderChild.getMaterialModel()); + warehouseStorageOrderDetail.setMaterialProcessMethod(purchaseOrderChild.getMaterialProcessMethod()); + warehouseStorageOrderDetail.setMaterialUnit(purchaseOrderChild.getMaterialUnit()); + warehouseStorageOrderDetail.setMaterialPhotourl(purchaseOrderChild.getMaterialPhotourl()); + warehouseStorageOrderDetail.setMaterialType(purchaseOrderChild.getMaterialType()); + warehouseStorageOrderDetail.setMaterialDeptType(purchaseOrderChild.getWarehouseDept()); + warehouseStorageOrderDetail.setArrivedTime(purchaseOrderChild.getPlanDeliveryTime()); + warehouseStorageOrderDetail.setCreateTime(new Date()); + warehouseStorageOrderDetail.setCreateBy(ShiroUtils.getLoginName()); + Integer notifyArriveNum = purchaseOrderChild.getNotifyArriveNum(); + Integer notifyHasArrivedNum = purchaseOrderChild.getNotifyHasArrivedNum(); + + //通知到货数<= 实际采购数 + if (notifyArriveNum > purchaseOrderChild.getActualPurchaseNum()){ + throw new BusinessException("通知到货数不能大于实际采购数"); + } + + if (notifyHasArrivedNum == null){ + warehouseStorageOrderDetail.setNotifyHasArrivedNum(notifyArriveNum); + }else { + warehouseStorageOrderDetail.setNotifyHasArrivedNum(notifyHasArrivedNum + notifyArriveNum); + } + warehouseStorageOrderDetail.setActualArriveNum(notifyArriveNum); + warehouseStorageOrderDetailChildren.add(warehouseStorageOrderDetail); + } + int result = warehouseStorageOrderDetailMapper.insertBatchWarehouseStorageOrderDetail(warehouseStorageOrderDetailChildren); + if (result <= 0){ + throw new RuntimeException("生成仓库入库子表数据失败"); + } + } + + + + + //采购入库生成采购入库子表数据 + private void buildPurchaseStorageChild(PurchaseOrder purchaseOrder, String warehouseStorageCode, List purchaseOrderChildList) { + String purchaseOrderCode = purchaseOrder.getPurchaseOrderCode(); + List purchaseStorageChildren = new ArrayList<>(); + for (PurchaseOrderChild purchaseOrderChild : purchaseOrderChildList) { + PurchaseStorageChild purchaseStorageChild = new PurchaseStorageChild(); + purchaseStorageChild.setWarehouseStorageCode(warehouseStorageCode); + purchaseStorageChild.setRelatedOrderCode(purchaseOrderCode); + purchaseStorageChild.setMaterialNo(purchaseOrderChild.getMaterialNo()); + purchaseStorageChild.setMaterialName(purchaseOrderChild.getMaterialName()); + purchaseStorageChild.setMaterialBrand(purchaseOrderChild.getMaterialBrand()); + purchaseStorageChild.setMaterialDescribe(purchaseOrderChild.getMaterialDescribe()); + purchaseStorageChild.setMaterialPhotourl(purchaseOrderChild.getMaterialPhotourl()); + purchaseStorageChild.setMaterialModel(purchaseOrderChild.getMaterialModel()); + purchaseStorageChild.setMaterialProcessMethod(purchaseOrderChild.getMaterialProcessMethod()); + purchaseStorageChild.setMaterialUnit(purchaseOrderChild.getMaterialUnit()); + purchaseStorageChild.setMaterialPhotourl(purchaseOrderChild.getMaterialPhotourl()); + purchaseStorageChild.setMaterialType(purchaseOrderChild.getMaterialType()); + purchaseStorageChild.setMaterialDeptType(purchaseOrderChild.getWarehouseDept()); + purchaseStorageChild.setArrivedTime(purchaseOrderChild.getPlanDeliveryTime()); + purchaseStorageChild.setCreateTime(new Date()); + purchaseStorageChild.setCreateBy(ShiroUtils.getLoginName()); + Integer notifyArriveNum = purchaseOrderChild.getNotifyArriveNum(); + Integer notifyHasArrivedNum = purchaseOrderChild.getNotifyHasArrivedNum(); + + //通知到货数<= 实际采购数 + if (notifyArriveNum > purchaseOrderChild.getActualPurchaseNum()){ + throw new BusinessException("通知到货数不能大于实际采购数"); + } + + if (notifyHasArrivedNum == null){ + purchaseStorageChild.setNotifyHasArrivedNum(notifyArriveNum); + }else { + purchaseStorageChild.setNotifyHasArrivedNum(notifyHasArrivedNum + notifyArriveNum); + } + purchaseStorageChild.setActualArriveNum(notifyArriveNum); + purchaseStorageChildren.add(purchaseStorageChild); + } + int result = purchaseStorageChildMapper.insertBatchPurchaseStorageChild(purchaseStorageChildren); + if (result <= 0){ + throw new RuntimeException("生成采购入库子表数据失败"); + } + } + /** * 启动流程实例 * */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java index 1c10a17f..659e1ddc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrder.java @@ -28,27 +28,28 @@ public class WarehouseStorageOrder extends BaseEntity private String warehouseStorageCode; /** 关联订单号(多种订单类型) */ - @Excel(name = "关联订单号", readConverterExp = "多=种订单类型") + @Excel(name = "关联订单号") private String relatedOrderCode; - /** 仓库入库状态 */ - @Excel(name = "仓库入库状态") + /** 仓库入库状态(0待暂收、1已暂收、2待入库、3部分入库、4全部入库) */ + @Excel(name = "仓库入库状态",dictType = "warehouse_storage_status") private String warehouseStorageStatus; - /** 仓库品质状态 */ - @Excel(name = "仓库品质状态") + /** 品质状态(0待品质、1部分品质、2全部品质) */ + @Excel(name = "品质状态",dictType = "warehouse_quality_status") private String warehouseQualityStatus; - /** 仓库入库类型 */ - @Excel(name = "仓库入库类型") + + /** 入库类型(0采购入库、1供应商补货、2委内入库、3公司退货、4委外入库、5生产入库) */ + @Excel(name = "入库类型",dictType ="warehouse_storage_type" ) private String warehouseStorageType; - /** 仓库订单类型 */ - @Excel(name = "仓库订单类型") + /** 订单类型(0采购订单、1生产订单、2退换货订单、3委外订单) */ + @Excel(name = "订单类型",dictType = "storage_order_type") private String warehouseOrderType; - /** 仓库入库部门类型 */ - @Excel(name = "仓库入库部门类型") + /** 入库部门类型(0仓库,1采购 ) */ + @Excel(name = "入库部门类型",dictType = "warehouse_dept_type") private String warehouseDeptType; /** 通知已到货数量 */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java index 0d536378..ea163c81 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/domain/WarehouseStorageOrderDetail.java @@ -105,6 +105,10 @@ public class WarehouseStorageOrderDetail extends BaseEntity @Excel(name = "物料图片地址") private String materialPhotourl; + /** 物料型号*/ + @Excel(name = "物料型号") + private String materialModel; + /** 物料品牌 */ @Excel(name = "物料品牌") private String materialBrand; @@ -445,7 +449,16 @@ public class WarehouseStorageOrderDetail extends BaseEntity { return materialBrand; } - public void setMaterialUnit(String materialUnit) + + public String getMaterialModel() { + return materialModel; + } + + public void setMaterialModel(String materialModel) { + this.materialModel = materialModel; + } + + public void setMaterialUnit(String materialUnit) { this.materialUnit = materialUnit; } @@ -745,6 +758,7 @@ public class WarehouseStorageOrderDetail extends BaseEntity .append("materialType", getMaterialType()) .append("materialPhotourl", getMaterialPhotourl()) .append("materialBrand", getMaterialBrand()) + .append("materialModel", getMaterialModel()) .append("materialUnit", getMaterialUnit()) .append("materialDescribe", getMaterialDescribe()) .append("materialProcessMethod", getMaterialProcessMethod()) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseStorageOrderDetailMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseStorageOrderDetailMapper.java index 4ccba705..4f6b55aa 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseStorageOrderDetailMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/mapper/WarehouseStorageOrderDetailMapper.java @@ -114,4 +114,9 @@ public interface WarehouseStorageOrderDetailMapper * */ int updateWarehouseStorageOrderDetailByCode(WarehouseStorageOrderDetail storageOrderDetail); + /** + * 批量插入仓库入库详情数据 + * */ + int insertBatchWarehouseStorageOrderDetail(List warehouseStorageOrderDetailChildren); + } diff --git a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml index b1fe8d8d..22d39026 100644 --- a/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/purchase/PurchaseOrderMapper.xml @@ -17,6 +17,7 @@ + @@ -45,7 +46,7 @@ - select purchase_order_id, purchase_order_code, purchase_plan_code, warehouse_storage_status, payment_status, supplier_code, supplier_name, material_sum, actual_purchase_sum, shared_inventory_occupancy_sum, refunds_exchanges_sum, storage_sum, noRmb_sum, rmb_sum, eceipt_type, arrived_time, stock_no, stock_name, receive_person, receive_person_phone, receive_address, purchase_buyer, use_status, audit_status, create_by, create_time, update_by, update_time, del_flag, instance_id, instance_type, submit_instance_id, cancel_instance_id, restore_instance_id, apply_title, apply_user, apply_time from purchase_order + select purchase_order_id, purchase_order_code, purchase_plan_code, warehouse_storage_status, payment_status, supplier_code, supplier_name, material_sum, actual_purchase_sum, shared_inventory_occupancy_sum, refunds_exchanges_sum, storage_sum, notify_has_arrived_sum,noRmb_sum, rmb_sum, eceipt_type, arrived_time, stock_no, stock_name, receive_person, receive_person_phone, receive_address, purchase_buyer, use_status, audit_status, create_by, create_time, update_by, update_time, del_flag, instance_id, instance_type, submit_instance_id, cancel_instance_id, restore_instance_id, apply_title, apply_user, apply_time from purchase_order +
@@ -69,6 +70,76 @@ $("#form-addPurchaseStorage-edit").validate({ focusCleanup: true}); + + + function submitHandler() { + // 获取表单数据 + const purchaseStorageData = $("#form-addPurchaseStorage-edit").serializeArray().reduce((obj, item) => { + obj[item.name] = item.value; + return obj; + }, {}); + + + var table = $('#bootstrap-table').bootstrapTable("getSelections"); + + + if (table.length === 0){ + $.modal.alertWarning("请至少选择一条要入库的物料"); + return; + } + + // 检查是否有同时存在 warehouseDept 为 1 和 0 的记录 + var hasWarehouseDept1 = false; + var hasWarehouseDept0 = false; + for (var i = 0; i < table.length; i++) { + var warehouseDept = table[i].warehouseDept; + if (warehouseDept === "1") { + hasWarehouseDept1 = true; + } else if (warehouseDept === "0") { + hasWarehouseDept0 = true; + } + } + + if (hasWarehouseDept1 && hasWarehouseDept0) { + $.modal.alertWarning("入库物料中同时包含仓库入库和采购入库,需要分开入库"); + return; + } + + var materialDataList = table.map(function(item) { + // 根据实际字段名调整 + return { + "purchaseOrderChildId":item.purchaseOrderChildId, + "materialNo": item.materialNo, + "materialName": item.materialName, + "materialPhotourl" : item.materialPhotourl, + "materialType": item.materialType, + "materialDescribe": item.materialDescribe, + "materialBrand": item.materialBrand, + "materialUnit": item.materialUnit, + "materialProcessMethod": item.materialProcessMethod, + "warehouseDept": item.warehouseDept, + "planPurchaseNum": item.planPurchaseNum, + "actualPurchaseNum": item.actualPurchaseNum, + "planDeliveryTime": item.planDeliveryTime, + "notifyHasArrivedNum": item.notifyHasArrivedNum, + "temporaryNum": item.temporaryNum, + "hasStorageNum": item.hasStorageNum, + "notifyArriveNum": item.notifyArriveNum, + }; + }); + + const combinedData = Object.assign({}, purchaseStorageData, { + purchaseOrderChildList: materialDataList, + }); + // 合并表单数据和表格数据 + console.log(combinedData) + // 使用 JSON.stringify() 序列化数据 + const jsonData = JSON.stringify(combinedData); + // 发送 AJAX 请求到后端接口 + $.operate.saveJson(prefix + "/addPurchaseStorage", jsonData); + } + + //物料信息展示列表 $(function() { var options = { @@ -83,7 +154,11 @@ columns: [{ checkbox: true }, - + { + field: 'purchaseOrderChildId', + title: '主键', + visible: false + }, { title: '料号', field: 'materialNo', @@ -92,6 +167,11 @@ title: '物料名称', field: 'materialName', }, + { + title: '图片', + field: 'materialPhotourl', + visible: false + }, { title: '物料类型', field: 'materialType', @@ -127,7 +207,7 @@ }, { title: '物料入库部门', - field: 'materialDeptType', + field: 'warehouseDept', formatter:function (value) { return $.table.selectDictLabel(warehouseDeptDatas, value); } @@ -141,7 +221,51 @@ {title: '已入库数',field: 'hasStorageNum', }, - {title: '通知到货数',field: 'notifyArriveNum' + {title: '通知到货数',field: 'notifyArriveNum', + editable: { + //动态禁用行内编辑 + noEditFormatter: function(value, row, index){ + if (row.temporaryNum === row.actualPurchaseNum || row.actualPurchaseNum === row.notifyHasArrivedNum){ + return "不可入库"; + }else { + return false; + } + }, + validate: function(value) { + if ($.trim(value) === '') { + return '通知到货数不能为空'; + } + if (isNaN(value)) { + return '请输入有效的数字'; + } + if (value < 0) { + return '通知到货数不能小于0'; + } + //不能为小数 + if (value % 1 !== 0) { + return '本次验收数不能为小数'; + } + }, + }, + formatter: function (value, row) { + // 检查 row 是否存在 + if (!row) { + return ""; + } + + // 检查 notifyArriveNum 是否存在 + if (row.notifyArriveNum === undefined || row.notifyArriveNum === null) { + return ""; + } + + // 根据 notifyArriveNum 的值决定返回值 + if (row.notifyArriveNum) { + return row.notifyArriveNum; + } else { + return value; + } + } + } ] }; diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html index 0643b3b2..41d3336a 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseOrder/purchaseOrder.html @@ -20,7 +20,7 @@
  • - @@ -75,7 +75,7 @@ var addPurchaseStorageFlag = [[${@permission.hasPermi('purchase:purchaseOrder:addPurchaseStorage')}]]; - var warehouseStorageStatusDatas = [[${@dict.getType('eceiptStatus')}]]; + var warehouseStorageStatusDatas = [[${@dict.getType('warehouse_storage_status')}]]; var paymentStatusDatas = [[${@dict.getType('sys_pay_close')}]]; var useStatusDatas = [[${@dict.getType('useStatus')}]]; var auditStatusDatas = [[${@dict.getType('auditStatus')}]]; @@ -239,8 +239,12 @@ if(row.auditStatus=="1" && row.useStatus=="1" && !row.cancelInstanceId) { // 作废 actions.push(' 作废'); - //入库通知 - actions.push(' 入库通知'); + + //入库状态(0待暂收、1已暂收、2待入库、3部分入库、4全部入库) + if(row.warehouseStorageStatus=="2" || row.warehouseStorageStatus=="3"){ + //入库通知 + actions.push(' 入库通知'); + } // 已作废 } @@ -344,6 +348,7 @@ //入库通知 function addPurchaseStorage(purchaseOrderId) { + //入库状态(0待暂收、1已暂收、2待入库、3部分入库、4全部入库) var url = prefix + "/addPurchaseStorage/" + purchaseOrderId; $.modal.open("入库通知", url); } diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchaseStorage/purchaseStorage.html b/ruoyi-admin/src/main/resources/templates/purchase/purchaseStorage/purchaseStorage.html index c3580eed..f7a34c29 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchaseStorage/purchaseStorage.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchaseStorage/purchaseStorage.html @@ -1,196 +1,276 @@ - + -
    -
    -
    -
    -
    -
      -
    • - - -
    • -
    • - - -
    • -
    • - - -
    • -
    • - - -
    • - -
    • - - -
    • -
    • - - -
    • -
    • - - - - - -
    • -
    • -  搜索 -  重置 -
    • -
    -
    -
    -
    +
    +
    +
    +
    +
    +
      +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + +
    • +
    • + + + - + +
    • +
    • +  搜索 +  重置 +
    • +
    +
    +
    +
    - -
    -
    -
    + +
    +
    - - + $.table.init(options); + }); + \ No newline at end of file