| | |
| | | package com.gkhy.hazmat.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.common.config.IdTableNameHandler; |
| | | import com.gkhy.hazmat.common.domain.entity.SysUser; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | @Autowired |
| | | private HzWarehouseMapper warehouseMapper; |
| | | |
| | | |
| | | @Override |
| | | public CommonPage selectHazmatList(HzHazmat hzHazmat) { |
| | | if(hzHazmat.getWarehouseId()==null||hzHazmat.getBasicId()==null){ |
| | |
| | | } |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(null,currentUser); |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | hzHazmat.setCompanyId(currentUser.getCompanyId()); |
| | | if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){ |
| | | IdTableNameHandler.setCurrentId(hzHazmat.getCompanyId()); |
| | | }else { |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | hzHazmat.setCompanyId(currentUser.getCompanyId()); |
| | | } |
| | | PageUtils.startPage(); |
| | | List<HzHazmat> hazmatList = baseMapper.selectHazmatList(hzHazmat); |
| | | IdTableNameHandler.removeCurrentId(); |
| | |
| | | public CommonPage selectHazmatGroupWarehouse(HzHazmat hzHazmat) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |
| | | checkUserAllowed(null,currentUser); |
| | | hzHazmat.setCompanyId(currentUser.getCompanyId()); |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | if (currentUser.getUserType().equals(UserTypeEnum.CHECK_USER.getCode())){ |
| | | IdTableNameHandler.setCurrentId(hzHazmat.getCompanyId()); |
| | | }else { |
| | | hzHazmat.setCompanyId(currentUser.getCompanyId()); |
| | | //设置分表id |
| | | //todo |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | } |
| | | PageUtils.startPage(); |
| | | List<HzHazmatWarehouseVO> hazmatList = baseMapper.selectHazmatGroupWareHouse(hzHazmat); |
| | | if(!hazmatList.isEmpty()) { |
| | | List<Long> warehouseIds = hazmatList.stream().map(HzHazmatWarehouseVO::getWarehouseId).collect(Collectors.toList()); |
| | | List<Long> basicIds = hazmatList.stream().map(HzHazmatWarehouseVO::getBasicId).collect(Collectors.toList()); |
| | | List<Integer> cupboardIds = hazmatList.stream().map(HzHazmatWarehouseVO::getCupboardId).collect(Collectors.toList()); |
| | | List<HzHazmatBasic> hazmatBasicList = hazmatBasicMapper.selectHazmatBasicListByIds(basicIds); |
| | | List<HzWarehouse> warehouseList = warehouseMapper.selectWarehouseListByIds(warehouseIds); |
| | | List<HzWarehouseCupboard> hzWarehouseCupboards = warehouseMapper.selectByCupboardIds(cupboardIds); |
| | | |
| | | Map<Long,HzHazmatBasic> hazmatBasicMap=hazmatBasicList.stream().collect(Collectors.toMap(HzHazmatBasic::getId, item->item)); |
| | | Map<Long,HzWarehouse> warehouseMap=warehouseList.stream().collect(Collectors.toMap(HzWarehouse::getId, item->item)); |
| | | Map<Integer, HzWarehouseCupboard> cupboardMap = hzWarehouseCupboards.stream().collect(Collectors.toMap(HzWarehouseCupboard::getId, item -> item)); |
| | | for(HzHazmatWarehouseVO hazmatWarehouseVO:hazmatList){ |
| | | HzHazmatBasic hazmatBasic=hazmatBasicMap.get(hazmatWarehouseVO.getBasicId()); |
| | | HzWarehouse warehouse=warehouseMap.get(hazmatWarehouseVO.getWarehouseId()); |
| | | HzWarehouseCupboard hzWarehouseCupboard = cupboardMap.get(hazmatWarehouseVO.getCupboardId()); |
| | | if(hazmatBasic!=null){ |
| | | hazmatWarehouseVO.setHazmatBasic(hazmatBasic); |
| | | } |
| | | if(warehouse!=null){ |
| | | hazmatWarehouseVO.setWarehouseName(warehouse.getName()); |
| | | } |
| | | if (hzWarehouseCupboard != null){ |
| | | hazmatWarehouseVO.setCupboardName(hzWarehouseCupboard.getCupboardName()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | IdTableNameHandler.removeCurrentId(); |
| | |
| | | } |
| | | checkUserAllowed(hazmat,currentUser); |
| | | //获取变动前仓库库存 |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId()); |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId(),hazmat.getCupboardId()); |
| | | |
| | | //生成流向 |
| | | BigDecimal remaining=hazmat.getRemaining(); |
| | |
| | | HzWarehouseRecord warehouseRecord = new HzWarehouseRecord() |
| | | .setWarehouseId(hazmat.getWarehouseId()) |
| | | .setBasicId(hazmat.getBasicId()) |
| | | .setCupboardId(hazmat.getCupboardId()) |
| | | .setCreateId(currentUser.getId()) |
| | | .setNum(-1) |
| | | .setState(OperateStatusEnum.USING.getCode()) |
| | |
| | | } |
| | | checkUserAllowed(dbhazmat,currentUser); |
| | | //获取变动前仓库库存 |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(dbhazmat.getWarehouseId(), dbhazmat.getBasicId(), currentUser.getCompanyId()); |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(dbhazmat.getWarehouseId(), dbhazmat.getBasicId(), currentUser.getCompanyId(),dbhazmat.getCupboardId()); |
| | | hazmat.setState(HazmatStatusEnum.USEWAREHOUSEIN.getCode()); |
| | | hazmat.setUpdateBy(currentUser.getUsername()); |
| | | updateById(hazmat); |
| | |
| | | HzWarehouseRecord warehouseRecord = new HzWarehouseRecord() |
| | | .setWarehouseId(dbhazmat.getWarehouseId()) |
| | | .setBasicId(dbhazmat.getBasicId()) |
| | | .setCupboardId(hazmat.getCupboardId()) |
| | | .setCreateId(currentUser.getId()) |
| | | .setNum(1) |
| | | .setState(OperateStatusEnum.RETURN.getCode()) |
| | |
| | | } |
| | | checkUserAllowed(hazmat,currentUser); |
| | | //获取变动前仓库库存 |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId()); |
| | | int count = baseMapper.selectHazmatCountOfWarehouse(hazmat.getWarehouseId(), hazmat.getBasicId(), currentUser.getCompanyId(),hazmat.getCupboardId()); |
| | | hazmat.setState(HazmatStatusEnum.DISCARD.getCode()); |
| | | hazmat.setUpdateBy(currentUser.getUsername()); |
| | | updateById(hazmat); |
| | |
| | | HzWarehouseRecord warehouseRecord = new HzWarehouseRecord() |
| | | .setWarehouseId(hazmat.getWarehouseId()) |
| | | .setBasicId(hazmat.getBasicId()) |
| | | .setCupboardId(hazmat.getCupboardId()) |
| | | .setCreateId(currentUser.getId()) |
| | | .setNum(-1) |
| | | .setState(OperateStatusEnum.DISCARD.getCode()) |