wuxw
2021-06-06 ee8e3e905cce3bda21fca450914ac38b18992edd
service-api/src/main/java/com/java110/api/bmo/allocationStorehouse/impl/AllocationStorehouseBMOImpl.java
@@ -4,9 +4,11 @@
import com.java110.api.bmo.ApiBaseBMO;
import com.java110.api.bmo.allocationStorehouse.IAllocationStorehouseBMO;
import com.java110.core.context.DataFlowContext;
import com.java110.dto.allocationStorehouse.AllocationStorehouseDto;
import com.java110.intf.community.IResourceStoreServiceSMO;
import com.java110.intf.store.IAllocationStorehouseInnerServiceSMO;
import com.java110.po.allocationStorehouse.AllocationStorehousePo;
import com.java110.po.allocationStorehouseApply.AllocationStorehouseApplyPo;
import com.java110.po.purchase.ResourceStorePo;
import com.java110.utils.constant.BusinessTypeConstant;
import com.java110.utils.util.Assert;
@@ -58,23 +60,35 @@
     * @return 订单服务能够接受的报文
     */
    public void deleteAllocationStorehouse(JSONObject paramInJson, DataFlowContext dataFlowContext) {
        AllocationStorehousePo allocationStorehousePo = BeanConvertUtil.covertBean(paramInJson, AllocationStorehousePo.class);
        super.delete(dataFlowContext, allocationStorehousePo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_ALLOCATION_STOREHOUSE);
        ResourceStorePo resourceStorePo = new ResourceStorePo();
        resourceStorePo.setResId(allocationStorehousePo.getResId());
        //查询资源物品表
        List<ResourceStorePo> resourceStores = resourceStoreServiceSMOImpl.getResourceStores(resourceStorePo);
        Assert.listOnlyOne(resourceStores, "资源物品信息错误");
        //获取库存数量
        int resourceStoreStock = Integer.parseInt(resourceStores.get(0).getStock());
        //获取调拨的数量
        int storehouseStock = Integer.parseInt(allocationStorehousePo.getStock());
        //库存数量
        int stock = resourceStoreStock + storehouseStock;
        /*ResourceStoreDto resourceStoreDto = new ResourceStoreDto();
        resourceStoreDto.setResId(allocationStorehousePo.getResId());
        resourceStoreDto.setStock(String.valueOf(stock));*/
        resourceStorePo.setStock(String.valueOf(stock));
        super.update(dataFlowContext, resourceStorePo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_RESOURCE_STORE);
        AllocationStorehouseDto allocationStorehouseDto = new AllocationStorehouseDto();
        allocationStorehouseDto.setApplyId(paramInJson.getString("applyId"));
        allocationStorehouseDto.setStoreId(paramInJson.getString("storeId"));
        List<AllocationStorehouseDto> allocationStorehouseDtos = allocationStorehouseInnerServiceSMOImpl.queryAllocationStorehouses(allocationStorehouseDto);
        for (AllocationStorehouseDto tmpAllocationStorehouseDto : allocationStorehouseDtos) {
            AllocationStorehousePo allocationStorehousePo = BeanConvertUtil.covertBean(tmpAllocationStorehouseDto, AllocationStorehousePo.class);
            super.delete(dataFlowContext, allocationStorehousePo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_ALLOCATION_STOREHOUSE);
            ResourceStorePo resourceStorePo = new ResourceStorePo();
            resourceStorePo.setResId(allocationStorehousePo.getResId());
            //查询资源物品表
            List<ResourceStorePo> resourceStores = resourceStoreServiceSMOImpl.getResourceStores(resourceStorePo);
            Assert.listOnlyOne(resourceStores, "资源物品信息错误");
            //获取库存数量
            int resourceStoreStock = Integer.parseInt(resourceStores.get(0).getStock());
            //获取调拨的数量
            int storehouseStock = Integer.parseInt(allocationStorehousePo.getStock());
            //库存数量
            int stock = resourceStoreStock + storehouseStock;
            resourceStorePo.setStock(String.valueOf(stock));
            super.update(dataFlowContext, resourceStorePo, BusinessTypeConstant.BUSINESS_TYPE_UPDATE_RESOURCE_STORE);
        }
        AllocationStorehouseApplyPo allocationStorehouseApplyPo = new AllocationStorehouseApplyPo();
        allocationStorehouseApplyPo.setApplyId(allocationStorehouseDto.getApplyId());
        allocationStorehouseApplyPo.setStoreId(allocationStorehouseDto.getStoreId());
        super.update(dataFlowContext, allocationStorehouseApplyPo, BusinessTypeConstant.BUSINESS_TYPE_DELETE_ALLOCATION_STOREHOUSE_APPLY);
    }
}