|
|
@ -35,10 +35,7 @@ import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
@ -232,41 +229,44 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public SchBasePoint selectByRegionCode(String region_code,String vehicleCode) { |
|
|
|
//查询载具的类型
|
|
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(vehicleCode); |
|
|
|
if(ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具类型不存在!"); |
|
|
|
//查询满足条件的站点
|
|
|
|
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). |
|
|
|
isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); |
|
|
|
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getIs_lock, false) |
|
|
|
.isNull(SchBasePoint::getVehicle_code) |
|
|
|
.eq(SchBasePoint::getRegion_code, region_code) |
|
|
|
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true)); |
|
|
|
if(CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0){ |
|
|
|
SchBasePoint schBasePoint = schBasePoints.get(0); |
|
|
|
schBasePoint.setVehicle_code(vehicleCode); |
|
|
|
schBasePoint.setIs_lock(true); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
schBasePoint.setUpdate_id(currentUserId); |
|
|
|
schBasePoint.setUpdate_name(nickName); |
|
|
|
schBasePoint.setUpdate_time(now); |
|
|
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|
|
|
PointUtils.setUpdateByAcs(schBasePoint); |
|
|
|
updateById(schBasePoint); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
|
SchBasePoint schBasePoint1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getRegion_code, region_code)).get(0); |
|
|
|
if(ObjectUtil.isEmpty(schBasePoint1)) throw new BadRequestException("不存在该区域!"); |
|
|
|
//分配载具类型相同的站点
|
|
|
|
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). |
|
|
|
isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); |
|
|
|
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getIs_lock, false) |
|
|
|
.isNull(SchBasePoint::getVehicle_code) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true) |
|
|
|
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); |
|
|
|
schBasePoints1.stream().sorted(Comparator.comparingInt(schBasePoint -> Math.abs(schBasePoint1.getRegion_seq() - schBasePoint.getRegion_seq()))); |
|
|
|
if(CollUtil.isNotEmpty(schBasePoints1) && schBasePoints1.size() > 0){ |
|
|
|
SchBasePoint schBasePoint = schBasePoints.get(0); |
|
|
|
SchBasePoint schBasePoint = schBasePoints1.get(0); |
|
|
|
schBasePoint.setVehicle_code(vehicleCode); |
|
|
|
schBasePoint.setIs_lock(true); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
schBasePoint.setUpdate_id(currentUserId); |
|
|
|
schBasePoint.setUpdate_name(nickName); |
|
|
|
schBasePoint.setUpdate_time(now); |
|
|
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|
|
|
PointUtils.setUpdateByAcs(schBasePoint); |
|
|
|
updateById(schBasePoint); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
@ -285,40 +285,39 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
|
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.getById(vehicleCode); |
|
|
|
if(ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具类型不存在!"); |
|
|
|
//查询满足条件的站点
|
|
|
|
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). |
|
|
|
isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getRegion_code, region_code).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()).eq(SchBasePoint::getIs_used, true)); |
|
|
|
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getIs_lock, false) |
|
|
|
.isNull(SchBasePoint::getVehicle_code) |
|
|
|
.eq(SchBasePoint::getRegion_code, region_code) |
|
|
|
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true)); |
|
|
|
if(CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0){ |
|
|
|
SchBasePoint schBasePoint1 = schBasePoints.get(0); |
|
|
|
SchBasePoint schBasePoint = pointMapper.selectById(schBasePoint1.getNext_wait_point()); |
|
|
|
if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("没有找到等待点!"); |
|
|
|
schBasePoint1.setVehicle_code(vehicleCode); |
|
|
|
schBasePoint1.setIs_lock(true); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
schBasePoint1.setUpdate_id(currentUserId); |
|
|
|
schBasePoint1.setUpdate_name(nickName); |
|
|
|
schBasePoint1.setUpdate_time(now); |
|
|
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|
|
|
PointUtils.setUpdateByAcs(schBasePoint); |
|
|
|
updateById(schBasePoint1); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
|
//分配载具类型相同的站点
|
|
|
|
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). |
|
|
|
isNull(SchBasePoint::getVehicle_code).eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true).eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); |
|
|
|
List<SchBasePoint> schBasePoints1 = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class) |
|
|
|
.eq(SchBasePoint::getIs_lock, false) |
|
|
|
.isNull(SchBasePoint::getVehicle_code) |
|
|
|
.eq(SchBasePoint::getCan_vehicle_type, mdBaseVehicle.getVehicle_type()) |
|
|
|
.eq(SchBasePoint::getIs_used, true) |
|
|
|
.eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue())); |
|
|
|
if(CollUtil.isNotEmpty(schBasePoints1) && schBasePoints1.size() > 0){ |
|
|
|
SchBasePoint schBasePoint1 = schBasePoints.get(0); |
|
|
|
SchBasePoint schBasePoint1 = schBasePoints1.get(0); |
|
|
|
SchBasePoint schBasePoint = pointMapper.selectById(schBasePoint1.getNext_wait_point()); |
|
|
|
if(ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("没有找到等待点!"); |
|
|
|
schBasePoint1.setVehicle_code(vehicleCode); |
|
|
|
schBasePoint1.setIs_lock(true); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
schBasePoint1.setUpdate_id(currentUserId); |
|
|
|
schBasePoint1.setUpdate_name(nickName); |
|
|
|
schBasePoint1.setUpdate_time(now); |
|
|
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|
|
|
PointUtils.setUpdateByAcs(schBasePoint); |
|
|
|
updateById(schBasePoint1); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
@ -334,12 +333,8 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch |
|
|
|
SchBasePoint schBasePoint = schBasePoints.get(0); |
|
|
|
schBasePoint.setVehicle_code(vehicleCode); |
|
|
|
schBasePoint.setIs_lock(true); |
|
|
|
String currentUserId = SecurityUtils.getCurrentUserId(); |
|
|
|
String nickName = SecurityUtils.getCurrentNickName(); |
|
|
|
String now = DateUtil.now(); |
|
|
|
schBasePoint.setUpdate_id(currentUserId); |
|
|
|
schBasePoint.setUpdate_name(nickName); |
|
|
|
schBasePoint.setUpdate_time(now); |
|
|
|
schBasePoint.setPoint_status(GoodsEnum.IN_STOCK.getValue()); |
|
|
|
PointUtils.setUpdateByAcs(schBasePoint); |
|
|
|
updateById(schBasePoint); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
|