|
@@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
|
import com.baomidou.mybatisplus.mapper.Wrapper;
|
|
|
import com.yh.saas.common.support.util.IdGenerator;
|
|
|
import com.yh.saas.common.support.util.StringUtils;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.constant.NumberConstant;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.constant.StatusEnum;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseBaseInfo;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehouseInOutInfo;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehousePositionInfo;
|
|
|
-import com.yh.saas.plugin.yiliangyiyun.entity.WarehousePositionStorageInfo;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.*;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.entity.view.WarehouseView;
|
|
|
+import com.yh.saas.plugin.yiliangyiyun.entity.view.WarehouseNumView;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YException;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.exception.YExceptionEnum;
|
|
|
import com.yh.saas.plugin.yiliangyiyun.mapper.WarehouseBaseInfoMapper;
|
|
@@ -20,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Comparator;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -39,6 +39,10 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
private IWarehouseInOutInfoService warehouseInOutInfoService;
|
|
|
@Autowired
|
|
|
private IWarehousePositionStorageInfoService warehousePositionStorageInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IWarehouseBaseInfoService warehouseBaseInfoService;
|
|
|
+ @Autowired
|
|
|
+ private IContractManagementInfoService contractManagementInfoService;
|
|
|
|
|
|
/**
|
|
|
* 仓库管理页面列表
|
|
@@ -47,94 +51,218 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<WarehouseView> selectWarehouseViewinfo(String compId, String warehouseName) {
|
|
|
+ public List<WarehouseView> selectWarehouseViewinfo(String compId, String warehouseName, String warehouseType) {
|
|
|
List<WarehouseView> warehouseViews = new ArrayList<>();
|
|
|
Wrapper<WarehouseBaseInfo> warehouseBaseInfoWrapper = new EntityWrapper<>();
|
|
|
- warehouseBaseInfoWrapper.eq("comp_id", compId).eq("delete_flag", "0").eq("show_flag", "1");
|
|
|
+ warehouseBaseInfoWrapper.eq(WarehouseBaseInfo.QueryFiles.COMP_ID, compId)
|
|
|
+ .eq(WarehouseBaseInfo.QueryFiles.DELETE_FLAG, NumberConstant.CONSTANT0)
|
|
|
+ .eq(WarehouseBaseInfo.QueryFiles.SHOW_FLAG, NumberConstant.CONSTANT1).eq(WarehouseBaseInfo.QueryFiles.WAREHOUSE_TYPE, warehouseType);
|
|
|
if (!StringUtils.isEmpty(warehouseName)) {
|
|
|
- warehouseBaseInfoWrapper.eq("warehouse_name", warehouseName);
|
|
|
+ warehouseBaseInfoWrapper.like(WarehouseBaseInfo.QueryFiles.WAREHOUSE_NAME, "%" + warehouseName + "%");
|
|
|
}
|
|
|
// 查出所有仓库
|
|
|
List<WarehouseBaseInfo> warehouseBaseInfoList = this.selectList(warehouseBaseInfoWrapper);
|
|
|
- if (!CollectionUtils.isEmpty(warehouseBaseInfoList)) {
|
|
|
- for (WarehouseBaseInfo warehouseBaseInfo : warehouseBaseInfoList) {
|
|
|
- // 以库位为维度查询
|
|
|
- List<WarehousePositionInfo> warehousePositionInfos = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
|
|
|
- .eq("comp_id", compId).eq("base_id", warehouseBaseInfo.getId()));
|
|
|
- if (!CollectionUtils.isEmpty(warehousePositionInfos)) {
|
|
|
- for (WarehousePositionInfo warehousePositionInfo : warehousePositionInfos) {
|
|
|
- WarehouseView warehouseView = new WarehouseView();
|
|
|
- warehouseView.setWarehouseId(warehouseBaseInfo.getId());
|
|
|
- warehouseView.setWarehouseName(warehouseBaseInfo.getWarehouseName());
|
|
|
- warehouseView.setBinNumberId(warehousePositionInfo.getId());
|
|
|
- warehouseView.setBinNumber(warehousePositionInfo.getBinNumber());
|
|
|
- warehouseView.setCapacity(String.valueOf(warehousePositionInfo.getMaxStorage()));
|
|
|
- // 定义待完成数量
|
|
|
- int count = 0;
|
|
|
- // 定义应余量
|
|
|
- String storage = "";
|
|
|
- //定义入库
|
|
|
- String inNetWeight = "";
|
|
|
- // 查询入库数量
|
|
|
- List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
- .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "2").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
- if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
- for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
- // 查询入库数量
|
|
|
- List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
- .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "2")
|
|
|
- .eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
- if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
- Float netWeight = 0f;
|
|
|
- for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
- netWeight = netWeight + warehouse.getNetWeight();
|
|
|
- if ("1".equals(warehouse.getStatusFlag())) {
|
|
|
- count++;
|
|
|
+ if (NumberConstant.CONSTANT1.equals(warehouseType)) {
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseBaseInfoList)) {
|
|
|
+ for (WarehouseBaseInfo warehouseBaseInfo : warehouseBaseInfoList) {
|
|
|
+ // 以库位为维度查询
|
|
|
+ List<WarehousePositionInfo> warehousePositionInfos = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehousePositionInfos)) {
|
|
|
+ for (WarehousePositionInfo warehousePositionInfo : warehousePositionInfos) {
|
|
|
+ WarehouseView warehouseView = new WarehouseView();
|
|
|
+ warehouseView.setWarehouseId(warehouseBaseInfo.getId());
|
|
|
+ warehouseView.setWarehouseName(warehouseBaseInfo.getWarehouseName());
|
|
|
+ warehouseView.setBinNumberId(warehousePositionInfo.getId());
|
|
|
+ warehouseView.setBinNumber(warehousePositionInfo.getBinNumber());
|
|
|
+ warehouseView.setCapacity(String.valueOf(warehousePositionInfo.getMaxStorage()));
|
|
|
+ warehouseView.setRemark(warehousePositionInfo.getRemark());
|
|
|
+ // 定义待完成数量
|
|
|
+ int count = 0;
|
|
|
+ // 定义应余量
|
|
|
+ String storage = "";
|
|
|
+ //定义入库
|
|
|
+ String inNetWeight = "";
|
|
|
+ // 子集合
|
|
|
+ List<WarehouseNumView> warehouseNumViewList = new ArrayList<>();
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "2").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
+ WarehouseNumView warehouseNumView = new WarehouseNumView();
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "2")
|
|
|
+ .eq("status_flag", "3").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
+ Float netWeight = 0f;
|
|
|
+ for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
+ netWeight = netWeight + warehouse.getNetWeight();
|
|
|
+ }
|
|
|
+ warehouseNumView.setGoodsName(warehouseInOutInfoAllList.get(0).getGoodsName());
|
|
|
+ warehouseNumView.setInNetWeight(String.valueOf(netWeight));
|
|
|
+ if (StringUtils.isEmpty(inNetWeight)) {
|
|
|
+ inNetWeight = "0";
|
|
|
}
|
|
|
+ inNetWeight = String.valueOf(Float.valueOf(inNetWeight) + netWeight);
|
|
|
+ }
|
|
|
+ // 查询应余量
|
|
|
+ WarehousePositionStorageInfo warehousePositionStorageInfo = warehousePositionStorageInfoService.selectOne(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
+ .eq("position_id", warehouseInOutInfo.getPositionId()).eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
+ if (warehousePositionStorageInfo != null) {
|
|
|
+ storage = String.valueOf(warehousePositionStorageInfo.getStorage());
|
|
|
+ } else {
|
|
|
+ storage = "";
|
|
|
}
|
|
|
- inNetWeight = inNetWeight + warehouseInOutInfo.getGoodsName() + "(" + netWeight + ") ";
|
|
|
+ warehouseNumView.setStorage(storage);
|
|
|
+ warehouseNumViewList.add(warehouseNumView);
|
|
|
}
|
|
|
- // 查询应余量
|
|
|
- WarehousePositionStorageInfo warehousePositionStorageInfo = warehousePositionStorageInfoService.selectOne(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
- .eq("position_id", warehouseInOutInfo.getPositionId()).eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
- storage = storage + warehousePositionStorageInfo.getGoodsName() + "(" + warehousePositionStorageInfo.getStorage() + ")";
|
|
|
|
|
|
}
|
|
|
- }
|
|
|
- warehouseView.setStorage(storage);
|
|
|
- warehouseView.setInNetWeight(inNetWeight);
|
|
|
- //定义出库
|
|
|
- String outNetWeight = "";
|
|
|
- // 查询出库数量
|
|
|
- List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
- .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "1").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
- if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
- for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
- List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
- .eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "1").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
- if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
+
|
|
|
+ //定义出库
|
|
|
+ String outNetWeight = "";
|
|
|
+ // 查询出库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "1").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
Float netWeight = 0f;
|
|
|
- for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
- netWeight = netWeight + warehouse.getNetWeight();
|
|
|
- if ("1".equals(warehouse.getStatusFlag())) {
|
|
|
- count++;
|
|
|
+ outNetWeight = "0";
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("status_flag", "3").eq("position_id", warehousePositionInfo.getId()).eq("in_out_flag", "1").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
+ for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
+ netWeight = netWeight + warehouse.getNetWeight();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(outNetWeight)) {
|
|
|
+ outNetWeight = "0";
|
|
|
}
|
|
|
+ outNetWeight = String.valueOf(Float.valueOf(outNetWeight) + netWeight);
|
|
|
}
|
|
|
- outNetWeight = outNetWeight + warehouseInOutInfo.getGoodsName() + "(" + netWeight + ") ";
|
|
|
+ for (WarehouseNumView warehouseNumView : warehouseNumViewList) {
|
|
|
+ if (warehouseNumView.getGoodsName().equals(warehouseInOutInfo.getGoodsName())) {
|
|
|
+ warehouseNumView.setOutNetWeight(outNetWeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ // 查询入库数量
|
|
|
+ count = warehouseInOutInfoService.selectCount(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId())
|
|
|
+ .eq("status_flag", "1"));
|
|
|
+ warehouseView.setNumber(count);
|
|
|
+ warehouseView.setWarehouseNumViewList(warehouseNumViewList);
|
|
|
+ warehouseViews.add(warehouseView);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseBaseInfoList)) {
|
|
|
+ for (WarehouseBaseInfo warehouseBaseInfo : warehouseBaseInfoList) {
|
|
|
+ WarehouseView warehouseView = new WarehouseView();
|
|
|
+ warehouseView.setWarehouseId(warehouseBaseInfo.getId());
|
|
|
+ warehouseView.setCreateType(warehouseBaseInfo.getCreateType());
|
|
|
+ warehouseView.setClearStatus(warehouseBaseInfo.getClearStatus());
|
|
|
+ warehouseView.setClearStatusFlag(warehouseBaseInfo.getClearStatusFlag());
|
|
|
+ warehouseView.setWarehouseName(warehouseBaseInfo.getWarehouseName());
|
|
|
+ warehouseView.setUpdateDate(warehouseBaseInfo.getUpdateDate());
|
|
|
+ warehouseView.setAddress(warehouseBaseInfo.getWarehousePrivate() + warehouseBaseInfo.getWarehouseCity() + warehouseBaseInfo.getWarehouseArea() + warehouseBaseInfo.getDetailedAddress());
|
|
|
+ // 定义待完成数量
|
|
|
+ int count = 0;
|
|
|
+ //定义入库
|
|
|
+ String inNetWeight = "";
|
|
|
+ // 子集合
|
|
|
+ List<WarehouseNumView> warehouseNumViewList = new ArrayList<>();
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "2").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
+ WarehouseNumView warehouseNumView = new WarehouseNumView();
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()).eq("in_out_flag", "2")
|
|
|
+ .eq("status_flag", "3").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
+ Float netWeight = 0f;
|
|
|
+ for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
+ netWeight = netWeight + warehouse.getNetWeight();
|
|
|
+ }
|
|
|
+ warehouseNumView.setGoodsName(warehouseInOutInfoAllList.get(0).getGoodsName());
|
|
|
+ warehouseNumView.setInNetWeight(String.valueOf(netWeight));
|
|
|
+ if (StringUtils.isEmpty(inNetWeight)) {
|
|
|
+ inNetWeight = "0";
|
|
|
}
|
|
|
+ inNetWeight = String.valueOf(Float.valueOf(inNetWeight) + netWeight);
|
|
|
}
|
|
|
+ warehouseNumViewList.add(warehouseNumView);
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+ //定义出库
|
|
|
+ String outNetWeight = "";
|
|
|
+ // 查询出库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "1").groupBy("goods_name_key").orderBy("goods_name_key"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
+ Float netWeight = 0f;
|
|
|
+ outNetWeight = "0";
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoAllList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("status_flag", "3").eq("base_id", warehouseBaseInfo.getId()).eq("in_out_flag", "1").eq("goods_name_key", warehouseInOutInfo.getGoodsNameKey()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoAllList)) {
|
|
|
+ for (WarehouseInOutInfo warehouse : warehouseInOutInfoAllList) {
|
|
|
+ netWeight = netWeight + warehouse.getNetWeight();
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(outNetWeight)) {
|
|
|
+ outNetWeight = "0";
|
|
|
+ }
|
|
|
+ outNetWeight = String.valueOf(Float.valueOf(outNetWeight) + netWeight);
|
|
|
+ }
|
|
|
+ for (WarehouseNumView warehouseNumView : warehouseNumViewList) {
|
|
|
+ if (warehouseNumView.getGoodsName().equals(warehouseInOutInfo.getGoodsName())) {
|
|
|
+ warehouseNumView.setOutNetWeight(outNetWeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- warehouseView.setOutNetWeight(outNetWeight);
|
|
|
- warehouseView.setNumber(count);
|
|
|
- warehouseViews.add(warehouseView);
|
|
|
|
|
|
}
|
|
|
+ // 查询入库数量
|
|
|
+ count = warehouseInOutInfoService.selectCount(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId())
|
|
|
+ .eq("status_flag", "1"));
|
|
|
+ warehouseView.setNumber(count);
|
|
|
+ // 定义待完成数量
|
|
|
+ int outCount = 0;
|
|
|
+ outCount = warehouseInOutInfoService.selectCount(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId())
|
|
|
+ .eq("in_out_flag", "1")
|
|
|
+ .eq("status_flag", "1"));
|
|
|
+ warehouseView.setOutNumber(outCount);
|
|
|
+ warehouseView.setWarehouseNumViewList(warehouseNumViewList);
|
|
|
+ warehouseViews.add(warehouseView);
|
|
|
+ // 排序
|
|
|
+ Comparator<WarehouseView> byClearStatusFlag = Comparator.comparing(WarehouseView::getClearStatusFlag);
|
|
|
+ Comparator<WarehouseView> byUpdateDate = Comparator.comparing(WarehouseView::getUpdateDate);
|
|
|
+ warehouseViews.sort(byClearStatusFlag.thenComparing(byUpdateDate));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
return warehouseViews;
|
|
|
}
|
|
|
|
|
@@ -152,6 +280,14 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
warehousePositionInfo.setBaseId(warehouseBaseInfo.getId());
|
|
|
}
|
|
|
}
|
|
|
+ //判断仓库名称是否唯一
|
|
|
+ List<WarehouseBaseInfo> warehouseBaseInfos =
|
|
|
+ warehouseBaseInfoService.selectList(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
+ .eq("warehouse_name", warehouseBaseInfo.getWarehouseName())
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
+ if (warehouseBaseInfos.size() > 0) {
|
|
|
+ throw new YException(YExceptionEnum.WAREHOUSE_NAME_ERROR);
|
|
|
+ }
|
|
|
boolean one = this.insert(warehouseBaseInfo);
|
|
|
boolean two = warehousePositionInfoService.insertBatch(warehousePositionInfoList);
|
|
|
// 假如 都成功返回ok
|
|
@@ -162,14 +298,54 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加临时仓库
|
|
|
+ *
|
|
|
+ * @param warehouseBaseInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String addTemporaryWarehouse(WarehouseBaseInfo warehouseBaseInfo) {
|
|
|
+ //新增主键id
|
|
|
+ if (StringUtils.isEmpty(warehouseBaseInfo.getId())) {
|
|
|
+ warehouseBaseInfo.setId(IdGenerator.generateUUID());
|
|
|
+ }
|
|
|
+ warehouseBaseInfo.setWarehouseType("2");
|
|
|
+ warehouseBaseInfo.setClearStatusFlag(StatusEnum.NOT_CLEARED.getFlag());
|
|
|
+ warehouseBaseInfo.setClearStatus(StatusEnum.NOT_CLEARED.getName());
|
|
|
+ //判断仓库名称是否唯一
|
|
|
+ List<WarehouseBaseInfo> warehouseBaseInfos =
|
|
|
+ warehouseBaseInfoService.selectList(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
+ .eq("warehouse_name", warehouseBaseInfo.getWarehouseName())
|
|
|
+ .eq("delete_flag", "0")
|
|
|
+ .eq("warehouse_type", "2"));
|
|
|
+ if (warehouseBaseInfos.size() > 0) {
|
|
|
+ throw new YException(YExceptionEnum.WAREHOUSE_NAME_ERROR);
|
|
|
+ }
|
|
|
+ this.insert(warehouseBaseInfo);
|
|
|
+ return warehouseBaseInfo.getId();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 编辑仓库
|
|
|
*/
|
|
|
@Override
|
|
|
public String editWarehouse(WarehouseBaseInfo warehouseBaseInfo) {
|
|
|
- List<WarehousePositionInfo> warehousePositionInfoList = warehouseBaseInfo.getWarehousePositionInfoList();
|
|
|
this.updateById(warehouseBaseInfo);
|
|
|
- warehousePositionInfoService.updateBatchById(warehousePositionInfoList);
|
|
|
+ if (warehouseBaseInfo.getWarehouseType().equals("1")) {
|
|
|
+ List<WarehousePositionInfo> warehousePositionInfoList = warehouseBaseInfo.getWarehousePositionInfoList();
|
|
|
+ if (!CollectionUtils.isEmpty(warehousePositionInfoList)) {
|
|
|
+ warehousePositionInfoList.forEach(warehousePositionInfo -> {
|
|
|
+ if (StringUtils.isEmpty(warehousePositionInfo.getId())) {
|
|
|
+ warehousePositionInfo.setId(IdGenerator.generateUUID());
|
|
|
+ warehousePositionInfo.setBaseId(warehouseBaseInfo.getId());
|
|
|
+ warehousePositionInfoService.insert(warehousePositionInfo);
|
|
|
+ } else {
|
|
|
+ warehousePositionInfoService.updateById(warehousePositionInfo);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
return warehouseBaseInfo.getId();
|
|
|
}
|
|
|
|
|
@@ -179,9 +355,9 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<WarehouseBaseInfo> selectWarehouse(String compId) {
|
|
|
+ public List<WarehouseBaseInfo> selectWarehouse(String compId, String warehouseType) {
|
|
|
List<WarehouseBaseInfo> warehouseBaseInfoList = this.selectList(new EntityWrapper<WarehouseBaseInfo>()
|
|
|
- .eq("comp_id", compId).eq("delete_flag", "0"));
|
|
|
+ .eq("comp_id", compId).eq("warehouse_type", warehouseType).eq("delete_flag", "0"));
|
|
|
return warehouseBaseInfoList;
|
|
|
}
|
|
|
|
|
@@ -192,7 +368,22 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
public WarehouseBaseInfo getWarehouse(String id) {
|
|
|
WarehouseBaseInfo warehouseBaseInfo = this.selectById(id);
|
|
|
List<WarehousePositionInfo> warehousePositionInfoList = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
|
|
|
- .eq("base_id", id));
|
|
|
+ .eq("base_id", id)
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
+ warehousePositionInfoList.forEach(warehousePositionInfo -> {
|
|
|
+ List<WarehousePositionStorageInfo> warehousePositionStorageInfoList = warehousePositionStorageInfoService.selectList(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId())
|
|
|
+ .eq("delete_flag", "0"));
|
|
|
+ Float storage = 0f;
|
|
|
+ String detailStorage = "";
|
|
|
+ for (WarehousePositionStorageInfo warehousePositionStorageInfo : warehousePositionStorageInfoList) {
|
|
|
+ storage = storage + warehousePositionStorageInfo.getStorage();
|
|
|
+ detailStorage = detailStorage + warehousePositionStorageInfo.getGoodsName() + "(" + warehousePositionStorageInfo.getStorage() + ") ";
|
|
|
+ }
|
|
|
+ warehousePositionInfo.setDetailStorage(detailStorage);
|
|
|
+ warehousePositionInfo.setNowStorage(storage);
|
|
|
+ });
|
|
|
+
|
|
|
warehouseBaseInfo.setWarehousePositionInfoList(warehousePositionInfoList);
|
|
|
return warehouseBaseInfo;
|
|
|
}
|
|
@@ -220,13 +411,18 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
/**
|
|
|
* 查询所有库房
|
|
|
*
|
|
|
- * @param compId
|
|
|
+ * @param compId,warehouseType
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<WarehouseBaseInfo> selectAllWarehouse(String compId) {
|
|
|
+ public List<WarehouseBaseInfo> selectAllWarehouse(String compId, String warehouseType, String warehouseName) {
|
|
|
+ Wrapper<WarehouseBaseInfo> warehouseBaseInfoWrapper = new EntityWrapper<>();
|
|
|
+ warehouseBaseInfoWrapper.eq("comp_id", compId).eq("delete_flag", "0").eq("show_flag", "1").eq("warehouse_type", warehouseType);
|
|
|
+ if (!StringUtils.isEmpty(warehouseName)) {
|
|
|
+ warehouseBaseInfoWrapper.like("warehouse_name", "%" + warehouseName + "%");
|
|
|
+ }
|
|
|
// 查出所有仓库
|
|
|
- List<WarehouseBaseInfo> warehouseBaseInfoList = this.selectList(new EntityWrapper<WarehouseBaseInfo>().eq("comp_id", compId).eq("delete_flag", "0"));
|
|
|
+ List<WarehouseBaseInfo> warehouseBaseInfoList = this.selectList(warehouseBaseInfoWrapper);
|
|
|
if (!CollectionUtils.isEmpty(warehouseBaseInfoList)) {
|
|
|
for (WarehouseBaseInfo warehouseBaseInfo : warehouseBaseInfoList) {
|
|
|
// 应余量
|
|
@@ -246,9 +442,47 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //临时仓库
|
|
|
+ else {
|
|
|
+ //定义入库
|
|
|
+ String inNetWeight = "";
|
|
|
+ // 查询入库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfoList = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "2"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfoList)) {
|
|
|
+ Float netWeight = 0f;
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfoList) {
|
|
|
+ // 查询入库数量
|
|
|
+ netWeight = netWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ if (StringUtils.isEmpty(inNetWeight)) {
|
|
|
+ inNetWeight = "0";
|
|
|
+ }
|
|
|
+ inNetWeight = String.valueOf(Float.valueOf(inNetWeight) + netWeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //定义出库
|
|
|
+ String outNetWeight = "";
|
|
|
+ // 查询出库数量
|
|
|
+ List<WarehouseInOutInfo> warehouseInOutInfos = warehouseInOutInfoService.selectList(new EntityWrapper<WarehouseInOutInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()).eq("status_flag", "3").eq("in_out_flag", "1"));
|
|
|
+ if (!CollectionUtils.isEmpty(warehouseInOutInfos)) {
|
|
|
+ Float netWeight = 0f;
|
|
|
+ for (WarehouseInOutInfo warehouseInOutInfo : warehouseInOutInfos) {
|
|
|
+ netWeight = netWeight + warehouseInOutInfo.getNetWeight();
|
|
|
+ if (StringUtils.isEmpty(outNetWeight)) {
|
|
|
+ outNetWeight = "0";
|
|
|
+ }
|
|
|
+ outNetWeight = String.valueOf(Float.valueOf(outNetWeight) + netWeight);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ residual = Float.valueOf(!StringUtils.isEmpty(inNetWeight) ? inNetWeight : "0") - Float.valueOf(!StringUtils.isEmpty(outNetWeight) ? outNetWeight : "0");
|
|
|
+ }
|
|
|
warehouseBaseInfo.setResidual(residual);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return warehouseBaseInfoList;
|
|
|
}
|
|
|
|
|
@@ -262,26 +496,62 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
|
|
|
//查询仓库信息
|
|
|
WarehouseBaseInfo warehouseBaseInfo = this.selectById(id);
|
|
|
this.deleteById(warehouseBaseInfo.getId());
|
|
|
- //查询仓位信息
|
|
|
- List<WarehousePositionInfo> warehousePositionInfos = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
|
|
|
- .eq("base_id", warehouseBaseInfo.getId()));
|
|
|
- if (!CollectionUtils.isEmpty(warehousePositionInfos)) {
|
|
|
- for (WarehousePositionInfo warehousePositionInfo : warehousePositionInfos) {
|
|
|
- warehousePositionInfoService.deleteById(warehousePositionInfo.getId());
|
|
|
- //查询仓位存储量
|
|
|
- List<WarehousePositionStorageInfo> warehousePositionStorageInfos = warehousePositionStorageInfoService.selectList(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
- .eq("position_id", warehousePositionInfo.getId()));
|
|
|
- if (!CollectionUtils.isEmpty(warehousePositionStorageInfos)) {
|
|
|
- for (WarehousePositionStorageInfo warehousePositionStorageInfo : warehousePositionStorageInfos) {
|
|
|
- //判断是否有剩余库存
|
|
|
- if (warehousePositionStorageInfo.getStorage() > 0) {
|
|
|
- throw new YException(YExceptionEnum.WAREHOSE_SYSTEM_ERROR);
|
|
|
- } else {
|
|
|
- warehousePositionStorageInfoService.deleteById(warehousePositionStorageInfo.getId());
|
|
|
+ if (warehouseBaseInfo.getWarehouseType().equals("1")) {
|
|
|
+ //查询仓位信息
|
|
|
+ List<WarehousePositionInfo> warehousePositionInfos = warehousePositionInfoService.selectList(new EntityWrapper<WarehousePositionInfo>()
|
|
|
+ .eq("base_id", warehouseBaseInfo.getId()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehousePositionInfos)) {
|
|
|
+ for (WarehousePositionInfo warehousePositionInfo : warehousePositionInfos) {
|
|
|
+ warehousePositionInfoService.deleteById(warehousePositionInfo.getId());
|
|
|
+ //查询仓位存储量
|
|
|
+ List<WarehousePositionStorageInfo> warehousePositionStorageInfos = warehousePositionStorageInfoService.selectList(new EntityWrapper<WarehousePositionStorageInfo>()
|
|
|
+ .eq("position_id", warehousePositionInfo.getId()));
|
|
|
+ if (!CollectionUtils.isEmpty(warehousePositionStorageInfos)) {
|
|
|
+ for (WarehousePositionStorageInfo warehousePositionStorageInfo : warehousePositionStorageInfos) {
|
|
|
+ //判断是否有剩余库存
|
|
|
+ if (warehousePositionStorageInfo.getStorage() > 0) {
|
|
|
+ throw new YException(YExceptionEnum.WAREHOSE_SYSTEM_ERROR);
|
|
|
+ } else {
|
|
|
+ warehousePositionStorageInfoService.deleteById(warehousePositionStorageInfo.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 清仓状态
|
|
|
+ *
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String editCleared(String id) {
|
|
|
+ //查询仓库信息
|
|
|
+ WarehouseBaseInfo warehouseBaseInfo = this.selectById(id);
|
|
|
+ //状态改为已清仓
|
|
|
+ warehouseBaseInfo.setClearStatusFlag(StatusEnum.CLEARED.getFlag());
|
|
|
+ warehouseBaseInfo.setClearStatus(StatusEnum.CLEARED.getName());
|
|
|
+ //更改仓库信息
|
|
|
+ this.updateById(warehouseBaseInfo);
|
|
|
+ return "OK";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 出入库合同编号下拉列表
|
|
|
+ *
|
|
|
+ * @param compId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<ContractManagementInfo> selectContractNoList(String compId) {
|
|
|
+ List<ContractManagementInfo> contractManagementInfoList = contractManagementInfoService.selectList(new EntityWrapper<ContractManagementInfo>()
|
|
|
+ .eq("comp_id", compId)
|
|
|
+ .eq("delete_flag", "0")
|
|
|
+ .orderBy("update_date", false));
|
|
|
+ return contractManagementInfoList;
|
|
|
}
|
|
|
}
|