zhou zhou
1 天以前 1dcfa3702505f0c431757312b5304531029f90f6
rsf-server/src/main/java/com/vincent/rsf/server/manager/entity/BasContainer.java
@@ -6,17 +6,16 @@
import java.util.Date;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.vincent.rsf.server.manager.utils.AreasDeserializer;
import com.vincent.rsf.server.manager.utils.AreasSerializer;
import com.vincent.rsf.server.manager.utils.AreasTypeHandler;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.vincent.rsf.server.system.entity.DictData;
import com.vincent.rsf.server.system.service.DictDataService;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableLogic;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.vincent.rsf.framework.common.Cools;
@@ -24,8 +23,10 @@
import com.vincent.rsf.server.system.service.UserService;
import com.vincent.rsf.server.system.entity.User;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.stream.Collectors;
@Data
@Accessors(chain = true)
@@ -51,17 +52,20 @@
    private Long containerType;
    /**
     * 容器条码类型
     * 容器条码规则
     */
    @ApiModelProperty(value = "容器条码类型")
    @ApiModelProperty(value = "容器条码规则")
    private String codeType;
    /**
     * 可入库区
     * 可入库区(包含排序信息)
     * 格式: [{"id": 1, "sort": 1}, {"id": 2, "sort": 2}]
     */
    @ApiModelProperty(value = "可入库区")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<Integer> areas;
    @ApiModelProperty(value = "可入库区(包含排序信息)")
    @TableField(typeHandler = AreasTypeHandler.class)
    @JsonDeserialize(using = AreasDeserializer.class)
    @JsonSerialize(using = AreasSerializer.class)
    private List<Map<String, Object>> areas;
    /**
     * 是否删除 1: 是 0: 否
@@ -87,6 +91,9 @@
    @ApiModelProperty(value = "添加人员")
    private Long createBy;
    @TableField(exist = false)
    private String createBy$;
    /**
     * 添加时间
     */
@@ -100,6 +107,9 @@
    @ApiModelProperty(value = "修改人员")
    private Long updateBy;
    @TableField(exist = false)
    private String updateBy$;
    /**
     * 修改时间
     */
@@ -112,13 +122,17 @@
     */
    @ApiModelProperty(value = "备注")
    private String memo;
    @TableField(exist = false)
    private String containerType$;
    public BasContainer() {
    }
    public BasContainer(Long containerType, String codeType, List<Integer> areas, Integer deleted, Integer status,
    public BasContainer(Long containerType, String codeType, List<Map<String, Object>> areas, Integer deleted, Integer status,
            Integer tenantId, Long createBy, Date createTime, Long updateBy, Date updateTime, String memo) {
        this.containerType = containerType;
        this.codeType = codeType;
@@ -148,26 +162,7 @@
//    );
    public String getContainerType$(){
        if (Cools.isEmpty(this.containerType)){
            return "";
        }
        DictDataService service = SpringUtils.getBean(DictDataService.class);
        DictData dictData = service.getOne(new LambdaQueryWrapper<DictData>()
                .eq(DictData::getDictTypeCode, "sys_container_type")
                .eq(DictData::getValue, this.containerType));
        if (!Cools.isEmpty(dictData)) {
            return String.valueOf(dictData.getLabel());
        }
        return "";
    }
    public String getCreateBy$() {
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.getById(this.createBy);
        if (!Cools.isEmpty(user)) {
            return String.valueOf(user.getNickname());
        }
        return null;
        return this.containerType$;
    }
    public String getCreateTime$() {
@@ -175,15 +170,6 @@
            return "";
        }
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime);
    }
    public String getUpdateBy$() {
        UserService service = SpringUtils.getBean(UserService.class);
        User user = service.getById(this.updateBy);
        if (!Cools.isEmpty(user)) {
            return String.valueOf(user.getNickname());
        }
        return null;
    }
    public String getUpdateTime$() {
@@ -207,4 +193,42 @@
        }
    }
    /**
     * 获取排序后的库区ID列表(向后兼容方法)
     * @return 排序后的库区ID列表
     */
    public List<Integer> getAreasIds() {
        if (Cools.isEmpty(this.areas)) {
            return new ArrayList<>();
        }
        return this.areas.stream()
                .sorted((a, b) -> {
                    Integer sortA = a.get("sort") != null ? ((Number) a.get("sort")).intValue() : Integer.MAX_VALUE;
                    Integer sortB = b.get("sort") != null ? ((Number) b.get("sort")).intValue() : Integer.MAX_VALUE;
                    return sortA.compareTo(sortB);
                })
                .map(area -> {
                    Object id = area.get("id");
                    if (id instanceof Number) {
                        return ((Number) id).intValue();
                    }
                    return null;
                })
                .filter(id -> id != null)
                .collect(Collectors.toList());
    }
    /**
     * 对areas按sort字段进行排序
     */
    public void sortAreas() {
        if (this.areas != null && !this.areas.isEmpty()) {
            this.areas.sort((a, b) -> {
                Integer sortA = a.get("sort") != null ? ((Number) a.get("sort")).intValue() : Integer.MAX_VALUE;
                Integer sortB = b.get("sort") != null ? ((Number) b.get("sort")).intValue() : Integer.MAX_VALUE;
                return sortA.compareTo(sortB);
            });
        }
    }
}