|
|
package com.glxp.api.service.inout;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.glxp.api.dao.auth.SysWorkplaceDao;
|
|
|
import com.glxp.api.dao.inout.IoSplitFifoCodeMapper;
|
|
|
import com.glxp.api.entity.auth.SysWorkplace;
|
|
|
import com.glxp.api.entity.inout.IoSplitFifoCodeEntity;
|
|
|
import com.glxp.api.exception.JsonException;
|
|
|
import com.glxp.api.req.inout.IoSplitFifoCodeRequest;
|
|
|
import com.glxp.api.res.inout.IoSplitCodeResponse;
|
|
|
import com.glxp.api.service.auth.SysWorkplaceService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
public class IoSplitFifoCodeService extends ServiceImpl<IoSplitFifoCodeMapper, IoSplitFifoCodeEntity> {
|
|
|
|
|
|
@Resource
|
|
|
IoSplitFifoCodeMapper splitFifoCodeMapper;
|
|
|
@Resource
|
|
|
SysWorkplaceService sysWorkplaceService;
|
|
|
|
|
|
public List<IoSplitCodeResponse> filterGroupList(IoSplitFifoCodeRequest splitFifoCodeRequest) {
|
|
|
if (splitFifoCodeRequest == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
if (splitFifoCodeRequest.getPage() != null) {
|
|
|
int offset = (splitFifoCodeRequest.getPage() - 1) * splitFifoCodeRequest.getLimit();
|
|
|
PageHelper.offsetPage(offset, splitFifoCodeRequest.getLimit());
|
|
|
}
|
|
|
return super.baseMapper.filterGroupList(splitFifoCodeRequest);
|
|
|
|
|
|
}
|
|
|
|
|
|
public List<IoSplitCodeResponse> filterList(IoSplitFifoCodeRequest splitFifoCodeRequest) {
|
|
|
if (splitFifoCodeRequest == null) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
if (splitFifoCodeRequest.getPage() != null) {
|
|
|
int offset = (splitFifoCodeRequest.getPage() - 1) * splitFifoCodeRequest.getLimit();
|
|
|
PageHelper.offsetPage(offset, splitFifoCodeRequest.getLimit());
|
|
|
}
|
|
|
return super.baseMapper.filterList(splitFifoCodeRequest);
|
|
|
|
|
|
}
|
|
|
|
|
|
public Boolean isExitCode(String code, Long workPlaceCode) {
|
|
|
return splitFifoCodeMapper.exists(
|
|
|
new LambdaQueryWrapper<IoSplitFifoCodeEntity>()
|
|
|
.eq(IoSplitFifoCodeEntity::getCode, code)
|
|
|
.eq(workPlaceCode != null, IoSplitFifoCodeEntity::getWorkPlaceCode, workPlaceCode)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
public IoSplitFifoCodeEntity findByCode(String code, Long workPlaceCode) {
|
|
|
return splitFifoCodeMapper.selectOne(
|
|
|
new LambdaQueryWrapper<IoSplitFifoCodeEntity>()
|
|
|
.eq(IoSplitFifoCodeEntity::getCode, code)
|
|
|
.eq(workPlaceCode != null, IoSplitFifoCodeEntity::getWorkPlaceCode, workPlaceCode)
|
|
|
.last("limit 1")
|
|
|
);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 库存量提醒
|
|
|
*
|
|
|
* @param workPlaceCode
|
|
|
* @return
|
|
|
*/
|
|
|
public String findInvRemind(Long workPlaceCode) {
|
|
|
final String[] msg = {"当前工位存量提醒:"};
|
|
|
SysWorkplace workplace = sysWorkplaceService.getWorkplace(workPlaceCode);
|
|
|
if (workplace == null) throw new JsonException("未找到匹配工位");
|
|
|
Integer invRemindNumber = workplace.getInvRemindNumber();
|
|
|
|
|
|
List<IoSplitCodeResponse> invReminds = splitFifoCodeMapper.findInvRemind(workPlaceCode);
|
|
|
if (CollUtil.isEmpty(invReminds)) {
|
|
|
return "当前工位存量提醒:" + "0";
|
|
|
}
|
|
|
invReminds.forEach(item -> {
|
|
|
Integer groupCount = item.getGroupCount();
|
|
|
if (groupCount < invRemindNumber) {
|
|
|
String cpmctymc = item.getCpmctymc();
|
|
|
String batchNo = item.getBatchNo();
|
|
|
if (StrUtil.isBlank(batchNo)) {
|
|
|
msg[0] = msg[0] + cpmctymc + "存量为:" + groupCount;
|
|
|
} else {
|
|
|
msg[0] = msg[0] + cpmctymc + "[" + batchNo + "]存量为:" + groupCount;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return msg[0];
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 预分配库存 todo
|
|
|
*/
|
|
|
public void preAllotInv(String workPaceCode) {
|
|
|
|
|
|
//1. 查询出当前工位的未分配的库存
|
|
|
|
|
|
|
|
|
//2.遍历当前工位待处理的单据,根据orderTime排序
|
|
|
|
|
|
|
|
|
//3.为每个单据底下的单据详情分配数量
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|