|
|
@@ -1,19 +1,21 @@
|
|
|
package com.yunfeiyun.agmp.fms.service.impl;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
+import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
+import com.yunfeiyun.agmp.common.exception.BizException;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
-import com.yunfeiyun.agmp.common.utils.StringUtils;
|
|
|
import com.yunfeiyun.agmp.fms.domain.FmsLandHouse;
|
|
|
import com.yunfeiyun.agmp.fms.domain.WmsWarehouse;
|
|
|
import com.yunfeiyun.agmp.fms.mapper.FmsLandHouseMapper;
|
|
|
import com.yunfeiyun.agmp.fms.mapper.WmsWarehouseMapper;
|
|
|
+import com.yunfeiyun.agmp.fms.service.IFmsLandHouseService;
|
|
|
import com.yunfeiyun.agmp.fms.service.IWmsWarehouseService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -30,6 +32,9 @@ public class WmsWarehouseServiceImpl implements IWmsWarehouseService
|
|
|
@Autowired
|
|
|
private FmsLandHouseMapper fmsLandHouseMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFmsLandHouseService fmsLandHouseService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询仓库
|
|
|
*
|
|
|
@@ -62,23 +67,30 @@ public class WmsWarehouseServiceImpl implements IWmsWarehouseService
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public int insertWmsWarehouse(WmsWarehouse wmsWarehouse) {
|
|
|
+ String tid = SecurityUtils.getTid();
|
|
|
wmsWarehouse.setWarehouseId(wmsWarehouse.getId());
|
|
|
wmsWarehouse.setWarehouseCreator(SecurityUtils.getUserId());
|
|
|
wmsWarehouse.setWarehouseCreatorname(SecurityUtils.getUsername());
|
|
|
wmsWarehouse.setWarehouseCreateddate(DateUtils.getTime());
|
|
|
+ wmsWarehouse.setTid(tid);
|
|
|
int i = wmsWarehouseMapper.insertWmsWarehouse(wmsWarehouse);
|
|
|
|
|
|
//更新关联关系
|
|
|
List<String> landIds = wmsWarehouse.getLandIds();
|
|
|
- if (landIds != null &&landIds.size() > 0) {
|
|
|
+
|
|
|
+ if (landIds != null && !landIds.isEmpty()) {
|
|
|
+ List<FmsLandHouse> fmsLandHouseList = new ArrayList<>();
|
|
|
for (String landId : landIds) {
|
|
|
FmsLandHouse fmsLandHouse = new FmsLandHouse();
|
|
|
fmsLandHouse.setLandhouseId(fmsLandHouse.getId());
|
|
|
fmsLandHouse.setLandId(landId);
|
|
|
fmsLandHouse.setWarehouseId(wmsWarehouse.getWarehouseId());
|
|
|
- fmsLandHouseMapper.insertFmsLandHouse(fmsLandHouse);
|
|
|
+ fmsLandHouse.setTid(tid);
|
|
|
+ fmsLandHouseList.add(fmsLandHouse);
|
|
|
}
|
|
|
+ fmsLandHouseService.insertBatchFmsLandHouse(fmsLandHouseList);
|
|
|
}
|
|
|
+
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
@@ -90,23 +102,31 @@ public class WmsWarehouseServiceImpl implements IWmsWarehouseService
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateWmsWarehouse(WmsWarehouse wmsWarehouse) {
|
|
|
- if(StringUtils.isEmpty(wmsWarehouse.getWarehouseId()) || ObjectUtils.isEmpty(wmsWarehouseMapper.selectWmsWarehouseByWarehouseId(wmsWarehouse.getWarehouseId(),wmsWarehouse.getTid())))
|
|
|
- {
|
|
|
- return 0;
|
|
|
+ String tid = SecurityUtils.getTid();
|
|
|
+ String warehouseId = wmsWarehouse.getWarehouseId();
|
|
|
+
|
|
|
+ WmsWarehouse wmsWarehouseOld = selectWmsWarehouseByWarehouseId(warehouseId,tid);
|
|
|
+ if(wmsWarehouseOld == null){
|
|
|
+ throw new BizException(ErrorCode.INVALID_PARAMETER.getCode(), "仓库不存在");
|
|
|
}
|
|
|
+
|
|
|
int i = wmsWarehouseMapper.updateWmsWarehouse(wmsWarehouse);
|
|
|
|
|
|
//更新关联关系
|
|
|
- fmsLandHouseMapper.deleteFmsLandHouseByWarehouseId(wmsWarehouse.getWarehouseId(), wmsWarehouse.getTid());
|
|
|
+ fmsLandHouseService.deleteFmsLandHouseByWarehouseId(warehouseId, tid);
|
|
|
List<String> landIds = wmsWarehouse.getLandIds();
|
|
|
- if (landIds != null && landIds.size() > 0) {
|
|
|
+
|
|
|
+ if (landIds != null && !landIds.isEmpty()) {
|
|
|
+ List<FmsLandHouse> fmsLandHouseList = new ArrayList<>();
|
|
|
for (String landId : landIds) {
|
|
|
FmsLandHouse fmsLandHouse = new FmsLandHouse();
|
|
|
fmsLandHouse.setLandhouseId(fmsLandHouse.getId());
|
|
|
fmsLandHouse.setLandId(landId);
|
|
|
fmsLandHouse.setWarehouseId(wmsWarehouse.getWarehouseId());
|
|
|
- fmsLandHouseMapper.insertFmsLandHouse(fmsLandHouse);
|
|
|
+ fmsLandHouse.setTid(tid);
|
|
|
+ fmsLandHouseList.add(fmsLandHouse);
|
|
|
}
|
|
|
+ fmsLandHouseService.insertBatchFmsLandHouse(fmsLandHouseList);
|
|
|
}
|
|
|
return i;
|
|
|
}
|