fix bug
This commit is contained in:
+3
@@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.springblade.transport.pojo.entity;
|
package org.springblade.transport.pojo.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -76,6 +78,7 @@ public class CommonCargo extends TenantEntity {
|
|||||||
private String packageType;
|
private String packageType;
|
||||||
|
|
||||||
@Schema(description = "货值")
|
@Schema(description = "货值")
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
private BigDecimal cargoValue;
|
private BigDecimal cargoValue;
|
||||||
|
|
||||||
@Schema(description = "规格")
|
@Schema(description = "规格")
|
||||||
|
|||||||
+15
@@ -41,6 +41,21 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface DriverMapper extends BaseMapper<Driver> {
|
public interface DriverMapper extends BaseMapper<Driver> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按身份证号查询司机(包含逻辑删除记录,用于唯一性校验)。
|
||||||
|
*/
|
||||||
|
Driver selectByIdCardNoIncludingDeleted(@Param("idCardNo") String idCardNo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按主键查询司机(包含逻辑删除记录,用于提交前校验)。
|
||||||
|
*/
|
||||||
|
Driver selectByIdIncludingDeleted(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复逻辑删除司机。
|
||||||
|
*/
|
||||||
|
int restoreById(@Param("id") Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义分页
|
* 自定义分页
|
||||||
*
|
*
|
||||||
|
|||||||
+22
@@ -90,6 +90,28 @@
|
|||||||
remark
|
remark
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectByIdCardNoIncludingDeleted" resultType="org.springblade.transport.pojo.entity.Driver">
|
||||||
|
SELECT
|
||||||
|
<include refid="BaseColumn"/>
|
||||||
|
FROM blade_transport_driver
|
||||||
|
WHERE id_card_no = #{idCardNo}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByIdIncludingDeleted" resultType="org.springblade.transport.pojo.entity.Driver">
|
||||||
|
SELECT
|
||||||
|
<include refid="BaseColumn"/>
|
||||||
|
FROM blade_transport_driver
|
||||||
|
WHERE id = #{id}
|
||||||
|
LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="restoreById">
|
||||||
|
UPDATE blade_transport_driver
|
||||||
|
SET is_deleted = 0
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<sql id="ExpiryExpiredCondition">
|
<sql id="ExpiryExpiredCondition">
|
||||||
(
|
(
|
||||||
((driving_license_long_term IS NULL OR driving_license_long_term != 1) AND driving_license_end_date < #{driver.today})
|
((driving_license_long_term IS NULL OR driving_license_long_term != 1) AND driving_license_end_date < #{driver.today})
|
||||||
|
|||||||
+7
@@ -43,6 +43,7 @@ import org.springblade.transport.wrapper.CommonCargoWrapper;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -115,6 +116,7 @@ public class CommonCargoServiceImpl extends BaseServiceImpl<CommonCargoMapper, C
|
|||||||
return list(queryWrapper).stream().map(record -> {
|
return list(queryWrapper).stream().map(record -> {
|
||||||
CommonCargoExportExcel excel = new CommonCargoExportExcel();
|
CommonCargoExportExcel excel = new CommonCargoExportExcel();
|
||||||
BeanUtil.copyProperties(record, excel);
|
BeanUtil.copyProperties(record, excel);
|
||||||
|
excel.setCargoValue(normalizeCargoValue(record.getCargoValue()));
|
||||||
excel.setPackageBrand(String.join(" / ", List.of(
|
excel.setPackageBrand(String.join(" / ", List.of(
|
||||||
Func.isEmpty(record.getPackageType()) ? "" : record.getPackageType(),
|
Func.isEmpty(record.getPackageType()) ? "" : record.getPackageType(),
|
||||||
Func.isEmpty(record.getBrand()) ? "" : record.getBrand()
|
Func.isEmpty(record.getBrand()) ? "" : record.getBrand()
|
||||||
@@ -255,6 +257,7 @@ public class CommonCargoServiceImpl extends BaseServiceImpl<CommonCargoMapper, C
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void prepare(CommonCargo commonCargo) {
|
private void prepare(CommonCargo commonCargo) {
|
||||||
|
commonCargo.setCargoValue(normalizeCargoValue(commonCargo.getCargoValue()));
|
||||||
commonCargo.setFirstCargoTypeName(TransportBusinessSupport.trimToNull(commonCargo.getFirstCargoTypeName()));
|
commonCargo.setFirstCargoTypeName(TransportBusinessSupport.trimToNull(commonCargo.getFirstCargoTypeName()));
|
||||||
commonCargo.setFirstCargoTypeCode(TransportBusinessSupport.trimToNull(commonCargo.getFirstCargoTypeCode()));
|
commonCargo.setFirstCargoTypeCode(TransportBusinessSupport.trimToNull(commonCargo.getFirstCargoTypeCode()));
|
||||||
commonCargo.setSecondCargoTypeName(TransportBusinessSupport.trimToNull(commonCargo.getSecondCargoTypeName()));
|
commonCargo.setSecondCargoTypeName(TransportBusinessSupport.trimToNull(commonCargo.getSecondCargoTypeName()));
|
||||||
@@ -280,6 +283,10 @@ public class CommonCargoServiceImpl extends BaseServiceImpl<CommonCargoMapper, C
|
|||||||
if (commonCargo.getStatus() == null) { commonCargo.setStatus(1); }
|
if (commonCargo.getStatus() == null) { commonCargo.setStatus(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BigDecimal normalizeCargoValue(BigDecimal cargoValue) {
|
||||||
|
return cargoValue != null && cargoValue.compareTo(BigDecimal.ONE.negate()) == 0 ? null : cargoValue;
|
||||||
|
}
|
||||||
|
|
||||||
private void validate(CommonCargo commonCargo) {
|
private void validate(CommonCargo commonCargo) {
|
||||||
TransportBusinessSupport.validateRequired(commonCargo.getFirstCargoTypeName(), "请选择一级货物类型");
|
TransportBusinessSupport.validateRequired(commonCargo.getFirstCargoTypeName(), "请选择一级货物类型");
|
||||||
TransportBusinessSupport.validateRequired(commonCargo.getSecondCargoTypeCode(), "请选择二级货物类型");
|
TransportBusinessSupport.validateRequired(commonCargo.getSecondCargoTypeCode(), "请选择二级货物类型");
|
||||||
|
|||||||
+26
-8
@@ -27,7 +27,6 @@ package org.springblade.transport.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import org.springblade.core.log.exception.ServiceException;
|
import org.springblade.core.log.exception.ServiceException;
|
||||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||||
import org.springblade.core.tool.utils.BeanUtil;
|
import org.springblade.core.tool.utils.BeanUtil;
|
||||||
@@ -73,7 +72,7 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
|||||||
public boolean submit(Driver driver) {
|
public boolean submit(Driver driver) {
|
||||||
prepare(driver);
|
prepare(driver);
|
||||||
validate(driver);
|
validate(driver);
|
||||||
checkUniqueIdCard(driver);
|
prepareSubmitTarget(driver);
|
||||||
return saveOrUpdate(driver);
|
return saveOrUpdate(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,14 +234,33 @@ public class DriverServiceImpl extends BaseServiceImpl<DriverMapper, Driver> imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkUniqueIdCard(Driver driver) {
|
private void prepareSubmitTarget(Driver driver) {
|
||||||
Long count = count(Wrappers.<Driver>lambdaQuery()
|
Driver existingById = Func.isEmpty(driver.getId())
|
||||||
.eq(Driver::getIsDeleted, 0)
|
? null : baseMapper.selectByIdIncludingDeleted(driver.getId());
|
||||||
.eq(Driver::getIdCardNo, driver.getIdCardNo())
|
if (Func.isNotEmpty(driver.getId()) && existingById == null) {
|
||||||
.ne(Func.isNotEmpty(driver.getId()), Driver::getId, driver.getId()));
|
throw new ServiceException("司机不存在,不能提交");
|
||||||
if (count > 0) {
|
}
|
||||||
|
Driver existingByIdCard = baseMapper.selectByIdCardNoIncludingDeleted(driver.getIdCardNo());
|
||||||
|
if (existingByIdCard == null) {
|
||||||
|
if (existingById != null && Objects.equals(existingById.getIsDeleted(), 1)) {
|
||||||
|
throw new ServiceException("司机不存在,不能提交");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
boolean sameRecord = existingById != null
|
||||||
|
&& Objects.equals(existingByIdCard.getId(), existingById.getId());
|
||||||
|
if (!Objects.equals(existingByIdCard.getIsDeleted(), 1)) {
|
||||||
|
if (!sameRecord) {
|
||||||
throw new ServiceException("身份证号已存在");
|
throw new ServiceException("身份证号已存在");
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!sameRecord && Func.isNotEmpty(driver.getId())) {
|
||||||
|
throw new ServiceException("身份证号已存在");
|
||||||
|
}
|
||||||
|
baseMapper.restoreById(existingByIdCard.getId());
|
||||||
|
driver.setId(existingByIdCard.getId());
|
||||||
|
driver.setIsDeleted(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateLength(String value, int maxLength, String message) {
|
private void validateLength(String value, int maxLength, String message) {
|
||||||
|
|||||||
+9
-4
@@ -848,12 +848,14 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
|
|||||||
Map<String, BigDecimal> feeItems = parseFeeItems(feeRow.getFeeItemsJson());
|
Map<String, BigDecimal> feeItems = parseFeeItems(feeRow.getFeeItemsJson());
|
||||||
boolean containsFreight = feeItems.keySet().stream().anyMatch(this::isFreightFeeItem);
|
boolean containsFreight = feeItems.keySet().stream().anyMatch(this::isFreightFeeItem);
|
||||||
if (!containsFreight) {
|
if (!containsFreight) {
|
||||||
aggregates.merge(summaryKey("物流配送", "运输费"), money(feeRow.getFreightAmount()),
|
aggregates.merge(
|
||||||
|
summaryKey(feeTypeMap.getOrDefault("运输费", ""), "运输费"),
|
||||||
|
money(feeRow.getFreightAmount()),
|
||||||
BigDecimal::add);
|
BigDecimal::add);
|
||||||
}
|
}
|
||||||
feeItems.forEach((feeItem, amount) -> aggregates.merge(
|
feeItems.forEach((feeItem, amount) -> aggregates.merge(
|
||||||
summaryKey(feeTypeMap.getOrDefault(feeItem,
|
summaryKey(feeTypeMap.getOrDefault(feeItem,
|
||||||
isFreightFeeItem(feeItem) ? "物流配送" : "其他费用"), feeItem),
|
""), feeItem),
|
||||||
money(amount), BigDecimal::add));
|
money(amount), BigDecimal::add));
|
||||||
}
|
}
|
||||||
summaryFeeMapper.delete(Wrappers.<PreSettlementSummaryFee>lambdaQuery()
|
summaryFeeMapper.delete(Wrappers.<PreSettlementSummaryFee>lambdaQuery()
|
||||||
@@ -884,6 +886,7 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
|
|||||||
|
|
||||||
private void applySummaryRequest(Long settlementId, List<PreSettlementSaveRequest.SummaryFee> requestRows) {
|
private void applySummaryRequest(Long settlementId, List<PreSettlementSaveRequest.SummaryFee> requestRows) {
|
||||||
if (requestRows == null) return;
|
if (requestRows == null) return;
|
||||||
|
Map<String, String> generatedFeeTypeMap = contractFeeTypeMap(loadExisting(settlementId).getContractId());
|
||||||
Map<String, Set<String>> allowedManualFees = new LinkedHashMap<>();
|
Map<String, Set<String>> allowedManualFees = new LinkedHashMap<>();
|
||||||
if (requestRows.stream().anyMatch(row -> Integer.valueOf(1).equals(row.getManualFlag()))) {
|
if (requestRows.stream().anyMatch(row -> Integer.valueOf(1).equals(row.getManualFlag()))) {
|
||||||
for (Map<String, Object> option : feeOptions()) {
|
for (Map<String, Object> option : feeOptions()) {
|
||||||
@@ -935,12 +938,14 @@ public class PreSettlementServiceImpl extends BaseServiceImpl<PreSettlementMappe
|
|||||||
row.getFeeItem() + "金额" + row.getSettlementAmount(), "");
|
row.getFeeItem() + "金额" + row.getSettlementAmount(), "");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
String feeItem = requiredText(requestRow.getFeeItem(), "费用项");
|
||||||
|
String feeType = generatedFeeTypeMap.getOrDefault(feeItem, "");
|
||||||
PreSettlementSummaryFee row = existingMap.get(requestRow.getId());
|
PreSettlementSummaryFee row = existingMap.get(requestRow.getId());
|
||||||
if (row == null) {
|
if (row == null) {
|
||||||
row = existingMap.values().stream()
|
row = existingMap.values().stream()
|
||||||
.filter(item -> !Integer.valueOf(1).equals(item.getManualFlag()))
|
.filter(item -> !Integer.valueOf(1).equals(item.getManualFlag()))
|
||||||
.filter(item -> Objects.equals(item.getFeeType(), requestRow.getFeeType())
|
.filter(item -> Objects.equals(item.getFeeType(), feeType)
|
||||||
&& Objects.equals(item.getFeeItem(), requestRow.getFeeItem()))
|
&& Objects.equals(item.getFeeItem(), feeItem))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
}
|
}
|
||||||
if (row == null || Integer.valueOf(1).equals(row.getManualFlag())) {
|
if (row == null || Integer.valueOf(1).equals(row.getManualFlag())) {
|
||||||
|
|||||||
+4
@@ -30,6 +30,7 @@ import org.springblade.system.cache.UserCache;
|
|||||||
import org.springblade.transport.pojo.entity.CommonCargo;
|
import org.springblade.transport.pojo.entity.CommonCargo;
|
||||||
import org.springblade.transport.pojo.vo.CommonCargoVO;
|
import org.springblade.transport.pojo.vo.CommonCargoVO;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,6 +47,9 @@ public class CommonCargoWrapper extends BaseEntityWrapper<CommonCargo, CommonCar
|
|||||||
@Override
|
@Override
|
||||||
public CommonCargoVO entityVO(CommonCargo commonCargo) {
|
public CommonCargoVO entityVO(CommonCargo commonCargo) {
|
||||||
CommonCargoVO commonCargoVO = Objects.requireNonNull(BeanUtil.copyProperties(commonCargo, CommonCargoVO.class));
|
CommonCargoVO commonCargoVO = Objects.requireNonNull(BeanUtil.copyProperties(commonCargo, CommonCargoVO.class));
|
||||||
|
if (commonCargoVO.getCargoValue() != null && commonCargoVO.getCargoValue().compareTo(BigDecimal.ONE.negate()) == 0) {
|
||||||
|
commonCargoVO.setCargoValue(null);
|
||||||
|
}
|
||||||
commonCargoVO.setCreateUserName(UserCache.getUserRealName(commonCargo.getCreateUser()));
|
commonCargoVO.setCreateUserName(UserCache.getUserRealName(commonCargo.getCreateUser()));
|
||||||
commonCargoVO.setUpdateUserName(UserCache.getUserRealName(commonCargo.getUpdateUser()));
|
commonCargoVO.setUpdateUserName(UserCache.getUserRealName(commonCargo.getUpdateUser()));
|
||||||
Long currentDeptId = Func.firstLong(AuthUtil.getDeptId());
|
Long currentDeptId = Func.firstLong(AuthUtil.getDeptId());
|
||||||
|
|||||||
Reference in New Issue
Block a user