|
@@ -0,0 +1,112 @@
|
|
|
+package com.fjhx.victoriatourist.service.excess.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.common.utils.Assert;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.dto.ExcessGoodsInfoDto;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.dto.ExcessGoodsInfoSelectDto;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.po.ExcessGoodsDetails;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.po.ExcessGoodsInfo;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.po.ExcessGoodsRegister;
|
|
|
+import com.fjhx.victoriatourist.entity.excess.vo.ExcessGoodsInfoVo;
|
|
|
+import com.fjhx.victoriatourist.entity.logistics.po.LogisticsInfos;
|
|
|
+import com.fjhx.victoriatourist.mapper.excess.ExcessGoodsInfoMapper;
|
|
|
+import com.fjhx.victoriatourist.service.excess.ExcessGoodsDetailsService;
|
|
|
+import com.fjhx.victoriatourist.service.excess.ExcessGoodsInfoService;
|
|
|
+import com.fjhx.victoriatourist.service.excess.ExcessGoodsRegisterService;
|
|
|
+import com.fjhx.victoriatourist.service.logistics.LogisticsInfosService;
|
|
|
+import com.fjhx.wms.entity.stock.po.StockWait;
|
|
|
+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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 多货登记 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2024-03-27
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class ExcessGoodsInfoServiceImpl extends ServiceImpl<ExcessGoodsInfoMapper, ExcessGoodsInfo> implements ExcessGoodsInfoService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StockWaitService stockWaitService;
|
|
|
+ @Autowired
|
|
|
+ private LogisticsInfosService logisticsInfosService;
|
|
|
+ @Autowired
|
|
|
+ private ExcessGoodsDetailsService excessGoodsDetailsService;
|
|
|
+ @Autowired
|
|
|
+ private ExcessGoodsRegisterService excessGoodsRegisterService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExcessGoodsInfoVo> getList(ExcessGoodsInfoSelectDto dto) {
|
|
|
+ IWrapper<ExcessGoodsInfo> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("egi", ExcessGoodsInfo::getId);
|
|
|
+ List<ExcessGoodsInfoVo> list = this.baseMapper.getList(wrapper);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<ExcessGoodsInfoVo> getPage(ExcessGoodsInfoSelectDto dto) {
|
|
|
+ IWrapper<ExcessGoodsInfo> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("egi", ExcessGoodsInfo::getId);
|
|
|
+ Page<ExcessGoodsInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ExcessGoodsInfoVo detail(Long id) {
|
|
|
+ ExcessGoodsInfo ExcessGoodsInfo = this.getById(id);
|
|
|
+ ExcessGoodsInfoVo result = BeanUtil.toBean(ExcessGoodsInfo, ExcessGoodsInfoVo.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @DSTransactional
|
|
|
+ public synchronized void add(ExcessGoodsInfoDto dto) {
|
|
|
+ Long stockWaitId = dto.getStockWaitId();
|
|
|
+ Assert.notEmpty(stockWaitId, "待入库id不能为空");
|
|
|
+ StockWait stockWait = stockWaitService.getById(stockWaitId);
|
|
|
+ Assert.notEmpty(stockWait, "查询不到待入库信息");
|
|
|
+ LogisticsInfos one = logisticsInfosService.getOne(q -> q.eq(LogisticsInfos::getBusinessId, stockWait.getDeliverGoodsId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(one)) {
|
|
|
+ dto.setLogisticsInfosId(one.getId());
|
|
|
+ }
|
|
|
+ this.save(dto);
|
|
|
+
|
|
|
+ //保存详情信息
|
|
|
+ List<ExcessGoodsDetails> list = excessGoodsDetailsService.list(q -> q.eq(ExcessGoodsDetails::getStockWaitId, stockWaitId));
|
|
|
+ for (ExcessGoodsDetails excessGoodsDetails : list) {
|
|
|
+ List<ExcessGoodsRegister> list1 = excessGoodsRegisterService.list(q -> q.eq(ExcessGoodsRegister::getExcessGoodsDetailsId, excessGoodsDetails.getId()));
|
|
|
+ BigDecimal sumQuantity = list1.stream()
|
|
|
+ .map(ExcessGoodsRegister::getQuantity)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ excessGoodsDetails.setQuantity(sumQuantity);
|
|
|
+ excessGoodsDetails.setExcessGoodsInfoId(dto.getId());
|
|
|
+ }
|
|
|
+ excessGoodsDetailsService.saveOrUpdateBatch(list);
|
|
|
+
|
|
|
+ //删除登记数据
|
|
|
+ excessGoodsRegisterService.remove(q -> q.in(ExcessGoodsRegister::getStockWaitId, stockWaitId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(ExcessGoodsInfoDto excessGoodsInfoDto) {
|
|
|
+ this.updateById(excessGoodsInfoDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|