调整 业务
This commit is contained in:
+10
-3
@@ -119,22 +119,29 @@ public class LoadingManageController extends BladeController {
|
||||
return R.status(loadingManageService.changeRoute(loadingManage));
|
||||
}
|
||||
|
||||
@PostMapping("/cancel")
|
||||
@PostMapping("/start")
|
||||
@ApiOperationSupport(order = 10)
|
||||
@Operation(summary = "改为进行中", description = "传入id")
|
||||
public R start(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
return R.status(loadingManageService.start(id));
|
||||
}
|
||||
|
||||
@PostMapping("/cancel")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@Operation(summary = "取消", description = "传入id")
|
||||
public R cancel(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
return R.status(loadingManageService.cancel(id));
|
||||
}
|
||||
|
||||
@PostMapping("/complete")
|
||||
@ApiOperationSupport(order = 11)
|
||||
@ApiOperationSupport(order = 12)
|
||||
@Operation(summary = "完成", description = "传入id")
|
||||
public R complete(@Parameter(description = "主键", required = true) @RequestParam Long id) {
|
||||
return R.status(loadingManageService.complete(id));
|
||||
}
|
||||
|
||||
@PostMapping("/batch-complete")
|
||||
@ApiOperationSupport(order = 12)
|
||||
@ApiOperationSupport(order = 13)
|
||||
@Operation(summary = "批量完成", description = "传入ids")
|
||||
public R<BusinessRemoveResultVO> batchComplete(@Parameter(description = "主键集合", required = true) @RequestParam String ids) {
|
||||
return R.data(loadingManageService.batchComplete(ids));
|
||||
|
||||
+2
@@ -50,6 +50,8 @@ public interface ILoadingManageService extends BaseService<LoadingManage> {
|
||||
|
||||
boolean changeRoute(LoadingManage loadingManage);
|
||||
|
||||
boolean start(Long id);
|
||||
|
||||
boolean cancel(Long id);
|
||||
|
||||
boolean complete(Long id);
|
||||
|
||||
+93
-2
@@ -29,6 +29,7 @@ import org.springblade.transport.service.IContractManageService;
|
||||
import org.springblade.transport.service.ILoadingManageService;
|
||||
import org.springblade.transport.service.IReceivablePayableDetailService;
|
||||
import org.springblade.transport.support.TransportBusinessSupport;
|
||||
import org.springblade.transport.support.WaybillProcessSupport;
|
||||
import org.springblade.transport.wrapper.LoadingManageWrapper;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,8 +41,10 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -76,6 +79,7 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
IPage<LoadingManage> entityPage = page(page, buildQuery(loadingManage));
|
||||
IPage<LoadingManageVO> voPage = LoadingManageWrapper.build().pageVO(entityPage);
|
||||
voPage.getRecords().forEach(this::fillReadonly);
|
||||
fillDriverRejected(voPage.getRecords());
|
||||
return voPage;
|
||||
}
|
||||
|
||||
@@ -83,6 +87,7 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
public LoadingManageVO detail(Long id) {
|
||||
LoadingManageVO loadingManageVO = LoadingManageWrapper.build().entityVO(loadExists(id));
|
||||
fillReadonly(loadingManageVO);
|
||||
fillDriverRejected(List.of(loadingManageVO));
|
||||
return loadingManageVO;
|
||||
}
|
||||
|
||||
@@ -106,22 +111,27 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
prepare(loadingManage);
|
||||
validate(loadingManage, true);
|
||||
List<Long> oldWaybillIds = new ArrayList<>();
|
||||
// 新建暂存为草稿;编辑已有单据时保持原业务状态(如待执行),避免被改回草稿
|
||||
String businessStatus = STATUS_DRAFT;
|
||||
if (Func.isNotEmpty(loadingManage.getId())) {
|
||||
LoadingManage oldRecord = loadEditable(loadingManage.getId(), true);
|
||||
oldWaybillIds = waybillIds(oldRecord.getWaybillIdsJson());
|
||||
loadingManage.setLoadingNo(oldRecord.getLoadingNo());
|
||||
loadingManage.setDeptId(oldRecord.getDeptId());
|
||||
loadingManage.setDeptName(oldRecord.getDeptName());
|
||||
if (Func.isNotEmpty(oldRecord.getBusinessStatus())) {
|
||||
businessStatus = oldRecord.getBusinessStatus();
|
||||
}
|
||||
}
|
||||
prepareCreateOrUpdate(loadingManage);
|
||||
loadingManage.setBusinessStatus(STATUS_DRAFT);
|
||||
loadingManage.setBusinessStatus(businessStatus);
|
||||
if (Func.isEmpty(loadingManage.getLoadingNo())) {
|
||||
loadingManage.setLoadingNo(nextCode());
|
||||
}
|
||||
validateWaybillsAvailable(loadingManage, waybillIds(loadingManage.getWaybillIdsJson()));
|
||||
validateCarrierContract(loadingManage, false);
|
||||
boolean result = saveOrUpdate(loadingManage);
|
||||
syncAssociatedWaybills(loadingManage, STATUS_DRAFT, oldWaybillIds);
|
||||
syncAssociatedWaybills(loadingManage, businessStatus, oldWaybillIds);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -321,6 +331,9 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
if (!Objects.equals(oldRecord.getBusinessStatus(), STATUS_PENDING)) {
|
||||
throw new ServiceException("仅待执行状态允许重新派单");
|
||||
}
|
||||
if (!hasDriverRejectedWaybill(oldRecord)) {
|
||||
throw new ServiceException("仅司机拒绝接单后允许重新派单");
|
||||
}
|
||||
prepare(loadingManage);
|
||||
validate(loadingManage, false);
|
||||
List<Long> oldWaybillIds = waybillIds(oldRecord.getWaybillIdsJson());
|
||||
@@ -332,6 +345,7 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
validateCarrierContract(loadingManage, true);
|
||||
boolean result = updateById(loadingManage);
|
||||
syncAssociatedWaybills(loadingManage, STATUS_PENDING, oldWaybillIds);
|
||||
clearAssociatedWaybillAcceptRecords(loadingManage);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -351,6 +365,19 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
return updateById(oldRecord);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean start(Long id) {
|
||||
LoadingManage loadingManage = loadEditable(id, true);
|
||||
if (!Objects.equals(loadingManage.getBusinessStatus(), STATUS_PENDING)) {
|
||||
throw new ServiceException("仅待执行状态允许改为进行中");
|
||||
}
|
||||
loadingManage.setBusinessStatus(STATUS_RUNNING);
|
||||
boolean result = updateById(loadingManage);
|
||||
syncAssociatedWaybills(loadingManage, STATUS_RUNNING, new ArrayList<>());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean cancel(Long id) {
|
||||
@@ -817,6 +844,70 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
// 保持与现有业务模块一致,包装类已完成主字段映射,这里预留兼容入口。
|
||||
}
|
||||
|
||||
private void fillDriverRejected(List<LoadingManageVO> records) {
|
||||
if (Func.isEmpty(records)) {
|
||||
return;
|
||||
}
|
||||
List<String> loadingNos = records.stream()
|
||||
.map(LoadingManage::getLoadingNo)
|
||||
.filter(Func::isNotEmpty)
|
||||
.distinct()
|
||||
.toList();
|
||||
Set<String> rejectedLoadingNos = new HashSet<>();
|
||||
if (Func.isNotEmpty(loadingNos)) {
|
||||
rejectedLoadingNos.addAll(waybillMapper.selectList(Wrappers.<Waybill>lambdaQuery()
|
||||
.select(Waybill::getLoadingNo)
|
||||
.in(Waybill::getLoadingNo, loadingNos)
|
||||
.eq(Waybill::getIsDeleted, 0)
|
||||
.eq(Waybill::getDriverAcceptStatus, WaybillProcessSupport.ACCEPT_REJECTED))
|
||||
.stream()
|
||||
.map(Waybill::getLoadingNo)
|
||||
.filter(Func::isNotEmpty)
|
||||
.collect(Collectors.toSet()));
|
||||
}
|
||||
for (LoadingManageVO record : records) {
|
||||
record.setDriverRejected(rejectedLoadingNos.contains(record.getLoadingNo()));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasDriverRejectedWaybill(LoadingManage loadingManage) {
|
||||
if (Func.isNotEmpty(loadingManage.getLoadingNo())) {
|
||||
Long count = waybillMapper.selectCount(Wrappers.<Waybill>lambdaQuery()
|
||||
.eq(Waybill::getLoadingNo, loadingManage.getLoadingNo())
|
||||
.eq(Waybill::getIsDeleted, 0)
|
||||
.eq(Waybill::getDriverAcceptStatus, WaybillProcessSupport.ACCEPT_REJECTED));
|
||||
if (count != null && count > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
List<Long> ids = waybillIds(loadingManage.getWaybillIdsJson());
|
||||
if (Func.isEmpty(ids)) {
|
||||
return false;
|
||||
}
|
||||
Long count = waybillMapper.selectCount(Wrappers.<Waybill>lambdaQuery()
|
||||
.in(Waybill::getId, ids)
|
||||
.eq(Waybill::getIsDeleted, 0)
|
||||
.eq(Waybill::getDriverAcceptStatus, WaybillProcessSupport.ACCEPT_REJECTED));
|
||||
return count != null && count > 0;
|
||||
}
|
||||
|
||||
private void clearAssociatedWaybillAcceptRecords(LoadingManage loadingManage) {
|
||||
List<Long> ids = waybillIds(loadingManage.getWaybillIdsJson());
|
||||
var update = Wrappers.<Waybill>lambdaUpdate()
|
||||
.set(Waybill::getDriverAcceptStatus, WaybillProcessSupport.ACCEPT_PENDING)
|
||||
.set(Waybill::getDriverAcceptTime, null)
|
||||
.set(Waybill::getDriverAcceptDriverId, null)
|
||||
.set(Waybill::getDriverRejectTime, null)
|
||||
.set(Waybill::getDriverRejectReason, null);
|
||||
if (Func.isNotEmpty(ids)) {
|
||||
waybillMapper.update(null, update.in(Waybill::getId, ids));
|
||||
return;
|
||||
}
|
||||
if (Func.isNotEmpty(loadingManage.getLoadingNo())) {
|
||||
waybillMapper.update(null, update.eq(Waybill::getLoadingNo, loadingManage.getLoadingNo()));
|
||||
}
|
||||
}
|
||||
|
||||
private String formatMileage(BigDecimal mileage) {
|
||||
if (mileage == null) {
|
||||
return null;
|
||||
|
||||
+1
-1
@@ -572,6 +572,6 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
private synchronized String nextCode() {
|
||||
String prefix = "DL-" + LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE) + "-";
|
||||
int serial = baseMapper.selectMaxSerial(prefix) + 1;
|
||||
return prefix + String.format("%04d", serial);
|
||||
return prefix + String.format("%03d", serial);
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -717,6 +717,18 @@ public class TransportPlanServiceImpl extends BaseServiceImpl<TransportPlanMappe
|
||||
if (Func.isNotEmpty(transportPlan.getRemark())) {
|
||||
queryWrapper.like(TransportPlan::getRemark, transportPlan.getRemark());
|
||||
}
|
||||
if (transportPlan.getPlanStartDateStart() != null) {
|
||||
queryWrapper.ge(TransportPlan::getPlanStartDate, transportPlan.getPlanStartDateStart());
|
||||
}
|
||||
if (transportPlan.getPlanStartDateEnd() != null) {
|
||||
queryWrapper.le(TransportPlan::getPlanStartDate, transportPlan.getPlanStartDateEnd());
|
||||
}
|
||||
if (transportPlan.getCreateTimeStart() != null) {
|
||||
queryWrapper.ge(TransportPlan::getCreateTime, transportPlan.getCreateTimeStart());
|
||||
}
|
||||
if (transportPlan.getCreateTimeEnd() != null) {
|
||||
queryWrapper.le(TransportPlan::getCreateTime, transportPlan.getCreateTimeEnd());
|
||||
}
|
||||
queryWrapper.orderByDesc(TransportPlan::getCreateTime);
|
||||
return queryWrapper;
|
||||
}
|
||||
@@ -800,7 +812,7 @@ public class TransportPlanServiceImpl extends BaseServiceImpl<TransportPlanMappe
|
||||
}
|
||||
|
||||
private boolean shouldSkipDelete(TransportPlan transportPlan) {
|
||||
return false;
|
||||
return !"draft".equals(transportPlan.getBusinessStatus());
|
||||
}
|
||||
|
||||
private synchronized String nextCode() {
|
||||
|
||||
+6
-3
@@ -475,7 +475,10 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
}
|
||||
} else {
|
||||
waybill.setLoadingNo(null);
|
||||
waybill.setMasterNo(null);
|
||||
waybill.setMileageRemark(null);
|
||||
// 新建(含复制后提交)不沿用源单据状态,与纯新增一致
|
||||
waybill.setBusinessStatus(null);
|
||||
}
|
||||
// 无过程快照时按项目回填;再按接单设置决定 pending / running
|
||||
fillProjectProcessConfig(waybill);
|
||||
@@ -717,13 +720,12 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
target.setOtherFeeTotal(source.getOtherFeeTotal());
|
||||
target.setTaskRemark(source.getTaskRemark());
|
||||
target.setOriginalNo(source.getOriginalNo());
|
||||
target.setBusinessStatus(source.getBusinessStatus());
|
||||
target.setDataSource(source.getDataSource());
|
||||
target.setStartDate(source.getStartDate());
|
||||
target.setEndDate(source.getEndDate());
|
||||
target.setPlanId(source.getPlanId());
|
||||
target.setPlanName(source.getPlanName());
|
||||
target.setMasterNo(source.getMasterNo());
|
||||
target.setMasterNo(null);
|
||||
target.setLoadingNo(null);
|
||||
target.setBatchNo(source.getBatchNo());
|
||||
target.setRelationNo(source.getRelationNo());
|
||||
@@ -736,7 +738,8 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
||||
target.setFreightJson(source.getFreightJson());
|
||||
target.setAttachmentsJson(source.getAttachmentsJson());
|
||||
target.setRemark(source.getRemark());
|
||||
target.setBusinessStatus("pending");
|
||||
// 复制后状态与新增一致:先置空,再按过程配置校正为 pending/running
|
||||
target.setBusinessStatus(null);
|
||||
target.setWaybillNo(nextCode());
|
||||
clearDriverAcceptRecord(target);
|
||||
fillProjectProcessConfig(target);
|
||||
|
||||
Reference in New Issue
Block a user