|
@@ -0,0 +1,77 @@
|
|
|
+package com.sd.business.service.check.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+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.check.dto.CheckDto;
|
|
|
+import com.sd.business.entity.check.dto.CheckSelectDto;
|
|
|
+import com.sd.business.entity.check.po.Check;
|
|
|
+import com.sd.business.entity.check.po.CheckBom;
|
|
|
+import com.sd.business.entity.check.vo.CheckVo;
|
|
|
+import com.sd.business.entity.warehouse.po.Warehouse;
|
|
|
+import com.sd.business.mapper.check.CheckMapper;
|
|
|
+import com.sd.business.service.check.CheckBomService;
|
|
|
+import com.sd.business.service.check.CheckService;
|
|
|
+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 CheckServiceImpl extends ServiceImpl<CheckMapper, Check> implements CheckService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CheckBomService checkBomService;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<CheckVo> getPage(CheckSelectDto dto) {
|
|
|
+ IWrapper<Check> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("c", Check::getId);
|
|
|
+ wrapper.eq("c", Check::getDepartmentId, dto.getDepartmentId());
|
|
|
+ wrapper.like("w", Warehouse::getName, dto.getWarehouseName());
|
|
|
+ wrapper.eq("c", Check::getStatus, dto.getStatus());
|
|
|
+ wrapper.ge("c", Check::getCreateTime, dto.getBeginTime());
|
|
|
+ wrapper.le("c", Check::getCreateTime, dto.getEndTime());
|
|
|
+
|
|
|
+ Page<CheckVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void add(CheckDto checkDto) {
|
|
|
+ long checkId = IdWorker.getId();
|
|
|
+ checkDto.setId(checkId);
|
|
|
+ checkDto.setStatus(0);
|
|
|
+
|
|
|
+ List<CheckBom> checkBomList = checkDto.getCheckBomList();
|
|
|
+ for (CheckBom checkBom : checkBomList) {
|
|
|
+ checkBom.setCheckId(checkId);
|
|
|
+ int compareTo = checkBom.getCheckQuantity().compareTo(checkBom.getSurplusStock());
|
|
|
+ if (compareTo == 0) {
|
|
|
+ checkBom.setStatus(1);
|
|
|
+ } else if (compareTo > 0) {
|
|
|
+ checkBom.setStatus(2);
|
|
|
+ checkDto.setStatus(1);
|
|
|
+ } else {
|
|
|
+ checkBom.setStatus(3);
|
|
|
+ checkDto.setStatus(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ this.save(checkDto);
|
|
|
+ checkBomService.saveBatch(checkBomList);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|