系统配置:自定义板编号处理类分页查询补充

This commit is contained in:
gaoqr
2025-01-10 10:59:01 +08:00
parent 7138811b63
commit 1414ef5291
@@ -10,6 +10,7 @@ import com.cf.imes.framework.common.enums.CommonStatusEnum;
import com.cf.imes.framework.common.exception.ErrorCode;
import com.cf.imes.framework.common.exception.ServiceException;
import com.cf.imes.framework.common.exception.util.ServiceExceptionUtil;
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigDeleteReqVO;
import com.cf.imes.module.system.controller.admin.systemconfig.vo.ConfigPageReqVO;
@@ -33,6 +34,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -78,7 +80,26 @@ public class CustomPlateNoServiceHandler extends AbstractSystemConfigServiceHand
@Override
public List<SystemConfigDO> selectList(ConfigPageReqVO pageReqVO) {
return null;
SystemConfigTypeEnum customPlateNoEnum = SystemConfigTypeEnum.CUSTOM_PLATE_NO;
List<SystemConfigDO> systemConfigDOS = systemConfigMapper.selectList(new LambdaQueryWrapperX<SystemConfigDO>()
.eq(SystemConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
.eq(SystemConfigDO::getType, pageReqVO.getType())
.eqIfPresent(SystemConfigDO::getOrganId, OrganContextHolder.getOrganId())
.select(SystemConfigDO::getId, SystemConfigDO::getName, SystemConfigDO::getStatus, SystemConfigDO::getType)
.orderByAsc(SystemConfigDO::getId));
if (systemConfigDOS.isEmpty()) {
SystemConfigDO initCustomPlateNoConfig = new SystemConfigDO().builder().id(null).name(customPlateNoEnum.getName()).type(customPlateNoEnum.getType()).build();
return List.of(initCustomPlateNoConfig);
} else {
// configDOPageResult下的自定义板编号配置只保留version最大的一项
Optional<SystemConfigDO> maxVersionCustPlateNoConfigOptinal = systemConfigDOS.stream()
.filter(s -> ObjectUtil.equal(customPlateNoEnum.getType(), s.getType()))
.max(Comparator.comparing(SystemConfigDO::getVersion));
if (maxVersionCustPlateNoConfigOptinal.isPresent()) {
systemConfigDOS.removeIf(s -> ObjectUtil.equal(customPlateNoEnum.getType(), s.getType()) && ObjectUtil.notEqual(s.getId(), maxVersionCustPlateNoConfigOptinal.get().getId()));
}
return systemConfigDOS;
}
}
@Override