|
@@ -58,6 +58,8 @@ import vip.xiaonuo.biz.modular.bizorderconfig.entity.BizOrderConfig;
|
|
|
import vip.xiaonuo.biz.modular.bizorderconfig.service.BizOrderConfigService;
|
|
|
import vip.xiaonuo.biz.modular.bizordersupplier.entity.BizOrderSupplier;
|
|
|
import vip.xiaonuo.biz.modular.bizordersupplier.service.BizOrderSupplierService;
|
|
|
+import vip.xiaonuo.biz.modular.bizpipeplan.entity.BizPipePlan;
|
|
|
+import vip.xiaonuo.biz.modular.bizpipeplan.service.BizPipePlanService;
|
|
|
import vip.xiaonuo.biz.modular.bizsupplier.entity.BizSupplierTransport;
|
|
|
import vip.xiaonuo.biz.modular.bizsupplier.service.BizSupplierTransportService;
|
|
|
import vip.xiaonuo.biz.modular.customer.entity.BizCustomer;
|
|
@@ -151,6 +153,9 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
@Resource
|
|
|
private BizLoadAppointSupplierService bizLoadAppointSupplierService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private BizPipePlanService bizPipePlanService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<BizAppointmentRecord> page(BizAppointmentRecordPageParam bizAppointmentRecordPageParam) {
|
|
|
QueryWrapper<BizAppointmentRecord> queryWrapper = getQueryWrapper(bizAppointmentRecordPageParam);
|
|
@@ -201,6 +206,10 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
if (ObjectUtil.isNotEmpty(bizAppointmentRecordPageParam.getLoadNumber())) {
|
|
|
queryWrapper.like("bla.load_number", bizAppointmentRecordPageParam.getLoadNumber());
|
|
|
}
|
|
|
+ //管桩计划单号
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordPageParam.getPlanNumber())){
|
|
|
+ queryWrapper.like("bpp.plan_number",bizAppointmentRecordPageParam.getPlanNumber());
|
|
|
+ }
|
|
|
queryWrapper.eq("bar.delete_flag", "NOT_DELETE");
|
|
|
queryWrapper.orderByDesc("bar.create_time");
|
|
|
return queryWrapper;
|
|
@@ -1281,6 +1290,8 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public void getLoadTimeCount(BizAppointmentRecordEditParam bizAppointmentRecordEditParam, BizAppointmentRecord bizAppointmentRecord) {
|
|
|
lock.lock();
|
|
|
try {
|
|
@@ -1303,6 +1314,196 @@ public class BizAppointmentRecordServiceImpl extends ServiceImpl<BizAppointmentR
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void addPipeAppoint(BizAppointmentRecordAddParam bizAppointmentRecordAddParam) {
|
|
|
+ checkPipeParam(bizAppointmentRecordAddParam);
|
|
|
+ //获取流程配置判断预约是否需要审核
|
|
|
+ BizConfig bizConfig = bizConfigService.getOne(new QueryWrapper<BizConfig>().lambda().last("limit 1"));
|
|
|
+ BizAppointmentRecord bizAppointmentRecord = BeanUtil.toBean(bizAppointmentRecordAddParam, BizAppointmentRecord.class);
|
|
|
+ if (ObjectUtil.isNotNull(bizConfig)) {
|
|
|
+ if (StringUtils.equals(bizConfig.getTemporaryAuditSwitch(), "1")) {
|
|
|
+ //开启审核,设置待审核状态
|
|
|
+ bizAppointmentRecord.setStatus("1");
|
|
|
+ } else {
|
|
|
+ //未开启审核,设置待入场状态
|
|
|
+ bizAppointmentRecord.setStatus("4");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bizAppointmentRecord.setAppointmentType("5");
|
|
|
+ this.save(bizAppointmentRecord);
|
|
|
+
|
|
|
+ //修改管桩计划状态
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecordAddParam.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(pipePlan)){
|
|
|
+ pipePlan.setStatus("2");
|
|
|
+ pipePlan.setPlanAlreadyCount(pipePlan.getPlanAlreadyCount() + 1);
|
|
|
+ bizPipePlanService.updateById(pipePlan);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkPipeParam(BizAppointmentRecordAddParam bizAppointmentRecordAddParam) {
|
|
|
+ //校验车牌号
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getLicenseNumber())) {
|
|
|
+ bizAppointmentRecordAddParam.setLicenseNumber(bizAppointmentRecordAddParam.getLicenseNumber().toUpperCase().trim());
|
|
|
+ //校验车牌号是否添加过预约,排除11:已签收、 13:销售已审核 、 14:已取消
|
|
|
+ long count = this.count(new QueryWrapper<BizAppointmentRecord>().lambda().
|
|
|
+ eq(BizAppointmentRecord::getLicenseNumber, bizAppointmentRecordAddParam.getLicenseNumber()).
|
|
|
+ notIn(BizAppointmentRecord::getStatus, "10", "11", "12", "13", "14", "15"));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CommonException("车牌号:{}已经添加过预约!", bizAppointmentRecordAddParam.getLicenseNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //校验手机号
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getDriverMobile())) {
|
|
|
+ if (!PhoneUtil.isMobile(bizAppointmentRecordAddParam.getDriverMobile())) {
|
|
|
+ throw new CommonException("手机号码:{}格式错误", bizAppointmentRecordAddParam.getDriverMobile());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //校验订单
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getOrderId())) {
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecordAddParam.getOrderId());
|
|
|
+ if (ObjectUtil.isNotNull(pipePlan)) {
|
|
|
+ if (!StringUtils.equals(pipePlan.getStatus(), "1") && !StringUtils.equals(pipePlan.getStatus(), "2")) {
|
|
|
+ throw new CommonException("当前订单不可预约!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询预约时间段内可预约次数
|
|
|
+ getPipeTimeCount(bizAppointmentRecordAddParam);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getPipeTimeCount(BizAppointmentRecordAddParam bizAppointmentRecordAddParam) {
|
|
|
+ lock.lock();
|
|
|
+ try {
|
|
|
+ //判断管桩计划次数是否满足
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordAddParam.getOrderId())) {
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecordAddParam.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(pipePlan)){
|
|
|
+ if(pipePlan.getPlanCount() - pipePlan.getPlanAlreadyCount() <= 0){
|
|
|
+ throw new CommonException("当前管桩计划单预约次数已满");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ lock.unlock(); // 释放锁
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional
|
|
|
+ @Override
|
|
|
+ public void editPipeAppoint(BizAppointmentRecordEditParam bizAppointmentRecordEditParam) {
|
|
|
+ BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordEditParam.getId());
|
|
|
+ checkPipeParam(bizAppointmentRecordEditParam, bizAppointmentRecord);
|
|
|
+ if (!StringUtils.equals(bizAppointmentRecord.getLoadTimeId(), bizAppointmentRecordEditParam.getLoadTimeId())) {
|
|
|
+ //调整了装卸时段,释放之前的已约次数,更新新的时段已约次数
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getLoadTimeId())) {
|
|
|
+ BizLoadTime bizLoadTime = bizLoadTimeService.getById(bizAppointmentRecordEditParam.getLoadTimeId());
|
|
|
+ if (ObjectUtil.isNotNull(bizLoadTime)) {
|
|
|
+ bizLoadTime.setAlreadyNumber(bizLoadTime.getAlreadyNumber() + 1);
|
|
|
+ bizLoadTimeService.updateById(bizLoadTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecord.getLoadTimeId())) {
|
|
|
+ BizLoadTime bizLoadTime = bizLoadTimeService.getById(bizAppointmentRecord.getLoadTimeId());
|
|
|
+ if (ObjectUtil.isNotNull(bizLoadTime)) {
|
|
|
+ bizLoadTime.setAlreadyNumber(bizLoadTime.getAlreadyNumber() - 1);
|
|
|
+ bizLoadTimeService.updateById(bizLoadTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BeanUtil.copyProperties(bizAppointmentRecordEditParam, bizAppointmentRecord);
|
|
|
+ if (StringUtils.equals(bizAppointmentRecord.getStatus(), "2")) {
|
|
|
+ //如果当前状态是审核不通过的状态,修改后重新提交审核
|
|
|
+ bizAppointmentRecord.setStatus("1");
|
|
|
+ }
|
|
|
+ this.updateById(bizAppointmentRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void checkPipeParam(BizAppointmentRecordEditParam bizAppointmentRecordEditParam, BizAppointmentRecord bizAppointmentRecord) {
|
|
|
+ //校验车牌号
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getLicenseNumber())) {
|
|
|
+ bizAppointmentRecordEditParam.setLicenseNumber(bizAppointmentRecordEditParam.getLicenseNumber().toUpperCase().trim());
|
|
|
+ if (!StringUtils.equals(bizAppointmentRecord.getLicenseNumber(), bizAppointmentRecordEditParam.getLicenseNumber())) {
|
|
|
+ //校验车牌号是否添加过预约,排除11:已签收、 13:销售已审核 、 14:已取消
|
|
|
+ long count = this.count(new QueryWrapper<BizAppointmentRecord>().lambda().
|
|
|
+ eq(BizAppointmentRecord::getLicenseNumber, bizAppointmentRecordEditParam.getLicenseNumber()).
|
|
|
+ notIn(BizAppointmentRecord::getStatus, "10", "11", "12", "13", "14", "15"));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new CommonException("车牌号:{}已经添加过预约!", bizAppointmentRecordEditParam.getLicenseNumber());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //校验手机号
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getDriverMobile())) {
|
|
|
+ if (!PhoneUtil.isMobile(bizAppointmentRecordEditParam.getDriverMobile())) {
|
|
|
+ throw new CommonException("手机号码:{}格式错误", bizAppointmentRecordEditParam.getDriverMobile());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //校验订单
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getOrderId())) {
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecordEditParam.getOrderId());
|
|
|
+ if (ObjectUtil.isNotNull(pipePlan)) {
|
|
|
+ if (!StringUtils.equals(pipePlan.getStatus(), "1") && !StringUtils.equals(pipePlan.getStatus(), "2")) {
|
|
|
+ throw new CommonException("当前订单不可预约!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询预约时间段内可预约次数
|
|
|
+ getPipeTimeCount(bizAppointmentRecordEditParam, bizAppointmentRecord);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void getPipeTimeCount(BizAppointmentRecordEditParam bizAppointmentRecordEditParam,BizAppointmentRecord bizAppointmentRecord) {
|
|
|
+ lock.lock();
|
|
|
+ try {
|
|
|
+ //判断管桩计划次数是否满足
|
|
|
+ if (ObjectUtil.isNotEmpty(bizAppointmentRecordEditParam.getOrderId())) {
|
|
|
+ if(!StringUtils.equals(bizAppointmentRecordEditParam.getOrderId(),bizAppointmentRecord.getOrderId())){
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecordEditParam.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(pipePlan)){
|
|
|
+ if(pipePlan.getPlanCount() - pipePlan.getPlanAlreadyCount() <= 0){
|
|
|
+ throw new CommonException("当前管桩计划单预约次数已满");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ lock.unlock(); // 释放锁
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<BizAppointmentRecord> getPipePage(BizAppointmentRecordPageParam bizAppointmentRecordPageParam) {
|
|
|
+ QueryWrapper<BizAppointmentRecord> queryWrapper = getQueryWrapper(bizAppointmentRecordPageParam);
|
|
|
+ Page<BizAppointmentRecord> loadPage = this.getBaseMapper().getPipePage(CommonPageRequest.defaultPage(), queryWrapper);
|
|
|
+ return loadPage;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void replacePipeAppoint(BizAppointmentRecordEditParam bizAppointmentRecordEditParam) {
|
|
|
+ //修改预约已取消状态
|
|
|
+ BizAppointmentRecord bizAppointmentRecord = this.queryEntity(bizAppointmentRecordEditParam.getId());
|
|
|
+ bizAppointmentRecord.setStatus("14");
|
|
|
+ this.updateById(bizAppointmentRecord);
|
|
|
+
|
|
|
+ //修改管桩计划单已约数量
|
|
|
+ BizPipePlan pipePlan = bizPipePlanService.getById(bizAppointmentRecord.getOrderId());
|
|
|
+ if(ObjectUtil.isNotNull(pipePlan)){
|
|
|
+ pipePlan.setPlanAlreadyCount(pipePlan.getPlanAlreadyCount() - 1);
|
|
|
+ bizPipePlanService.updateById(pipePlan);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void addOtherAppointment(BizOtherAppointmentAddParam bizOtherAppointmentAddParam) {
|
|
|
checkOtherParam(bizOtherAppointmentAddParam.getLicenseNumber());
|