2025-12-17 13:58:04 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
2025-12-17 15:02:51 +08:00
|
|
|
|
private final WmsMaterialCoilServiceImpl materialCoilService;
|
2025-12-17 13:58:04 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询发货计划钢卷操作记录
|
|
|
|
|
|
*/
|
|
|
|
|
|
@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();
|
|
|
|
|
|
}
|
2025-12-17 15:33:39 +08:00
|
|
|
|
List<WmsDeliveryPlanCoilOperate> coilOperateList = baseMapper.getCoilOperate(planId, coilIdArray);
|
|
|
|
|
|
// 转Vo并构建操作记录Map(key=coilId,value=对应的操作记录)
|
|
|
|
|
|
Map<Long, WmsDeliveryPlanCoilOperateVo> operateMap = BeanUtil.copyToList(coilOperateList, WmsDeliveryPlanCoilOperateVo.class)
|
|
|
|
|
|
.stream()
|
|
|
|
|
|
.collect(Collectors.toMap(
|
|
|
|
|
|
WmsDeliveryPlanCoilOperateVo::getCoilId,
|
|
|
|
|
|
operate -> operate,
|
|
|
|
|
|
(v1, v2) -> v1 // 防重复(理论上窗口函数已保证唯一,兜底)
|
|
|
|
|
|
));
|
2025-12-17 13:58:04 +08:00
|
|
|
|
//接着就是根据钢卷ids去查询钢卷list了 用分页查询的list就需要设置分页参数都设置为最大即可
|
2025-12-17 15:33:39 +08:00
|
|
|
|
if (materialCoilService != null) {
|
|
|
|
|
|
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);
|
|
|
|
|
|
if (tableDataInfo != null && tableDataInfo.getRows() != null) {
|
|
|
|
|
|
List<WmsMaterialCoilVo> coilDetails = tableDataInfo.getRows();
|
|
|
|
|
|
List<WmsDeliveryPlanCoilOperateVo> resultList = new ArrayList<>();
|
|
|
|
|
|
for (WmsMaterialCoilVo coilDetail : coilDetails) {
|
|
|
|
|
|
if (coilDetail != null) {
|
|
|
|
|
|
Long coilId = coilDetail.getCoilId();
|
|
|
|
|
|
// 初始化操作记录Vo(无操作记录则新建空Vo,保证钢卷信息不丢失)
|
|
|
|
|
|
WmsDeliveryPlanCoilOperateVo operateVo = operateMap.getOrDefault(coilId, new WmsDeliveryPlanCoilOperateVo());
|
|
|
|
|
|
// 给操作记录绑定钢卷信息(核心:钢卷为主,操作记录为附属)
|
|
|
|
|
|
operateVo.setCoilId(coilId); // 确保coilId不为空
|
|
|
|
|
|
operateVo.setCoilDetail(coilDetail); // 绑定钢卷详情
|
|
|
|
|
|
resultList.add(operateVo);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
}
|
2025-12-17 13:58:04 +08:00
|
|
|
|
}
|
2025-12-17 15:33:39 +08:00
|
|
|
|
return Collections.emptyList();
|
2025-12-17 13:58:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|