| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.param.ContainerParams; |
| | | import com.zy.asrs.enums.CommonEnum; |
| | | import com.zy.asrs.enums.ContainerType; |
| | | import com.zy.asrs.mapper.BasContainerMapper; |
| | | import com.zy.asrs.entity.BasContainer; |
| | | import com.zy.asrs.service.BasContainerService; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import org.apache.tika.utils.StringUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.awt.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service("basContainerService") |
| | | public class BasContainerServiceImpl extends ServiceImpl<BasContainerMapper, BasContainer> implements BasContainerService { |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/9/26 |
| | | * @description: 容器初始化 |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R init(ContainerParams container) { |
| | | Integer length = 7; |
| | | if (Objects.isNull(container.getType())) { |
| | | throw new CoolException("容器类型不能为空!"); |
| | | } |
| | | if (!Objects.isNull(container.getLength())) { |
| | | length = container.getLength(); |
| | | } |
| | | if (!Objects.isNull(container.getFlagInit()) && container.getFlagInit().equals(CommonEnum.COMMON_ENUM_Y.type)) { |
| | | this.delete(new EntityWrapper<>()); |
| | | } |
| | | for (int i = container.getStart(); i <= container.getEnd(); i++) { |
| | | BasContainer basContainer = new BasContainer(); |
| | | String prefix = "", ruleCode = ""; |
| | | if (container.getType().equals(ContainerType.CONTAINER_TYPE_BOX.type)) { |
| | | prefix = "LX2"; |
| | | basContainer.setMixMax(3); |
| | | } else if (container.getType().equals(ContainerType.CONTAINER_TYPE_CAGE.type)) { |
| | | prefix = "LK3"; |
| | | basContainer.setMixMax(2); |
| | | } else if (container.getType().equals(ContainerType.CONTAINER_TYPE_SALVER.type)) { |
| | | prefix = "TP4"; |
| | | basContainer.setMixMax(2); |
| | | } |
| | | ruleCode = prefix + StringUtils.leftPad(i + "", length, "0"); |
| | | basContainer.setType(container.getType()) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateTime(new Date()) |
| | | .setId(null) |
| | | .setFlagMix(1) |
| | | .setBarcode(ruleCode); |
| | | if (!this.insert(basContainer)) { |
| | | throw new CoolException("容器保存失败!!"); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |