- 在 WmsSchedulePlan 和 WmsSchedulePlanBo 类中添加 startDate 和 endDate 字段 - 更新相关服务方法,支持新增的计划开始日期和结束日期功能 - 注释掉查询排产计划总的开始结束时间的代码块
139 lines
4.6 KiB
Java
139 lines
4.6 KiB
Java
package com.klp.service.impl;
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
import com.klp.common.core.domain.PageQuery;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import com.klp.common.utils.StringUtils;
|
|
import com.klp.domain.vo.PlanTimeAgg;
|
|
import com.klp.mapper.WmsSchedulePlanDetailMapper;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import com.klp.domain.bo.WmsSchedulePlanBo;
|
|
import com.klp.domain.vo.WmsSchedulePlanVo;
|
|
import com.klp.domain.WmsSchedulePlan;
|
|
import com.klp.mapper.WmsSchedulePlanMapper;
|
|
import com.klp.service.IWmsSchedulePlanService;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Collection;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* 排产计划Service业务层处理
|
|
*
|
|
* @author JR
|
|
* @date 2025-07-18
|
|
*/
|
|
@RequiredArgsConstructor
|
|
@Service
|
|
public class WmsSchedulePlanServiceImpl implements IWmsSchedulePlanService {
|
|
|
|
private final WmsSchedulePlanMapper baseMapper;
|
|
|
|
@Resource
|
|
private WmsSchedulePlanDetailMapper wmsSchedulePlanDetailMapper;
|
|
|
|
/**
|
|
* 查询排产计划
|
|
*/
|
|
@Override
|
|
public WmsSchedulePlanVo queryById(Long planId){
|
|
return baseMapper.selectVoById(planId);
|
|
}
|
|
|
|
/**
|
|
* 查询排产计划列表
|
|
*/
|
|
@Override
|
|
public TableDataInfo<WmsSchedulePlanVo> queryPageList(WmsSchedulePlanBo bo, PageQuery pageQuery) {
|
|
LambdaQueryWrapper<WmsSchedulePlan> lqw = buildQueryWrapper(bo);
|
|
Page<WmsSchedulePlanVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
/*// 查排产计划总的开始结束时间
|
|
// 获取所有planId
|
|
List<Long> planIds = result.getRecords().stream()
|
|
.map(WmsSchedulePlanVo::getPlanId)
|
|
.collect(Collectors.toList());
|
|
if (!planIds.isEmpty()) {
|
|
// 查询详情表的最早/最晚时间
|
|
List<PlanTimeAgg> aggList = wmsSchedulePlanDetailMapper.selectPlanTimeAgg(planIds);
|
|
Map<Long, PlanTimeAgg> aggMap = aggList.stream()
|
|
.collect(Collectors.toMap(PlanTimeAgg::getPlanId, Function.identity()));
|
|
// 填充到VO
|
|
for (WmsSchedulePlanVo vo : result.getRecords()) {
|
|
PlanTimeAgg agg = aggMap.get(vo.getPlanId());
|
|
if (agg != null) {
|
|
vo.setStartDate(agg.getStartDate());
|
|
vo.setEndDate(agg.getEndDate());
|
|
}
|
|
}
|
|
}*/
|
|
return TableDataInfo.build(result);
|
|
}
|
|
|
|
/**
|
|
* 查询排产计划列表
|
|
*/
|
|
@Override
|
|
public List<WmsSchedulePlanVo> queryList(WmsSchedulePlanBo bo) {
|
|
LambdaQueryWrapper<WmsSchedulePlan> lqw = buildQueryWrapper(bo);
|
|
return baseMapper.selectVoList(lqw);
|
|
}
|
|
|
|
private LambdaQueryWrapper<WmsSchedulePlan> buildQueryWrapper(WmsSchedulePlanBo bo) {
|
|
Map<String, Object> params = bo.getParams();
|
|
LambdaQueryWrapper<WmsSchedulePlan> lqw = Wrappers.lambdaQuery();
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlanCode()), WmsSchedulePlan::getPlanCode, bo.getPlanCode());
|
|
lqw.eq(bo.getOrderId() != null, WmsSchedulePlan::getOrderId, bo.getOrderId());
|
|
lqw.eq(bo.getStatus() != null, WmsSchedulePlan::getStatus, bo.getStatus());
|
|
return lqw;
|
|
}
|
|
|
|
/**
|
|
* 新增排产计划
|
|
*/
|
|
@Override
|
|
public Boolean insertByBo(WmsSchedulePlanBo bo) {
|
|
WmsSchedulePlan add = BeanUtil.toBean(bo, WmsSchedulePlan.class);
|
|
validEntityBeforeSave(add);
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
if (flag) {
|
|
bo.setPlanId(add.getPlanId());
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
/**
|
|
* 修改排产计划
|
|
*/
|
|
@Override
|
|
public Boolean updateByBo(WmsSchedulePlanBo bo) {
|
|
WmsSchedulePlan update = BeanUtil.toBean(bo, WmsSchedulePlan.class);
|
|
validEntityBeforeSave(update);
|
|
return baseMapper.updateById(update) > 0;
|
|
}
|
|
|
|
/**
|
|
* 保存前的数据校验
|
|
*/
|
|
private void validEntityBeforeSave(WmsSchedulePlan entity){
|
|
//TODO 做一些数据校验,如唯一约束
|
|
}
|
|
|
|
/**
|
|
* 批量删除排产计划
|
|
*/
|
|
@Override
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
if(isValid){
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|
}
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
}
|
|
}
|