Merge remote-tracking branch 'origin/main' into main

This commit is contained in:
xiaocp2009 2025-08-29 16:15:20 +08:00
commit 3b9c58f4d9
5 changed files with 69 additions and 21 deletions

View File

@ -86,7 +86,7 @@ public class MpsManualPricingController extends BaseController {
public R<Void> importData(@RequestPart("file") MultipartFile file, boolean updateSupport,
@RequestParam @DateTimeFormat(pattern = "yyyy-MM") Date importMonth) throws Exception {
String importTime = DateUtils.parseDateToStr(FormatsType.YYYY_MM,importMonth);
mpsManualPricingService.deleteDataByMonth(importTime);
// mpsManualPricingService.deleteDataByMonth(importTime);
ExcelResult<MpsManualPricingImportVo> result = ExcelUtil.importExcel(file.getInputStream(), MpsManualPricingImportVo.class, new MpsManualPricingImportListener(updateSupport,importTime));
return R.ok(result.getAnalysis());
}

View File

@ -36,6 +36,7 @@ public class MpsManualPricing extends TenantEntity {
/**
* 员工身份证号
*/
@TableField(value = "idcard_no")
private String idcardNo;
/**
@ -111,6 +112,7 @@ public class MpsManualPricing extends TenantEntity {
/**
* 日期
*/
@TableField(value = "import_time")
private String importTime;
/**

View File

@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.original.domain.OriginalHeat;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.dromara.mps.domain.bo.MpsManualPricingBo;
import org.dromara.mps.domain.vo.MpsManualPricingVo;
@ -20,7 +20,10 @@ import org.dromara.mps.mapper.MpsManualPricingMapper;
import org.dromara.mps.service.IMpsManualPricingService;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 手工导入计价Service业务层处理
@ -43,11 +46,56 @@ public class MpsManualPricingServiceImpl implements IMpsManualPricingService {
}
// 业务校验可选,参照demo
//validateBusinessRules(list);
validateBusinessRules(list);
// 2. 批量插入/更新
if (isUpdateSupport) {
baseMapper.insertOrUpdateBatch(list);
// 1. 先查询所有具有相同import_time的记录
List<MpsManualPricing> existingData = baseMapper.selectList(
Wrappers.<MpsManualPricing>lambdaQuery()
.in(MpsManualPricing::getImportTime,
list.stream()
.map(MpsManualPricing::getImportTime)
.distinct()
.collect(Collectors.toList())
)
);
// 2. 构建身份证号到ID的映射
Map<String, MpsManualPricing> idcardToRecordMap = existingData.stream()
.collect(Collectors.toMap(
MpsManualPricing::getIdcardNo,
Function.identity(),
(oldValue, newValue) -> oldValue // 如果有重复身份证号保留第一个
));
// 3. 处理待插入的数据合并ID
List<MpsManualPricing> processedList = new ArrayList<>();
for (MpsManualPricing item : list) {
MpsManualPricing copy = new MpsManualPricing();
BeanUtils.copyProperties(item, copy);
// 如果找到匹配的ID则设置ID
if (idcardToRecordMap.containsKey(copy.getIdcardNo())) {
MpsManualPricing existing = idcardToRecordMap.get(copy.getIdcardNo());
copy.setId(existing.getId());
// 并新旧数据计算
BigDecimal total = (
copy.getMerchantRetentionRate() != null ? copy.getMerchantRetentionRate() : existing.getMerchantRetentionRate())
.add(copy.getNewPartyFeeUnits() != null ? copy.getNewPartyFeeUnits() : existing.getNewPartyFeeUnits())
.add(copy.getNewPropertyFeeUnits() != null ? copy.getNewPropertyFeeUnits() : existing.getNewPropertyFeeUnits())
.add(copy.getNewCateringFeeUnits() != null ? copy.getNewCateringFeeUnits() : existing.getNewCateringFeeUnits())
.add(copy.getNewForeignAccounts() != null ? copy.getNewForeignAccounts() : existing.getNewForeignAccounts())
.add(copy.getNewIndividualTreasury() != null ? copy.getNewIndividualTreasury() : existing.getNewIndividualTreasury())
.add(copy.getNewCorporateTreasury() != null ? copy.getNewCorporateTreasury() : existing.getNewCorporateTreasury())
.add(copy.getTreasuryTransactions() != null ? copy.getTreasuryTransactions() : existing.getTreasuryTransactions())
.add(copy.getRegularProducts() != null ? copy.getRegularProducts() : existing.getRegularProducts())
.add(copy.getNewHousingFund() != null ? copy.getNewHousingFund() : existing.getNewHousingFund());
copy.setTotalScore(total);
}
processedList.add(copy);
}
baseMapper.insertOrUpdateBatch(processedList);
} else {
// baseMapper.insertBatch(list);
@ -77,16 +125,16 @@ public class MpsManualPricingServiceImpl implements IMpsManualPricingService {
}
// 示例业务重复检查
/*private void validateBusinessRules(Collection<MpsManualPricingBo> list) {
private void validateBusinessRules(Collection<MpsManualPricing> list) {
Set<String> uniqueKeys = new HashSet<>();
for (MpsManualPricingBo bo : list) {
String key = bo.getCustAcctNo();
for (MpsManualPricing bo : list) {
String key = bo.getIdcardNo();
if (uniqueKeys.contains(key)) {
throw new ServiceException("重复的客户账号: " + key);
}
uniqueKeys.add(key);
}
} */
}
/**
* 查询手工导入计价

View File

@ -15,7 +15,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
marketing_code,
add_item,
record_month,
tenant_id,
create_dept,
create_by,
create_time,
@ -32,7 +31,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.marketingCode},
#{item.addItem},
#{item.recordMonth},
#{item.tenantId},
#{item.createDept},
#{item.createBy},
#{item.createTime},

View File

@ -48,17 +48,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.name},
#{item.position},
#{item.marketingCode},
#{item.merchantRetentionRate},
#{item.newPartyFeeUnits},
#{item.newPropertyFeeUnits},
#{item.newCateringFeeUnits},
#{item.newForeignAccounts},
#{item.newIndividualTreasury},
#{item.newCorporateTreasury},
#{item.treasuryTransactions},
#{item.regularProducts},
#{item.newHousingFund},
#{item.totalScore},
COALESCE(#{item.merchantRetentionRate},0.00),
COALESCE(#{item.newPartyFeeUnits},0.00),
COALESCE(#{item.newPropertyFeeUnits},0.00),
COALESCE(#{item.newCateringFeeUnits},0.00),
COALESCE(#{item.newForeignAccounts},0.00),
COALESCE(#{item.newIndividualTreasury},0.00),
COALESCE(#{item.newCorporateTreasury},0.00),
COALESCE(#{item.treasuryTransactions},0.00),
COALESCE(#{item.regularProducts},0.00),
COALESCE(#{item.newHousingFund},0.00),
COALESCE(#{item.totalScore},0.00),
#{item.importTime},
#{item.fill1},
#{item.fill2},