| | |
| | | |
| | | import cn.hutool.core.date.DatePattern; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.hazmat.common.api.CommonPage; |
| | | import com.gkhy.hazmat.common.config.IdTableNameHandler; |
| | | import com.gkhy.hazmat.common.constant.Constant; |
| | | import com.gkhy.hazmat.common.domain.entity.SysUser; |
| | | import com.gkhy.hazmat.common.enums.CodePrexEnum; |
| | | import com.gkhy.hazmat.common.enums.EntryStateEnum; |
| | |
| | | import com.gkhy.hazmat.common.enums.UserTypeEnum; |
| | | import com.gkhy.hazmat.common.exception.ApiException; |
| | | import com.gkhy.hazmat.common.listener.CustomEventPublisher; |
| | | import com.gkhy.hazmat.common.service.RedisService; |
| | | import com.gkhy.hazmat.common.utils.PageUtils; |
| | | import com.gkhy.hazmat.common.utils.SecurityUtils; |
| | | import com.gkhy.hazmat.common.utils.StringUtils; |
| | | import com.gkhy.hazmat.system.domain.*; |
| | | import com.gkhy.hazmat.system.domain.vo.TabooDisVo; |
| | | import com.gkhy.hazmat.system.mapper.*; |
| | | import com.gkhy.hazmat.system.service.HzEntryRecordService; |
| | | import com.gkhy.hazmat.system.service.HzHazmatService; |
| | | import com.gkhy.hazmat.system.service.TabooWarningService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.transaction.support.TransactionSynchronization; |
| | | import org.springframework.transaction.support.TransactionSynchronizationManager; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | private CustomEventPublisher customEventPublisher; |
| | | @Autowired |
| | | private SysCompanyMapper companyMapper; |
| | | @Autowired |
| | | private RedisService redisService; |
| | | // @Autowired |
| | | // private TabooWarningService tabooWarningService; |
| | | |
| | | @Autowired |
| | | private HzTabooWarningMapper tabooWarningMapper; |
| | | |
| | | @Override |
| | | public CommonPage selectEntryRecordList(HzEntryRecord entryRecord) { |
| | |
| | | throw new ApiException("危化品基础数据不存在"); |
| | | } |
| | | |
| | | |
| | | // synchronized (this) { |
| | | //获取当前仓库库存 |
| | | //设置分表id |
| | | IdTableNameHandler.setCurrentId(currentUser.getCompanyId()); |
| | | int count = hazmatMapper.selectHazmatCountOfWarehouse(entryRecord.getWarehouseId(), hazmatBasic.getId(), currentUser.getCompanyId()); |
| | | int count = hazmatMapper.selectHazmatCountOfWarehouse(entryRecord.getWarehouseId(), hazmatBasic.getId(), currentUser.getCompanyId(), entryRecord.getCupboardId()); |
| | | //新增危化品变动记录 |
| | | HzWarehouseRecord warehouseRecord = new HzWarehouseRecord() |
| | | .setWarehouseId(entryRecord.getWarehouseId()) |
| | |
| | | .setCreateId(currentUser.getId()) |
| | | .setRemaining(entryRecord.getNum() + count); |
| | | warehouseRecordMapper.insert(warehouseRecord); |
| | | int startCode=entryRecord.getStartCode(); |
| | | // 校验生成相忌数据 |
| | | Map<String, Long> redata = (Map<String, Long>)redisService.get(Constant.TABOO_UNIQUE_KEY); |
| | | if (!redata.isEmpty()){ |
| | | // 查询对应仓库和柜子的物品信息获取品类 获取相冲相弱相吸相异 |
| | | List<TabooDisVo> collectData = |
| | | hazmatMapper.selectHazmatWarehouseCheck(entryRecord.getWarehouseId(), currentUser.getCompanyId(), entryRecord.getCupboardId()); |
| | | if (!collectData.isEmpty() && collectData.size() > 0) { |
| | | for (TabooDisVo collectDatum : collectData) { |
| | | String key1 = collectDatum.getSpNum() + "_" + hazmatBasic.getPeculiarityNumber(); |
| | | String key2 = hazmatBasic.getPeculiarityNumber() + "_" + collectDatum.getSpNum(); |
| | | |
| | | if (redata.containsKey(key1) || redata.containsKey(key2)) { |
| | | // 记录数据 |
| | | Long l = redata.get(key1); |
| | | Long l1 = l == null ? redata.get(key2) : l; |
| | | HzTabooWarning tabooWarning = new HzTabooWarning() |
| | | .setWarningType(l1) |
| | | .setWarehouseId(entryRecord.getWarehouseId()) |
| | | .setCupboardId(entryRecord.getCupboardId()) |
| | | .setEntryId(entryRecord.getId()) |
| | | .setCompanyId(currentUser.getCompanyId()) |
| | | .setTabooBasicId(collectDatum.getId()).setCreateBy(currentUser.getUsername()); |
| | | tabooWarningMapper.insert(tabooWarning); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // if (null != collectData) { |
| | | // Iterator<Map.Entry<String, Integer>> iterator = collectData.entrySet().iterator(); |
| | | // while (iterator.hasNext()) { |
| | | // Map.Entry<String, Integer> entry = iterator.next(); |
| | | // String key = entry.getKey(); |
| | | // Integer value = entry.getValue(); |
| | | // Integer i = collectData.get(value); |
| | | // String key1 = value + "_" + hazmatBasic.getPeculiarityNumber(); |
| | | // String key2 = hazmatBasic.getPeculiarityNumber() + "_" + value; |
| | | // |
| | | // if (redata.containsKey(key1) || redata.containsKey(key2)) { |
| | | // // 记录数据 |
| | | // Long l = redata.get(key1); |
| | | // Long l1 = l == null ? redata.get(key2) : l; |
| | | // HzTabooWarning tabooWarning = new HzTabooWarning() |
| | | // .setWarningType(l1) |
| | | // .setEntryId(entryRecord.getId()) |
| | | // .setCompanyId(currentUser.getCompanyId()) |
| | | // .setTabooBasicId(i.longValue()).setCreateBy(currentUser.getUsername()); |
| | | // tabooWarningMapper.insert(tabooWarning); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | }else { |
| | | throw new ApiException("危化品相忌信息不存在"); |
| | | } |
| | | int startCode=entryRecord.getStartCode(); |
| | | int endCode=entryRecord.getEndCode(); |
| | | List<HzHazmat> hazmatList = new ArrayList<>(); |
| | | for (int i = startCode; i <=endCode; i++) { |
| | |
| | | hazmatList.add(new HzHazmat().setWarehouseId(entryRecord.getWarehouseId()) |
| | | .setCupboardId(entryRecord.getCupboardId()) |
| | | .setBasicId(entryRecord.getBasicId()) |
| | | .setCupboardId(entryRecord.getCupboardId()) |
| | | .setEntryId(entryRecord.getId()) |
| | | .setRemaining(hazmatBasic.getMetering()) |
| | | .setCompanyId(currentUser.getCompanyId()) |
| | |
| | | }); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public int updateEntryRecord(HzEntryRecord entryRecord) { |
| | | SysUser currentUser = SecurityUtils.getLoginUser().getUser(); |