| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.approve.bean.dto.ApprovalInstanceDto; |
| | | import com.ruoyi.approve.mapper.ApprovalTemplateMapper; |
| | | import com.ruoyi.approve.pojo.ApprovalTemplate; |
| | | import com.ruoyi.approve.pojo.ApproveProcess; |
| | | import com.ruoyi.approve.service.ApprovalInstanceService; |
| | | import com.ruoyi.approve.service.impl.ApproveProcessServiceImpl; |
| | | import com.ruoyi.basic.enums.ApplicationTypeEnum; |
| | | import com.ruoyi.basic.enums.RecordTypeEnum; |
| | | import com.ruoyi.basic.utils.FileUtil; |
| | | import com.ruoyi.common.enums.FileNameType; |
| | | import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum; |
| | | import com.ruoyi.common.utils.OrderUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.security.LoginUser; |
| | | import com.ruoyi.procurementrecord.bean.vo.ShippingProductVo; |
| | | import com.ruoyi.procurementrecord.utils.StockUtils; |
| | | import com.ruoyi.sales.dto.SalesLedgerProductDto; |
| | | import com.ruoyi.sales.dto.ShippingApproveDto; |
| | | import com.ruoyi.sales.dto.ShippingInfoDto; |
| | | import com.ruoyi.sales.dto.ShippingProductDetailDto; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.collections4.CollectionUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | private final ApproveProcessServiceImpl approveProcessService; |
| | | private final FileUtil fileUtil; |
| | | private final ShippingProductDetailMapper shippingProductDetailMapper; |
| | | private final ApprovalTemplateMapper approvalTemplateMapper; |
| | | private final ApprovalInstanceService approvalInstanceService; |
| | | |
| | | @Override |
| | | public IPage<ShippingInfoDto> listPage(Page page, ShippingInfo req) { |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public boolean delete(List<Long> ids) { |
| | | List<ShippingInfo> shippingInfos = shippingInfoMapper.selectList(new LambdaQueryWrapper<ShippingInfo>() |
| | | .in(ShippingInfo::getId, ids)); |
| | | if (CollectionUtils.isEmpty(shippingInfos)) return false; |
| | | // 只有待审核状态才能删除 |
| | | boolean allPending = shippingInfos.stream().allMatch(s -> "待审核".equals(s.getStatus())); |
| | | if (!allPending) throw new RuntimeException("只有待审核状态才能删除"); |
| | | // 删除附件 |
| | | commonFileService.deleteByBusinessIds(ids, FileNameType.SHIP.getValue()); |
| | | // 扣已发货库存 |
| | | for (ShippingInfo shippingInfo : shippingInfos) { |
| | | if ("已发货".equals(shippingInfo.getStatus())) { |
| | | stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode()); |
| | | } |
| | | } |
| | | // 删除发货审批 |
| | | if (CollectionUtils.isNotEmpty(shippingInfos)) { |
| | | for (ShippingInfo shippingInfo : shippingInfos) { |
| | |
| | | List<Long> list = one.stream().map(ApproveProcess::getId).toList(); |
| | | approveProcessService.delByIds(list); |
| | | } |
| | | // 扣已发货库存 |
| | | stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode()); |
| | | } |
| | | } |
| | | //删除发货明细 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<SalesLedgerProductDto> getReturnManagementDtoById(Long shippingId) { |
| | | public List<ShippingProductVo> getReturnManagementDtoById(Long shippingId) { |
| | | return shippingInfoMapper.getReturnManagementDtoById(shippingId); |
| | | |
| | | } |
| | |
| | | shippingApproveDto.setShippingProductDetailDtoList(dateilByShippingNo); |
| | | return shippingApproveDto; |
| | | } |
| | | |
| | | @Override |
| | | public boolean addReq(ShippingInfoDto req) { |
| | | |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | String sh = OrderUtils.countTodayByCreateTime(shippingInfoMapper, "SH","shipping_no"); |
| | | // 先保存发货单,再发起审批;无审核人自动通过时需要按发货编号回写发货状态。 |
| | | req.setShippingNo(sh); |
| | | req.setStatus("待审核"); |
| | | boolean save = this.add(req); |
| | | // 发货审批 |
| | | ApprovalInstanceDto approvalInstance = new ApprovalInstanceDto(); |
| | | approvalInstance.setTemplateId(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,6L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getId()); |
| | | approvalInstance.setTemplateName(approvalTemplateMapper.selectOne(new LambdaQueryWrapper<ApprovalTemplate>().eq(ApprovalTemplate::getBusinessType,6L).orderByDesc(ApprovalTemplate::getId).last("LIMIT 1")).getTemplateName()); |
| | | approvalInstance.setBusinessId(req.getId()); |
| | | approvalInstance.setBusinessType(6L); |
| | | approvalInstance.setCurrentLevel(1); |
| | | approvalInstance.setTitle(sh+"审批"); |
| | | approvalInstance.setApplicantId(loginUser.getUserId()); |
| | | approvalInstance.setApplicantName(loginUser.getNickName()); |
| | | approvalInstance.setApplyTime(LocalDateTime.now()); |
| | | approvalInstanceService.add(approvalInstance); |
| | | return true; |
| | | } |
| | | } |