|
@@ -0,0 +1,90 @@
|
|
|
+package com.sd.business.service.in.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.sd.business.entity.in.dto.InOutStorageDto;
|
|
|
+import com.sd.business.entity.in.dto.InOutStorageSelectDto;
|
|
|
+import com.sd.business.entity.in.emums.InOutTypeEnum;
|
|
|
+import com.sd.business.entity.in.po.InOutStorage;
|
|
|
+import com.sd.business.entity.in.po.InOutStorageBom;
|
|
|
+import com.sd.business.entity.in.vo.InOutStorageVo;
|
|
|
+import com.sd.business.entity.warehouse.po.Warehouse;
|
|
|
+import com.sd.business.mapper.in.InOutStorageMapper;
|
|
|
+import com.sd.business.service.in.InOutStorageBomService;
|
|
|
+import com.sd.business.service.in.InOutStorageService;
|
|
|
+import com.sd.business.util.CodeEnum;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 出入库 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2023-07-03
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class InOutStorageServiceImpl extends ServiceImpl<InOutStorageMapper, InOutStorage> implements InOutStorageService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private InOutStorageBomService inOutStorageBomService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<InOutStorageVo> getPage(InOutStorageSelectDto dto) {
|
|
|
+ IWrapper<InOutStorage> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("ios", InOutStorage::getId);
|
|
|
+ wrapper.eq("ios", InOutStorage::getType, dto.getType());
|
|
|
+ wrapper.like("ios", InOutStorage::getCode, dto.getCode());
|
|
|
+ wrapper.eq("ios", InOutStorage::getDepartmentId, dto.getDepartmentId());
|
|
|
+ wrapper.like("w", Warehouse::getName, dto.getWarehouseName());
|
|
|
+ wrapper.eq("ios", InOutStorage::getDetailType, dto.getDetailType());
|
|
|
+ wrapper.ge("ios", InOutStorage::getCreateTime, dto.getBeginTime());
|
|
|
+ wrapper.le("ios", InOutStorage::getCreateTime, dto.getEndTime());
|
|
|
+
|
|
|
+ Page<InOutStorageVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InOutStorageVo detail(Long id) {
|
|
|
+ InOutStorage InOutStorage = this.getById(id);
|
|
|
+ InOutStorageVo result = BeanUtil.toBean(InOutStorage, InOutStorageVo.class);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void add(InOutStorageDto inOutStorageDto) {
|
|
|
+
|
|
|
+ InOutTypeEnum inOutType = InOutTypeEnum.getInOutType(inOutStorageDto.getType());
|
|
|
+ if (inOutType.equals(InOutTypeEnum.IN)) {
|
|
|
+ inOutStorageDto.setCode(CodeEnum.IN_CODE.getCode());
|
|
|
+ } else {
|
|
|
+ inOutStorageDto.setCode(CodeEnum.OUT_CODE.getCode());
|
|
|
+ }
|
|
|
+ this.save(inOutStorageDto);
|
|
|
+
|
|
|
+ List<InOutStorageBom> inOutStorageBomList = inOutStorageDto.getInOutStorageBomList();
|
|
|
+ inOutStorageBomList.forEach(item -> item.setInOutStorageId(inOutStorageDto.getId()));
|
|
|
+ inOutStorageBomService.saveBatch(inOutStorageBomList);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void edit(InOutStorageDto inOutStorageDto) {
|
|
|
+ this.updateById(inOutStorageDto);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void delete(Long id) {
|
|
|
+ this.removeById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|