|
@@ -1,10 +1,22 @@
|
|
|
package com.yh.saas.plugin.yiliangyiyun.service.impl;
|
|
|
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInventoryCountInfo;
|
|
|
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
+import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.plugins.Page;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.winsea.svc.base.security.util.AuthSecurityUtils;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.WarehouseInventoryCountInfoMapper;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseInOutInfoService;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.service.IWarehouseInventoryCountInfoService;
|
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -17,4 +29,122 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class WarehouseInventoryCountInfoServiceImpl extends ServiceImpl<WarehouseInventoryCountInfoMapper, WarehouseInventoryCountInfo> implements IWarehouseInventoryCountInfoService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IWarehouseInOutInfoService warehouseInOutInfoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询盘损记录
|
|
|
+ *
|
|
|
+ * @param warehouseInventoryCountInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Page<WarehouseInventoryCountInfo> selectInfo(WarehouseInventoryCountInfo warehouseInventoryCountInfo) {
|
|
|
+ Map<String, Object> pageView = new HashMap<>();
|
|
|
+ pageView.put("startRecord", (warehouseInventoryCountInfo.getCurrentPage() - 1)
|
|
|
+ * warehouseInventoryCountInfo.getPageSize());
|
|
|
+ // 仓库ID
|
|
|
+ pageView.put("baseId", warehouseInventoryCountInfo.getBaseId());
|
|
|
+ // 仓位ID
|
|
|
+ pageView.put("positionId", warehouseInventoryCountInfo.getPositionId());
|
|
|
+ pageView.put("pageSize", warehouseInventoryCountInfo.getPageSize());
|
|
|
+ pageView.put("currentPage", warehouseInventoryCountInfo.getCurrentPage());
|
|
|
+ // 查询记录总数
|
|
|
+ Integer dataCount = baseMapper.getCountByCondition(pageView);
|
|
|
+ List<WarehouseInventoryCountInfo> dataList = baseMapper.getListByCondition(pageView);
|
|
|
+ Page<WarehouseInventoryCountInfo> page = new Page<>();
|
|
|
+ page.setRecords(dataList == null ? Lists.newArrayList() : dataList);
|
|
|
+ page.setTotal(dataCount == null ? 0 : dataCount);
|
|
|
+ page.setCurrent(warehouseInventoryCountInfo.getCurrentPage());
|
|
|
+ page.setSize(warehouseInventoryCountInfo.getPageSize());
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 盘损
|
|
|
+ *
|
|
|
+ * @param warehouseInventoryCountInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public WarehouseInventoryCountInfo getInfo(WarehouseInventoryCountInfo warehouseInventoryCountInfo) {
|
|
|
+ WarehouseInventoryCountInfo warehouseInventoryCountInfoCopy = new WarehouseInventoryCountInfo();
|
|
|
+ Wrapper<WarehouseInventoryCountInfo> warehouseInventoryCountInfoWrapper = new EntityWrapper<>();
|
|
|
+ warehouseInventoryCountInfoWrapper.eq("base_id", warehouseInventoryCountInfo.getBaseId())
|
|
|
+ .eq("position_id", warehouseInventoryCountInfo.getPositionId())
|
|
|
+ .eq("goods_name_key",warehouseInventoryCountInfo.getGoodsNameKey())
|
|
|
+ .eq("delete_flag", "0")
|
|
|
+ .orderBy("create_date",false);
|
|
|
+ List<WarehouseInventoryCountInfo> warehouseInventoryCountInfos = this.selectList(warehouseInventoryCountInfoWrapper);
|
|
|
+ // 有盘损记录
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInventoryCountInfos)) {
|
|
|
+ WarehouseInventoryCountInfo warehouseInventoryCountInfo1=warehouseInventoryCountInfos.get(0);
|
|
|
+ //最后一次盘损剩余量
|
|
|
+ Float physicalInventory=warehouseInventoryCountInfo1.getPhysicalInventory();
|
|
|
+ //定义入库
|
|
|
+ Float inNetWeight =0f;
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseInventoryCountInfo1.getBaseId())
|
|
|
+ .eq("position_id", warehouseInventoryCountInfo1.getPositionId())
|
|
|
+ .eq("in_out_flag", "2")
|
|
|
+ .ge("create_date",warehouseInventoryCountInfo1.getCreateDate())
|
|
|
+ .eq("goods_name_key",warehouseInventoryCountInfo1.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
+ inNetWeight = inNetWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ warehouseInventoryCountInfoCopy.setCumulativeStockIn(inNetWeight + physicalInventory);
|
|
|
+ //定义出库
|
|
|
+ Float outNetWeight = 0f;
|
|
|
+ // 查询出库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseInventoryCountInfo1.getBaseId())
|
|
|
+ .eq("position_id", warehouseInventoryCountInfo1.getPositionId())
|
|
|
+ .ge("create_date",warehouseInventoryCountInfo1.getCreateDate())
|
|
|
+ .eq("in_out_flag", "1")
|
|
|
+ .eq("goods_name_key",warehouseInventoryCountInfo1.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
+ outNetWeight = outNetWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ warehouseInventoryCountInfoCopy.setCumulativeStockOut(outNetWeight);
|
|
|
+
|
|
|
+ }
|
|
|
+ // 未盘损过
|
|
|
+ else{
|
|
|
+ //定义入库
|
|
|
+ Float inNetWeight =0f;
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseInventoryCountInfo.getBaseId())
|
|
|
+ .eq("position_id", warehouseInventoryCountInfo.getPositionId())
|
|
|
+ .eq("in_out_flag", "2")
|
|
|
+ .eq("goods_name_key",warehouseInventoryCountInfo.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
+ inNetWeight = inNetWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ warehouseInventoryCountInfoCopy.setCumulativeStockIn(inNetWeight);
|
|
|
+ //定义出库
|
|
|
+ Float outNetWeight = 0f;
|
|
|
+ // 查询出库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseInventoryCountInfo.getBaseId())
|
|
|
+ .eq("position_id", warehouseInventoryCountInfo.getPositionId())
|
|
|
+ .eq("in_out_flag", "1")
|
|
|
+ .eq("goods_name_key",warehouseInventoryCountInfo.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
+ outNetWeight = outNetWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ warehouseInventoryCountInfoCopy.setCumulativeStockOut(outNetWeight);
|
|
|
+
|
|
|
+ }
|
|
|
+ return warehouseInventoryCountInfoCopy;
|
|
|
+ }
|
|
|
}
|