| | |
| | | package com.ruoyi.approve.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.project.system.domain.SysDept; |
| | | import com.ruoyi.project.system.domain.SysNotice; |
| | | import com.ruoyi.project.system.domain.SysUser; |
| | |
| | | import com.ruoyi.purchase.mapper.PurchaseLedgerMapper; |
| | | import com.ruoyi.purchase.pojo.PurchaseLedger; |
| | | import com.ruoyi.sales.mapper.CommonFileMapper; |
| | | import com.ruoyi.sales.mapper.SalesLedgerProductMapper; |
| | | import com.ruoyi.sales.mapper.SalesQuotationMapper; |
| | | import com.ruoyi.sales.mapper.ShippingInfoMapper; |
| | | import com.ruoyi.sales.pojo.CommonFile; |
| | | import com.ruoyi.sales.pojo.SalesLedgerProduct; |
| | | import com.ruoyi.sales.pojo.SalesQuotation; |
| | | import com.ruoyi.sales.pojo.ShippingInfo; |
| | | import com.ruoyi.sales.service.impl.CommonFileServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | |
| | | private final CommonFileServiceImpl commonFileService; |
| | | private final ISysNoticeService sysNoticeService; |
| | | private final PurchaseLedgerMapper purchaseLedgerMapper; |
| | | private final SalesLedgerProductMapper salesLedgerProductMapper; |
| | | private final SalesQuotationMapper salesQuotationMapper; |
| | | private final StockUtils stockUtils; |
| | | private final ShippingInfoMapper shippingInfoMapper; |
| | | private final ApproveNodeMapper approveNodeMapper; |
| | | private final ApproveProcessConfigNodeService approveProcessConfigNodeService; |
| | |
| | | .collect(Collectors.toList()); |
| | | // 无审核人逻辑添加 |
| | | if (CollectionUtils.isEmpty(nodeIds)) { |
| | | autoPassPurchaseApproveIfNoApprover(approveProcessVO); // 采购单无审核人逻辑 |
| | | switch (approveProcessVO.getApproveType()){ |
| | | case 5: |
| | | autoPassPurchaseApproveIfNoApprover(approveProcessVO); // 采购单无审核人逻辑 |
| | | break; |
| | | case 6: |
| | | autoPassSalesApproveIfNoApprover(approveProcessVO); // 销售报价无审核人逻辑 |
| | | break; |
| | | case 7: |
| | | autoShippingApproveIfNoApprover(approveProcessVO); // 销售发货无审核人逻辑 |
| | | break; |
| | | } |
| | | return; |
| | | } |
| | | List<SysUser> sysUsers = sysUserMapper.selectUserByIds(nodeIds); |
| | |
| | | .collect(Collectors.joining(",")); |
| | | approveNodeService.initApproveNodes(nodeIdStr, no, approveProcessVO.getApproveDeptId()); |
| | | // 附件绑定 |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_PROCESS, approveProcess.getId(), approveProcessVO.getStorageBlobDTOList()); |
| | | fileUtil.saveStorageAttachment(ApplicationTypeEnum.FILE, RecordTypeEnum.APPROVE_PROCESS, approveProcess.getId(), approveProcessVO.getStorageBlobDTOS()); |
| | | /*消息通知*/ |
| | | Long id = nodeIds.getFirst(); |
| | | if (approveProcess.getApproveType() == 8) { |
| | |
| | | } |
| | | } |
| | | |
| | | private void autoPassPurchaseApproveIfNoApprover(ApproveProcessVO approveProcessVO) { |
| | | if (!Objects.equals(approveProcessVO.getApproveType(), 5) |
| | | || !StringUtils.hasText(approveProcessVO.getApproveReason())) { |
| | | throw new RuntimeException("审核用户不存在"); |
| | | private void autoPassSalesApproveIfNoApprover(ApproveProcessVO approveProcessVO) { |
| | | if (!StringUtils.hasText(approveProcessVO.getApproveReason())) { |
| | | return; |
| | | } |
| | | salesQuotationMapper.update(null, new LambdaUpdateWrapper<SalesQuotation>() |
| | | .eq(SalesQuotation::getQuotationNo, approveProcessVO.getApproveReason()) |
| | | .set(SalesQuotation::getStatus, "通过")); |
| | | } |
| | | |
| | | private void autoShippingApproveIfNoApprover(ApproveProcessVO approveProcessVO) { |
| | | if (!StringUtils.hasText(approveProcessVO.getApproveReason())) { |
| | | return; |
| | | } |
| | | ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, approveProcessVO.getApproveReason()) |
| | | .last("limit 1")); |
| | | if(shippingInfo == null){ |
| | | return; |
| | | } |
| | | shippingInfoMapper.update(null, new LambdaUpdateWrapper<ShippingInfo>() |
| | | .eq(ShippingInfo::getShippingNo, approveProcessVO.getApproveReason()) |
| | | .set(ShippingInfo::getStatus, "审核通过")); |
| | | //更改出库审核状态(待确认改成待审核) |
| | | stockUtils.shipmentStatus(StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), shippingInfo.getId()); |
| | | } |
| | | |
| | | private void autoPassPurchaseApproveIfNoApprover(ApproveProcessVO approveProcessVO) { |
| | | if (!StringUtils.hasText(approveProcessVO.getApproveReason())) { |
| | | return; |
| | | } |
| | | |
| | | purchaseLedgerMapper.update(null, new LambdaUpdateWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveProcessVO.getApproveReason()) |
| | | .set(PurchaseLedger::getApprovalStatus, 3)); |
| | | //采购入库 |
| | | PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>() |
| | | .eq(PurchaseLedger::getPurchaseContractNumber, approveProcessVO.getApproveReason()) |
| | | .last("limit 1")); |
| | | List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>() |
| | | .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2)); |
| | | for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) { |
| | | stockUtils.addStockWithBatchNo(salesLedgerProduct.getProductModelId(), salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), purchaseLedger.getId(),purchaseLedger.getPurchaseContractNumber()+"-"+salesLedgerProduct.getId()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<SysDept> selectDeptListByDeptIds(Long[] deptIds) { |
| | | List<SysDept> sysDeptList = new ArrayList<SysDept>(); |
| | | for (Long deptId : deptIds) { |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | sysDeptList.add(sysDept); |
| | | } |
| | | return sysDeptList; |
| | | // List<SysDept> sysDeptList = new ArrayList<SysDept>(); |
| | | // for (Long deptId : deptIds) { |
| | | // SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | // sysDeptList.add(sysDept); |
| | | // } |
| | | return sysDeptMapper.selectList(new QueryWrapper<SysDept>()); |
| | | } |
| | | |
| | | @Override |