package com.vincent.rsf.server.api.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.vincent.rsf.framework.common.Cools;
|
import com.vincent.rsf.framework.common.R;
|
import com.vincent.rsf.framework.exception.CoolException;
|
import com.vincent.rsf.server.api.entity.params.PdaGeneralParam;
|
import com.vincent.rsf.server.api.service.PdaOtherService;
|
import com.vincent.rsf.server.manager.entity.BasStation;
|
import com.vincent.rsf.server.manager.entity.Loc;
|
import com.vincent.rsf.server.manager.entity.LocItem;
|
import com.vincent.rsf.server.manager.entity.Transfer;
|
import com.vincent.rsf.server.manager.enums.LocStatusType;
|
import com.vincent.rsf.server.manager.enums.LocStsType;
|
import com.vincent.rsf.server.manager.service.BasStationService;
|
import com.vincent.rsf.server.manager.service.LocItemService;
|
import com.vincent.rsf.server.manager.service.LocService;
|
import com.vincent.rsf.server.manager.service.TransferService;
|
import com.vincent.rsf.server.system.entity.User;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class PdaOtherServiceImpl implements PdaOtherService {
|
|
@Autowired
|
private TransferService transferService;
|
|
@Autowired
|
private LocService locService;
|
@Autowired
|
private LocItemService locItemService;
|
|
@Autowired
|
private BasStationService basStationService;
|
|
@Override
|
public R transferPage(String orderNo, Integer curr, Integer limit) {
|
Page<Transfer> page = new Page<>(curr, limit);
|
LambdaQueryWrapper<Transfer> transferLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
transferLambdaQueryWrapper.eq(!Cools.isEmpty(orderNo), Transfer::getCode, orderNo);
|
Page<Transfer> page1 = transferService.page(page, transferLambdaQueryWrapper);
|
return R.ok(page1);
|
}
|
|
@Override
|
public R inspectList(PdaGeneralParam generalParam) {
|
if (Cools.isEmpty(generalParam.getContainerNo())) {
|
throw new CoolException("容器码为空");
|
}
|
Loc loc = null;
|
try {
|
loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, generalParam.getContainerNo()));
|
}catch (Exception e){
|
throw new CoolException("数据错误,查询到多条库位");
|
}
|
if (Cools.isEmpty(loc)) {
|
throw new CoolException("未找到对应的库位");
|
}
|
if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)){
|
throw new CoolException("库位不为在库状态");
|
}
|
List<LocItem> list = locItemService.list(new LambdaQueryWrapper<LocItem>()
|
.eq(LocItem::getLocId, loc.getId())
|
.eq(!Cools.isEmpty(generalParam.getMatnrCode()),LocItem::getMatnrCode, generalParam.getMatnrCode())
|
);
|
if (Cools.isEmpty(list)) {
|
throw new CoolException("库位为在库状态,但库位为空");
|
}
|
return R.ok(list);
|
|
}
|
|
@Override
|
public R inspectConfirm(PdaGeneralParam generalParam) {
|
if (Cools.isEmpty(generalParam.getMatnrList())){
|
throw new CoolException("参数为空");
|
}
|
for (LocItem locItem : generalParam.getMatnrList()) {
|
LocItem locItem1 = locItemService.getById(locItem.getId());
|
if (Cools.isEmpty(locItem1)) {
|
throw new CoolException("数据错误");
|
}
|
if (locItem1.getStatus().equals(LocStatusType.FREEZE.type)){
|
continue;
|
}
|
if (locItem.getStatus().equals(LocStatusType.FREEZE.type)){
|
locItem1.setStatus(LocStatusType.FREEZE.type);
|
locItemService.updateById(locItem1);
|
}
|
|
|
}
|
return R.ok();
|
}
|
|
@Override
|
public R inspectConfirm2(PdaGeneralParam generalParam) {
|
if (Cools.isEmpty(generalParam.getMatnrList())){
|
throw new CoolException("参数为空");
|
}
|
for (LocItem locItem : generalParam.getMatnrList()) {
|
LocItem locItem1 = locItemService.getById(locItem.getId());
|
if (Cools.isEmpty(locItem1)) {
|
throw new CoolException("数据错误");
|
}
|
if (locItem1.getStatus().equals(LocStatusType.NORMAL.type)){
|
continue;
|
}
|
if (locItem.getStatus().equals(LocStatusType.NORMAL.type)){
|
locItem1.setStatus(LocStatusType.NORMAL.type);
|
locItemService.updateById(locItem1);
|
}
|
|
|
}
|
return R.ok();
|
}
|
|
@Override
|
public R stationPage(String staNo, Integer curr, Integer limit) {
|
Page<BasStation> page = new Page<>(curr, limit);
|
LambdaQueryWrapper<BasStation> basStationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
basStationLambdaQueryWrapper.eq(!Cools.isEmpty(staNo), BasStation::getStationName, staNo);
|
Page<BasStation> page1 = basStationService.page(page, basStationLambdaQueryWrapper);
|
return R.ok(page1);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public R staOperate(PdaGeneralParam generalParam, User user) {
|
switch (generalParam.getStaOperateType()){
|
case 1:
|
stationDisabled(generalParam.getTransferStationNo(),user);
|
break;
|
case 2:
|
stationLiftTheBan(generalParam.getTransferStationNo(),user);
|
break;
|
case 3:
|
stationRelease(generalParam.getTransferStationNo(),user);
|
break;
|
default:
|
break;
|
}
|
|
return R.ok();
|
}
|
|
|
@Transactional(rollbackFor = Exception.class)
|
public void stationDisabled(String transferStationNo,User user){
|
BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, transferStationNo));
|
if (Cools.isEmpty(basStation)) {
|
throw new CoolException("未找到正确的站点");
|
}
|
if (basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前站点正在工作");
|
}
|
basStation.setUseStatus(LocStsType.LOC_STS_TYPE_X.type);
|
basStation.setUpdateBy(user.getId());
|
basStation.setUpdateTime(new Date());
|
basStationService.updateById(basStation);
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
public void stationLiftTheBan(String transferStationNo,User user){
|
BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, transferStationNo));
|
if (Cools.isEmpty(basStation)) {
|
throw new CoolException("未找到正确的站点");
|
}
|
if (basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前站点正在工作");
|
}
|
|
basStation.setUseStatus(Cools.isEmpty(basStation.getBarcode())?LocStsType.LOC_STS_TYPE_O.type:LocStsType.LOC_STS_TYPE_F.type);
|
basStation.setUpdateBy(user.getId());
|
basStation.setUpdateTime(new Date());
|
basStationService.updateById(basStation);
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
public void stationRelease(String transferStationNo,User user){
|
BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, transferStationNo));
|
if (Cools.isEmpty(basStation)) {
|
throw new CoolException("未找到正确的站点");
|
}
|
if (basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || basStation.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前站点正在工作");
|
}
|
|
basStation.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
|
basStation.setBarcode(null);
|
basStation.setUpdateBy(user.getId());
|
basStation.setUpdateTime(new Date());
|
basStationService.updateById(basStation);
|
}
|
|
|
@Override
|
public R locPage(String locNo, Integer curr, Integer limit) {
|
Page<Loc> page = new Page<>(curr, limit);
|
LambdaQueryWrapper<Loc> basStationLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
basStationLambdaQueryWrapper.eq(!Cools.isEmpty(locNo), Loc::getCode, locNo);
|
Page<Loc> page1 = locService.page(page, basStationLambdaQueryWrapper);
|
return R.ok(page1);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public R locOperate(PdaGeneralParam generalParam, User user) {
|
switch (generalParam.getStaOperateType()){
|
case 1:
|
locDisabled(generalParam.getLocNo(),user);
|
break;
|
case 2:
|
locLiftTheBan(generalParam.getLocNo(),user);
|
break;
|
case 3:
|
locRelease(generalParam.getLocNo(),user);
|
break;
|
default:
|
break;
|
}
|
|
return R.ok();
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
public void locDisabled(String transferStationNo,User user){
|
Loc lco = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, transferStationNo));
|
if (Cools.isEmpty(lco)) {
|
throw new CoolException("未找到正确的库位");
|
}
|
if (lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前站点正在工作");
|
}
|
lco.setUseStatus(LocStsType.LOC_STS_TYPE_X.type);
|
lco.setUpdateBy(user.getId());
|
lco.setUpdateTime(new Date());
|
locService.updateById(lco);
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
public void locLiftTheBan(String transferStationNo,User user){
|
Loc lco = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, transferStationNo));
|
if (Cools.isEmpty(lco)) {
|
throw new CoolException("未找到正确的库位");
|
}
|
if (lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前库位正在工作");
|
}
|
|
lco.setUseStatus(Cools.isEmpty(lco.getBarcode())?LocStsType.LOC_STS_TYPE_O.type:LocStsType.LOC_STS_TYPE_F.type);
|
lco.setUpdateBy(user.getId());
|
lco.setUpdateTime(new Date());
|
locService.updateById(lco);
|
}
|
|
@Transactional(rollbackFor = Exception.class)
|
public void locRelease(String transferStationNo,User user){
|
Loc lco = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, transferStationNo));
|
if (Cools.isEmpty(lco)) {
|
throw new CoolException("未找到正确的库位");
|
}
|
if (lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type) || lco.getUseStatus().equals(LocStsType.LOC_STS_TYPE_R.type)) {
|
throw new CoolException("当前库位正在工作");
|
}
|
|
lco.setUseStatus(LocStsType.LOC_STS_TYPE_O.type);
|
lco.setBarcode(null);
|
lco.setUpdateBy(user.getId());
|
lco.setUpdateTime(new Date());
|
locService.updateById(lco);
|
}
|
|
}
|