“djh”
6 days ago d30017df796e4e4aef20f320f3c27d90ba8cbeff
hazmat-system/src/main/java/com/gkhy/hazmat/system/service/impl/HzHazmatServiceImpl.java
@@ -7,6 +7,7 @@
import com.github.pagehelper.PageHelper;
import com.gkhy.hazmat.common.api.CommonPage;
//import com.gkhy.hazmat.common.config.IdTableNameHandler;
import com.gkhy.hazmat.common.api.CommonResult;
import com.gkhy.hazmat.common.domain.entity.SysUser;
import com.gkhy.hazmat.common.enums.CodePrexEnum;
import com.gkhy.hazmat.common.enums.HazmatStatusEnum;
@@ -16,6 +17,8 @@
import com.gkhy.hazmat.common.utils.PageUtils;
import com.gkhy.hazmat.common.utils.SecurityUtils;
import com.gkhy.hazmat.system.domain.*;
import com.gkhy.hazmat.system.domain.dto.HazmatDto;
import com.gkhy.hazmat.system.domain.vo.HzHazmatOrder;
import com.gkhy.hazmat.system.domain.vo.HzHazmatWarehouseVO;
import com.gkhy.hazmat.system.mapper.*;
import com.gkhy.hazmat.system.service.HzHazmatService;
@@ -24,10 +27,7 @@
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;
import java.util.*;
import java.util.stream.Collectors;
/**
@@ -49,6 +49,15 @@
    private HzHazmatBasicMapper hazmatBasicMapper;
    @Autowired
    private HzWarehouseMapper warehouseMapper;
    @Autowired
    private SubscribeMapper subscribeMapper;
    @Autowired
    private HzEntryRecordMapper hzEntryRecordMapper;
    @Autowired
    private SysUserMapper sysUserMapper;
    @Override
@@ -327,6 +336,7 @@
        hazmatFlow.setState(OperateStatusEnum.DISCARD.getCode());
        hazmatFlow.setCompanyId(currentUser.getCompanyId());
        hazmatFlow.setNum(hazmat.getRemaining().multiply(BigDecimal.valueOf(-1)));
        hazmatFlow.setConsumption(hazmat.getRemaining());
        hazmatFlow.setCreateId(currentUser.getId());
        hazmatFlowMapper.insert(hazmatFlow);
@@ -396,6 +406,38 @@
//        IdTableNameHandler.removeCurrentId();
    }
    @Override
    public List<HzHazmatOrder> selectByWarehouseAndCupboard(HazmatDto hazmatDto) {
//        if (hazmatDto.getCabinetId() == null || hazmatDto.getAuxiliaryCabinetId() == null) {
//            throw new ApiException("仓库id和存储柜id不能为空");
//        }
        List<HzHazmatOrder> orders = new ArrayList<>();
        List<HzHazmat> hzHazmats = baseMapper.selectByWarehouseAndCupboard(hazmatDto);
        for (HzHazmat hzHazmat : hzHazmats) {
            HzHazmatOrder hzHazmatOrder = new HzHazmatOrder();
            HzEntryRecord hzEntryRecord = hzEntryRecordMapper.selectById(hzHazmat.getEntryId());
            Subscribe subscribes = subscribeMapper.selectBySubscribeNum(hzEntryRecord.getSubscribeNum());
            HzHazmatBasic hzHazmatBasic = hazmatBasicMapper.selectById(hzHazmat.getBasicId());
            SysUser sysuer = sysUserMapper.getUserById(subscribes.getSubscribePersonId());
            hzHazmatOrder.setHzhazmatId(hzHazmat.getId());
            hzHazmatOrder.setCabinetId(hazmatDto.getCabinetId());
            hzHazmatOrder.setAuxiliaryCabinetId(hazmatDto.getAuxiliaryCabinetId());
            hzHazmatOrder.setSubscribeNum(subscribes.getSubscribeNum());
            hzHazmatOrder.setCas(hzHazmatBasic.getCas());
            hzHazmatOrder.setStandard(hzHazmatBasic.getHazmatFormat());
            hzHazmatOrder.setRemaining(hzHazmat.getRemaining());
            hzHazmatOrder.setProductSn(hzHazmatBasic.getProductSn());
            hzHazmatOrder.setSubscribePersonName(subscribes.getSubscribePersonName());
            hzHazmatOrder.setOfDept(sysuer.getDepartName());
            orders.add(hzHazmatOrder);
        }
        return orders;
    }
    public void checkUserAllowed(HzHazmat hazmat,SysUser user) {
        if (user.getUserType().equals(UserTypeEnum.SYSTEM_USER.getCode())) {
            throw new ApiException("管理员不能操作");