149 lines
5.6 KiB
Java
149 lines
5.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.bo.WmsMaterialCoilBo;
|
|||
|
|
import com.klp.domain.vo.WmsMaterialCoilVo;
|
|||
|
|
import lombok.RequiredArgsConstructor;
|
|||
|
|
import org.springframework.stereotype.Service;
|
|||
|
|
import com.klp.domain.bo.WmsDeliveryPlanCoilOperateBo;
|
|||
|
|
import com.klp.domain.vo.WmsDeliveryPlanCoilOperateVo;
|
|||
|
|
import com.klp.domain.WmsDeliveryPlanCoilOperate;
|
|||
|
|
import com.klp.mapper.WmsDeliveryPlanCoilOperateMapper;
|
|||
|
|
import com.klp.service.IWmsDeliveryPlanCoilOperateService;
|
|||
|
|
|
|||
|
|
import java.util.*;
|
|||
|
|
import java.util.stream.Collectors;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 发货计划钢卷操作记录Service业务层处理
|
|||
|
|
*
|
|||
|
|
* @author klp
|
|||
|
|
* @date 2025-12-17
|
|||
|
|
*/
|
|||
|
|
@RequiredArgsConstructor
|
|||
|
|
@Service
|
|||
|
|
public class WmsDeliveryPlanCoilOperateServiceImpl implements IWmsDeliveryPlanCoilOperateService {
|
|||
|
|
|
|||
|
|
private final WmsDeliveryPlanCoilOperateMapper baseMapper;
|
|||
|
|
|
|||
|
|
private WmsMaterialCoilServiceImpl materialCoilService;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询发货计划钢卷操作记录
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public WmsDeliveryPlanCoilOperateVo queryById(Long operateId){
|
|||
|
|
return baseMapper.selectVoById(operateId);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询发货计划钢卷操作记录列表
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public TableDataInfo<WmsDeliveryPlanCoilOperateVo> queryPageList(WmsDeliveryPlanCoilOperateBo bo, PageQuery pageQuery) {
|
|||
|
|
LambdaQueryWrapper<WmsDeliveryPlanCoilOperate> lqw = buildQueryWrapper(bo);
|
|||
|
|
Page<WmsDeliveryPlanCoilOperateVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|||
|
|
return TableDataInfo.build(result);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 查询发货计划钢卷操作记录列表
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public List<WmsDeliveryPlanCoilOperateVo> queryList(WmsDeliveryPlanCoilOperateBo bo) {
|
|||
|
|
LambdaQueryWrapper<WmsDeliveryPlanCoilOperate> lqw = buildQueryWrapper(bo);
|
|||
|
|
return baseMapper.selectVoList(lqw);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private LambdaQueryWrapper<WmsDeliveryPlanCoilOperate> buildQueryWrapper(WmsDeliveryPlanCoilOperateBo bo) {
|
|||
|
|
Map<String, Object> params = bo.getParams();
|
|||
|
|
LambdaQueryWrapper<WmsDeliveryPlanCoilOperate> lqw = Wrappers.lambdaQuery();
|
|||
|
|
lqw.eq(bo.getPlanId() != null, WmsDeliveryPlanCoilOperate::getPlanId, bo.getPlanId());
|
|||
|
|
lqw.eq(bo.getCoilId() != null, WmsDeliveryPlanCoilOperate::getCoilId, bo.getCoilId());
|
|||
|
|
lqw.eq(StringUtils.isNotBlank(bo.getOperateType()), WmsDeliveryPlanCoilOperate::getOperateType, bo.getOperateType());
|
|||
|
|
return lqw;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 新增发货计划钢卷操作记录
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public Boolean insertByBo(WmsDeliveryPlanCoilOperateBo bo) {
|
|||
|
|
WmsDeliveryPlanCoilOperate add = BeanUtil.toBean(bo, WmsDeliveryPlanCoilOperate.class);
|
|||
|
|
validEntityBeforeSave(add);
|
|||
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|||
|
|
if (flag) {
|
|||
|
|
bo.setOperateId(add.getOperateId());
|
|||
|
|
}
|
|||
|
|
return flag;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 修改发货计划钢卷操作记录
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public Boolean updateByBo(WmsDeliveryPlanCoilOperateBo bo) {
|
|||
|
|
WmsDeliveryPlanCoilOperate update = BeanUtil.toBean(bo, WmsDeliveryPlanCoilOperate.class);
|
|||
|
|
validEntityBeforeSave(update);
|
|||
|
|
return baseMapper.updateById(update) > 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 保存前的数据校验
|
|||
|
|
*/
|
|||
|
|
private void validEntityBeforeSave(WmsDeliveryPlanCoilOperate entity){
|
|||
|
|
//TODO 做一些数据校验,如唯一约束
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 批量删除发货计划钢卷操作记录
|
|||
|
|
*/
|
|||
|
|
@Override
|
|||
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|||
|
|
if(isValid){
|
|||
|
|
//TODO 做一些业务上的校验,判断是否需要校验
|
|||
|
|
}
|
|||
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
@Override
|
|||
|
|
public List<WmsDeliveryPlanCoilOperateVo> getCoilOperate(Long planId, String coilIds) {
|
|||
|
|
// 边界校验:空值/空字符串直接返回空列表
|
|||
|
|
if (planId == null || coilIds == null || coilIds.trim().isEmpty()) {
|
|||
|
|
return Collections.emptyList();
|
|||
|
|
}
|
|||
|
|
String[] coilIdArray = coilIds.split(",");
|
|||
|
|
// 过滤空字符串(避免split出""的情况,比如coilIds是",1002,")
|
|||
|
|
coilIdArray = Arrays.stream(coilIdArray)
|
|||
|
|
.filter(StringUtils::isNotBlank)
|
|||
|
|
.toArray(String[]::new);
|
|||
|
|
if (coilIdArray.length == 0) {
|
|||
|
|
return Collections.emptyList();
|
|||
|
|
}
|
|||
|
|
List<WmsDeliveryPlanCoilOperateVo> coilOperate = baseMapper.getCoilOperate(planId, coilIdArray);
|
|||
|
|
//接着就是根据钢卷ids去查询钢卷list了 用分页查询的list就需要设置分页参数都设置为最大即可
|
|||
|
|
WmsMaterialCoilBo bo = new WmsMaterialCoilBo();
|
|||
|
|
bo.setCoilIds(coilIds);
|
|||
|
|
PageQuery pageQuery = new PageQuery();
|
|||
|
|
pageQuery.setPageNum(1);
|
|||
|
|
pageQuery.setPageSize(Integer.MAX_VALUE);
|
|||
|
|
TableDataInfo<WmsMaterialCoilVo> tableDataInfo = materialCoilService.queryPageList(bo, pageQuery);
|
|||
|
|
List<WmsMaterialCoilVo> coilDetails = tableDataInfo.getRows();
|
|||
|
|
// 将钢卷详细信息设置到操作记录中
|
|||
|
|
Map<Long, WmsMaterialCoilVo> coilDetailMap = coilDetails.stream()
|
|||
|
|
.collect(Collectors.toMap(WmsMaterialCoilVo::getCoilId, coil -> coil));
|
|||
|
|
|
|||
|
|
for (WmsDeliveryPlanCoilOperateVo operate : coilOperate) {
|
|||
|
|
operate.setCoilDetail(coilDetailMap.get(operate.getCoilId()));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return coilOperate;
|
|||
|
|
}
|
|||
|
|
}
|