2025-11-03 17:03:03 +08:00
|
|
|
package com.klp.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import com.klp.common.core.domain.PageQuery;
|
|
|
|
|
import com.klp.common.core.page.TableDataInfo;
|
|
|
|
|
import com.klp.common.utils.StringUtils;
|
|
|
|
|
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.helper.LoginHelper;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import com.klp.domain.bo.WmsCoilPendingActionBo;
|
|
|
|
|
import com.klp.domain.vo.WmsCoilPendingActionVo;
|
|
|
|
|
import com.klp.domain.WmsCoilPendingAction;
|
|
|
|
|
import com.klp.mapper.WmsCoilPendingActionMapper;
|
|
|
|
|
import com.klp.service.IWmsCoilPendingActionService;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 钢卷待操作Service业务层处理
|
|
|
|
|
*
|
|
|
|
|
* @author Joshi
|
|
|
|
|
* @date 2025-11-03
|
|
|
|
|
*/
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
@Service
|
|
|
|
|
public class WmsCoilPendingActionServiceImpl implements IWmsCoilPendingActionService {
|
|
|
|
|
|
|
|
|
|
private final WmsCoilPendingActionMapper baseMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询钢卷待操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public WmsCoilPendingActionVo queryById(Long actionId){
|
|
|
|
|
return baseMapper.selectVoById(actionId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询钢卷待操作列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public TableDataInfo<WmsCoilPendingActionVo> queryPageList(WmsCoilPendingActionBo bo, PageQuery pageQuery) {
|
|
|
|
|
LambdaQueryWrapper<WmsCoilPendingAction> lqw = buildQueryWrapper(bo);
|
|
|
|
|
Page<WmsCoilPendingActionVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
|
|
return TableDataInfo.build(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询钢卷待操作列表
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<WmsCoilPendingActionVo> queryList(WmsCoilPendingActionBo bo) {
|
|
|
|
|
LambdaQueryWrapper<WmsCoilPendingAction> lqw = buildQueryWrapper(bo);
|
|
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<WmsCoilPendingAction> buildQueryWrapper(WmsCoilPendingActionBo bo) {
|
|
|
|
|
LambdaQueryWrapper<WmsCoilPendingAction> lqw = Wrappers.lambdaQuery();
|
|
|
|
|
lqw.eq(bo.getCoilId() != null, WmsCoilPendingAction::getCoilId, bo.getCoilId());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getCurrentCoilNo()), WmsCoilPendingAction::getCurrentCoilNo, bo.getCurrentCoilNo());
|
|
|
|
|
lqw.eq(bo.getActionType() != null, WmsCoilPendingAction::getActionType, bo.getActionType());
|
|
|
|
|
lqw.eq(bo.getActionStatus() != null, WmsCoilPendingAction::getActionStatus, bo.getActionStatus());
|
|
|
|
|
lqw.eq(bo.getWarehouseId() != null, WmsCoilPendingAction::getWarehouseId, bo.getWarehouseId());
|
|
|
|
|
lqw.eq(bo.getPriority() != null, WmsCoilPendingAction::getPriority, bo.getPriority());
|
|
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getSourceType()), WmsCoilPendingAction::getSourceType, bo.getSourceType());
|
|
|
|
|
lqw.orderByDesc(WmsCoilPendingAction::getPriority);
|
|
|
|
|
lqw.orderByDesc(WmsCoilPendingAction::getScanTime);
|
|
|
|
|
return lqw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增钢卷待操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean insertByBo(WmsCoilPendingActionBo bo) {
|
|
|
|
|
WmsCoilPendingAction add = BeanUtil.toBean(bo, WmsCoilPendingAction.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
// 设置默认值
|
|
|
|
|
if (add.getActionStatus() == null) {
|
|
|
|
|
add.setActionStatus(0); // 默认待处理
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isBlank(add.getSourceType())) {
|
|
|
|
|
add.setSourceType("manual"); // 默认手动创建
|
|
|
|
|
}
|
|
|
|
|
if (add.getScanTime() == null && "scan".equals(add.getSourceType())) {
|
|
|
|
|
add.setScanTime(new Date());
|
|
|
|
|
}
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
bo.setActionId(add.getActionId());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改钢卷待操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateByBo(WmsCoilPendingActionBo bo) {
|
|
|
|
|
WmsCoilPendingAction update = BeanUtil.toBean(bo, WmsCoilPendingAction.class);
|
|
|
|
|
validEntityBeforeSave(update);
|
|
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 保存前的数据校验
|
|
|
|
|
*/
|
|
|
|
|
private void validEntityBeforeSave(WmsCoilPendingAction entity){
|
|
|
|
|
// TODO 做一些数据校验,如唯一约束
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除钢卷待操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
|
|
|
|
if(isValid){
|
|
|
|
|
// TODO 做一些业务上的校验,判断是否需要校验
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.deleteBatchIds(ids) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新操作状态
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateStatus(Long actionId, Integer status) {
|
|
|
|
|
WmsCoilPendingAction action = new WmsCoilPendingAction();
|
|
|
|
|
action.setActionId(actionId);
|
|
|
|
|
action.setActionStatus(status);
|
|
|
|
|
return baseMapper.updateById(action) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 开始处理操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean startProcess(Long actionId) {
|
|
|
|
|
WmsCoilPendingAction action = new WmsCoilPendingAction();
|
|
|
|
|
action.setActionId(actionId);
|
|
|
|
|
action.setActionStatus(1); // 处理中
|
|
|
|
|
action.setProcessTime(new Date());
|
|
|
|
|
try {
|
|
|
|
|
action.setOperatorId(LoginHelper.getUserId());
|
|
|
|
|
action.setOperatorName(LoginHelper.getUsername());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果获取登录用户失败,不影响主流程
|
|
|
|
|
}
|
|
|
|
|
return baseMapper.updateById(action) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 完成操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean completeAction(Long actionId) {
|
2025-11-11 10:01:42 +08:00
|
|
|
// 先查询原记录,检查操作人是否为空
|
|
|
|
|
WmsCoilPendingAction oldAction = baseMapper.selectById(actionId);
|
|
|
|
|
if (oldAction == null) {
|
|
|
|
|
throw new RuntimeException("待操作记录不存在");
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-03 17:03:03 +08:00
|
|
|
WmsCoilPendingAction action = new WmsCoilPendingAction();
|
|
|
|
|
action.setActionId(actionId);
|
|
|
|
|
action.setActionStatus(2); // 已完成
|
|
|
|
|
action.setCompleteTime(new Date());
|
2025-11-11 10:01:42 +08:00
|
|
|
|
|
|
|
|
// 如果操作人为空,设置当前登录用户为操作人
|
|
|
|
|
if (oldAction.getOperatorId() == null || oldAction.getOperatorName() == null) {
|
|
|
|
|
try {
|
|
|
|
|
action.setOperatorId(LoginHelper.getUserId());
|
|
|
|
|
action.setOperatorName(LoginHelper.getUsername());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 如果获取登录用户失败,不影响主流程
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-03 17:03:03 +08:00
|
|
|
return baseMapper.updateById(action) > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 取消操作
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean cancelAction(Long actionId) {
|
|
|
|
|
WmsCoilPendingAction action = new WmsCoilPendingAction();
|
|
|
|
|
action.setActionId(actionId);
|
|
|
|
|
action.setActionStatus(3); // 已取消
|
|
|
|
|
return baseMapper.updateById(action) > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|