调整业务模块
This commit is contained in:
+6
-3
@@ -6,6 +6,7 @@ package org.springblade.transport.excel;
|
||||
|
||||
import cn.idev.excel.annotation.ExcelIgnore;
|
||||
import cn.idev.excel.annotation.ExcelProperty;
|
||||
import cn.idev.excel.annotation.format.DateTimeFormat;
|
||||
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||
import cn.idev.excel.annotation.write.style.ContentRowHeight;
|
||||
import cn.idev.excel.annotation.write.style.HeadRowHeight;
|
||||
@@ -13,7 +14,7 @@ import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 配载管理 Excel
|
||||
@@ -54,9 +55,11 @@ public class LoadingManageExcel implements Serializable {
|
||||
@ExcelProperty("数据来源")
|
||||
private String dataSource;
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
@DateTimeFormat("yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
@ExcelProperty("过程节点")
|
||||
private String currentProcessNode;
|
||||
@ExcelProperty("状态")
|
||||
|
||||
+13
@@ -14,6 +14,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
||||
import org.springblade.core.tool.jackson.JsonUtil;
|
||||
import org.springblade.core.tool.utils.BeanUtil;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.system.cache.DictCache;
|
||||
import org.springblade.system.pojo.entity.Dept;
|
||||
import org.springblade.transport.excel.LoadingManageExcel;
|
||||
import org.springblade.transport.mapper.LoadingManageMapper;
|
||||
@@ -185,10 +186,22 @@ public class LoadingManageServiceImpl extends BaseServiceImpl<LoadingManageMappe
|
||||
return list(queryWrapper).stream().map(record -> {
|
||||
LoadingManageExcel excel = new LoadingManageExcel();
|
||||
BeanUtil.copyProperties(record, excel);
|
||||
excel.setTransportType(transportTypeName(record.getTransportType()));
|
||||
excel.setCreateTime(record.getCreateTime());
|
||||
excel.setUpdateTime(record.getUpdateTime());
|
||||
excel.setBusinessStatus(LoadingManageWrapper.businessStatusName(record.getBusinessStatus()));
|
||||
return excel;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
private String transportTypeName(String value) {
|
||||
if (Func.isEmpty(value)) {
|
||||
return value;
|
||||
}
|
||||
String name = DictCache.getValue("transport_type", value);
|
||||
return Func.isEmpty(name) ? value : name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public LoadingManageVO copy(Long id) {
|
||||
|
||||
+39
-2
@@ -292,6 +292,7 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
MasterOrderVO vo = Objects.requireNonNull(BeanUtil.copyProperties(entity, MasterOrderVO.class));
|
||||
ContractManage contract = resolveContract(entity);
|
||||
vo.setContractNo(contract == null ? null : contract.getContractNo());
|
||||
if (contract != null && "客户合同".equals(contract.getContractCategory()) && Func.isNotEmpty(contract.getPartyA())) vo.setCustomerName(contract.getPartyA());
|
||||
vo.setRoutes(parseArray(entity.getRouteJson())); vo.setGoods(parseArray(entity.getGoodsJson())); vo.setTotalQuantity(totalQuantity(vo.getGoods()));
|
||||
List<Waybill> boundWaybills = waybillsByMasterNo(entity.getMasterNo());
|
||||
vo.setBoundWaybills(boundWaybills);
|
||||
@@ -329,6 +330,8 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
|
||||
private void copyWritable(MasterOrderVO source, MasterOrder target) {
|
||||
target.setProjectId(source.getProjectId()); target.setProjectName(source.getProjectName()); target.setContractId(source.getContractId()); target.setContractName(source.getContractName()); target.setCustomerName(source.getCustomerName());
|
||||
ContractManage customerContract = resolveContract(source);
|
||||
if (customerContract != null && "客户合同".equals(customerContract.getContractCategory()) && Func.isNotEmpty(customerContract.getPartyA())) target.setCustomerName(customerContract.getPartyA());
|
||||
target.setDepartureName(source.getDepartureName()); target.setDepartureAddress(source.getDepartureAddress()); target.setDepartureContact(source.getDepartureContact()); target.setDeparturePhone(source.getDeparturePhone());
|
||||
target.setArrivalName(source.getArrivalName()); target.setArrivalAddress(source.getArrivalAddress()); target.setArrivalContact(source.getArrivalContact()); target.setArrivalPhone(source.getArrivalPhone());
|
||||
target.setPlanStartTime(source.getPlanStartTime()); target.setPlanEndTime(source.getPlanEndTime()); target.setRouteJson(JsonUtil.toJson(source.getRoutes())); target.setGoodsJson(JsonUtil.toJson(source.getGoods())); target.setAttachmentsJson(source.getAttachmentsJson()); target.setRemark(source.getRemark());
|
||||
@@ -371,7 +374,6 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
BigDecimal quantity = decimal(dispatch, "quantity");
|
||||
if (quantity.compareTo(BigDecimal.ZERO) <= 0) throw new ServiceException("本次数量必须大于0");
|
||||
if (Func.isEmpty(string(dispatch, "quantityUnit"))) throw new ServiceException("数量单位不能为空");
|
||||
if (Func.isEmpty(string(dispatch, "unitPrice"))) throw new ServiceException("单价不能为空");
|
||||
if (Func.isEmpty(string(dispatch, "priceUnit"))) throw new ServiceException("单价单位不能为空");
|
||||
if (!available.containsKey(key)) throw new ServiceException("调度货物必须来自总单配置");
|
||||
LocalDate startDate = date(dispatch, "estimatedStartTime"); LocalDate endDate = date(dispatch, "estimatedEndTime");
|
||||
@@ -383,6 +385,41 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
used.merge(key, quantity, BigDecimal::add);
|
||||
if (used.get(key).compareTo(available.get(key)) > 0) throw new ServiceException("货物【" + string(dispatch, "cargoName") + "】的调度数量超过可调度数量");
|
||||
}
|
||||
validatePreviousSegmentCompletedQuantity(masterOrder, dispatches);
|
||||
}
|
||||
private void validatePreviousSegmentCompletedQuantity(MasterOrder masterOrder, List<Map<String, Object>> dispatches) {
|
||||
List<Map<String, Object>> routes = parseArray(masterOrder.getRouteJson());
|
||||
Map<String, BigDecimal> requestQuantityBySegment = new LinkedHashMap<>();
|
||||
for (Map<String, Object> dispatch : dispatches) {
|
||||
requestQuantityBySegment.merge(string(dispatch, "segmentNo"), decimal(dispatch, "quantity"), BigDecimal::add);
|
||||
}
|
||||
for (int index = 1; index < routes.size(); index++) {
|
||||
Map<String, Object> route = routes.get(index);
|
||||
String segmentNo = string(route, "segmentNo");
|
||||
BigDecimal requestQuantity = requestQuantityBySegment.get(segmentNo);
|
||||
if (requestQuantity == null) continue;
|
||||
BigDecimal dispatchTotal = routeDispatchedQuantity(masterOrder, route).add(requestQuantity);
|
||||
BigDecimal previousCompletedQuantity = completedQuantity(masterOrder.getMasterNo(), routes.get(index - 1));
|
||||
if (dispatchTotal.compareTo(previousCompletedQuantity) > 0) {
|
||||
throw new ServiceException(segmentNo + "调度总量不能大于上一段已完成数量(" + previousCompletedQuantity.stripTrailingZeros().toPlainString() + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
private BigDecimal routeDispatchedQuantity(MasterOrder masterOrder, Map<String, Object> route) {
|
||||
List<Waybill> waybills = waybillsByMasterNo(masterOrder.getMasterNo()).stream()
|
||||
.filter(item -> belongsToRoute(item, route)).toList();
|
||||
List<TransportPlan> plans = transportPlanService.list(new LambdaQueryWrapper<TransportPlan>()
|
||||
.eq(TransportPlan::getMasterNo, masterOrder.getMasterNo())).stream()
|
||||
.filter(item -> belongsToRoute(item, route)).toList();
|
||||
return dispatchedGoods(waybills, plans).values().stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
private BigDecimal completedQuantity(String masterNo, Map<String, Object> route) {
|
||||
return waybillsByMasterNo(masterNo).stream()
|
||||
.filter(item -> "completed".equals(item.getBusinessStatus()))
|
||||
.filter(item -> belongsToRoute(item, route))
|
||||
.flatMap(item -> waybillGoods(item).stream())
|
||||
.map(item -> decimal(item, "quantity"))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
private Map<String, BigDecimal> availableGoods(MasterOrder masterOrder) {
|
||||
Map<String, BigDecimal> available = new LinkedHashMap<>();
|
||||
@@ -435,7 +472,7 @@ public class MasterOrderServiceImpl extends BaseServiceImpl<MasterOrderMapper, M
|
||||
boolean road = transportType.toLowerCase().contains("road") || transportType.contains("公路");
|
||||
String mileage = string(dispatch, "mileage");
|
||||
if (!road) {
|
||||
if (Func.isEmpty(string(dispatch, "vehicleNo")) || Func.isEmpty(string(dispatch, "driverPhone")) || (Func.isNotEmpty(mileage) && decimal(dispatch, "mileage").compareTo(BigDecimal.ZERO) <= 0) || ("承运商".equals(carrierType) && Func.isEmpty(string(dispatch, "carrierName")))) {
|
||||
if (Func.isEmpty(string(dispatch, "vehicleNo")) || (Func.isNotEmpty(mileage) && decimal(dispatch, "mileage").compareTo(BigDecimal.ZERO) <= 0) || ("承运商".equals(carrierType) && Func.isEmpty(string(dispatch, "carrierName")))) {
|
||||
throw new ServiceException("非公路运输的承运信息不完整");
|
||||
}
|
||||
return;
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class LoadingManageWrapper extends BaseEntityWrapper<LoadingManage, Loadi
|
||||
return loadingManageVO;
|
||||
}
|
||||
|
||||
private String businessStatusName(String status) {
|
||||
public static String businessStatusName(String status) {
|
||||
if (status == null) {
|
||||
return "未知";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user