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