feat(smartfactory): 作为工厂主管查询搬运工时支持多工厂查询

- 在 HandlingGroupAmountSpecificationsTotalNumDTO 和 HandlingGroupAmountSpecificationsPageReqVO 中添加 factoryIds 字段
- 修改 HandlingGroupAmountSpecificationsServiceImpl 中的方法以支持多工厂查询
- 更新 HandlingGroupAmountSpecificationsMapper.xml 中的 SQL 语句以支持多工厂查询
This commit is contained in:
aikai 2025-05-19 09:28:40 +08:00
parent a4fba15a4a
commit bb49e919cb
4 changed files with 29 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -23,4 +24,6 @@ public class HandlingGroupAmountSpecificationsTotalNumDTO {
@Schema(description = "创建时间") @Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "工厂ids")
private List<Long> factoryIds;
} }

View File

@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ -47,4 +48,7 @@ public class HandlingGroupAmountSpecificationsPageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime; private LocalDateTime[] createTime;
@Schema(description = "工厂ids", example = "23178")
private List<Long> factoryIds;
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications; package cn.iocoder.yudao.module.smartfactory.service.handlinggroupamountspecifications;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils; import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupListVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroup.vo.HandlingGroupListVO;
@ -64,11 +65,10 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) { public PageResult<HandlingGroupAmountSpecificationsDO> getHandlingGroupAmountSpecificationsPage(HandlingGroupAmountSpecificationsPageReqVO pageReqVO) {
// 判断当前登录人是否属于工厂主管 // 判断当前登录人是否属于工厂主管
AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData(); AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData();
DeptRespDTO deptRespDTO = deptApi.getDept(userRespDTO.getDeptId()).getCheckedData(); List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(userRespDTO.getDeptId()).getCheckedData();
if (deptRespDTO.getFactoryId() != null) { if (CollUtil.isNotEmpty(deptRespDTOS)) {
pageReqVO.setFactoryId(deptRespDTO.getFactoryId()); pageReqVO.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
} }
IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO); IPage<HandlingGroupAmountSpecificationsDO> pageResult = handlingGroupAmountSpecificationsMapper.getHandlingGroupAmountSpecificationsPage(MyBatisUtils.buildPage(pageReqVO), pageReqVO);
return new PageResult<>(pageResult.getRecords(), pageResult.getTotal()); return new PageResult<>(pageResult.getRecords(), pageResult.getTotal());
} }
@ -160,6 +160,12 @@ public class HandlingGroupAmountSpecificationsServiceImpl implements HandlingGro
@Override @Override
public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) { public HandlingGroupAmountSpecificationsTotalNumVO getTotalNum(HandlingGroupAmountSpecificationsTotalNumDTO dto) {
// 判断当前登录人是否属于工厂主管
AdminUserRespDTO userRespDTO = userApi.getUser(getLoginUserId()).getCheckedData();
List<DeptRespDTO> deptRespDTOS = deptApi.getDeptByLeaderId(userRespDTO.getDeptId()).getCheckedData();
if (CollUtil.isNotEmpty(deptRespDTOS)) {
dto.setFactoryIds(deptRespDTOS.stream().map(DeptRespDTO::getFactoryId).distinct().collect(Collectors.toList()));
}
return handlingGroupAmountSpecificationsMapper.getTotalNum(dto); return handlingGroupAmountSpecificationsMapper.getTotalNum(dto);
} }

View File

@ -40,6 +40,12 @@
<if test="vo.factoryId != null"> <if test="vo.factoryId != null">
AND a.factory_id = #{vo.factoryId} AND a.factory_id = #{vo.factoryId}
</if> </if>
<if test="vo.factoryIds != null and vo.factoryIds.size() > 0">
and a.factory_id in
<foreach collection="vo.factoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="vo.porterName != null and vo.porterName != ''"> <if test="vo.porterName != null and vo.porterName != ''">
and g.nick_name like concat('%', #{vo.porterName}, '%') and g.nick_name like concat('%', #{vo.porterName}, '%')
</if> </if>
@ -108,6 +114,12 @@
<if test="dto.factoryId != null"> <if test="dto.factoryId != null">
and a.factory_id = #{dto.factoryId} and a.factory_id = #{dto.factoryId}
</if> </if>
<if test="dto.factoryIds != null and dto.factoryIds.size() > 0">
and a.factory_id in
<foreach collection="dto.factoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="dto.handlingSpecificationsId != null"> <if test="dto.handlingSpecificationsId != null">
and a.handling_specifications_id = #{dto.handlingSpecificationsId} and a.handling_specifications_id = #{dto.handlingSpecificationsId}
</if> </if>