|
@@ -0,0 +1,104 @@
|
|
|
+package com.fjhx.mes.service.report.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.mes.entity.report.dto.ReportLossesDetailsDto;
|
|
|
+import com.fjhx.mes.entity.report.dto.ReportLossesDetailsSelectDto;
|
|
|
+import com.fjhx.mes.entity.report.po.ReportLossesDetails;
|
|
|
+import com.fjhx.mes.entity.report.vo.ReportLossesDetailsVo;
|
|
|
+import com.fjhx.mes.mapper.report.ReportLossesDetailsMapper;
|
|
|
+import com.fjhx.mes.service.report.ReportLossesDetailsService;
|
|
|
+import com.fjhx.wms.entity.stock.emums.JournalType;
|
|
|
+import com.fjhx.wms.entity.stock.po.StockWait;
|
|
|
+import com.fjhx.wms.entity.stock.po.StockWaitDetails;
|
|
|
+import com.fjhx.wms.service.stock.StockWaitDetailsService;
|
|
|
+import com.fjhx.wms.service.stock.StockWaitService;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 报损管理 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-01-26
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ReportLossesDetailsServiceImpl extends ServiceImpl<ReportLossesDetailsMapper, ReportLossesDetails> implements ReportLossesDetailsService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductInfoService productInfoService;
|
|
|
+ @Autowired
|
|
|
+ private StockWaitService stockWaitService;
|
|
|
+ @Autowired
|
|
|
+ private StockWaitDetailsService stockWaitDetailsService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ReportLossesDetailsVo> getPage(ReportLossesDetailsSelectDto dto) {
|
|
|
+ IWrapper<ReportLossesDetails> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("rld", ReportLossesDetails::getId);
|
|
|
+ Page<ReportLossesDetailsVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+
|
|
|
+ List<ReportLossesDetailsVo> records = page.getRecords();
|
|
|
+ if (ObjectUtil.isEmpty(records)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ //赋值产品信息
|
|
|
+ productInfoService.attributeAssign(records, ReportLossesDetailsVo::getMaterialId, (item, product) -> {
|
|
|
+ item.setMaterialCode(product.getCustomCode());
|
|
|
+ item.setMaterialName(product.getName());
|
|
|
+ });
|
|
|
+
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReportLossesDetailsVo detail(Long id) {
|
|
|
+ ReportLossesDetails ReportLossesDetails = this.getById(id);
|
|
|
+ ReportLossesDetailsVo result = BeanUtil.toBean(ReportLossesDetails, ReportLossesDetailsVo.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void add(ReportLossesDetailsDto dto) {
|
|
|
+ this.save(dto);
|
|
|
+
|
|
|
+ JournalType journalType = Objects.equals(dto.getType(), 1) ? JournalType.REPAIR_EXCEED_OUT : JournalType.LOSE_EXCEED_OUT;
|
|
|
+
|
|
|
+ //生成待出库数据
|
|
|
+ StockWait stockWait = new StockWait();
|
|
|
+ stockWait.setType(2);
|
|
|
+ stockWait.setBusinessType(journalType.getDetailType());
|
|
|
+ stockWait.setBusinessId(dto.getId());
|
|
|
+ stockWait.setStatus(0);
|
|
|
+ stockWaitService.save(stockWait);
|
|
|
+ StockWaitDetails stockWaitDetails = new StockWaitDetails();
|
|
|
+ stockWaitDetails.setStockWaitId(stockWait.getId());
|
|
|
+ stockWaitDetails.setProductId(dto.getMaterialId());
|
|
|
+ stockWaitDetails.setQuantity(dto.getQuantity());
|
|
|
+ stockWaitDetails.setReceiptQuantity(BigDecimal.ZERO);
|
|
|
+ stockWaitDetailsService.save(stockWaitDetails);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(ReportLossesDetailsDto reportLossesDetailsDto) {
|
|
|
+ this.updateById(reportLossesDetailsDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|