数据权限的bug修改260113
This commit is contained in:
+74
-15
@@ -1326,12 +1326,43 @@ public class BusinessDocumentApplicationService {
|
||||
List<BusinessDocumentDetali> businessDocumentDetaliUpdateList = new ArrayList<>();
|
||||
List<BusinessDocumentDetaliDTO> businessDocumentDetailDtoList = new ArrayList<>();
|
||||
List<Verification> verificationList = new ArrayList<>();
|
||||
log.info("批量审核开始,审核状态:{},待审核数据条数:{}", businessDocumentDetaliDO.getAuditStatus(), detailList.size());
|
||||
|
||||
// 先设置审核人的组织信息,确保在生成应付账单时能够正确获取组织信息
|
||||
Long loginUserOrganizationId = null;
|
||||
String loginUserOrganizationName = null;
|
||||
Long loginUserTopOrganizationId = null;
|
||||
if (loginUser.getUserPo() != null) {
|
||||
loginUserOrganizationId = loginUser.getUserPo().getOrganizationId();
|
||||
loginUserOrganizationName = loginUser.getUserPo().getOrganizationName();
|
||||
loginUserTopOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
}
|
||||
|
||||
for (BusinessDocumentDetali detail:detailList) {
|
||||
log.debug("处理业务单据详情:businessDocumentDetaliId={}, 当前审核状态={}, 目标审核状态={}",
|
||||
detail.getBusinessDocumentDetaliId(), detail.getAuditStatus(), businessDocumentDetaliDO.getAuditStatus());
|
||||
|
||||
if(detail.getAuditStatus()==2||detail.getAuditStatus()==3){
|
||||
log.warn("业务单据详情 businessDocumentDetaliId={} 的审核状态已经是 {}(2=已同意,3=已拒绝),跳过处理",
|
||||
detail.getBusinessDocumentDetaliId(), detail.getAuditStatus());
|
||||
continue;
|
||||
}
|
||||
|
||||
// 在生成应付账单之前,先设置审核人的组织信息,确保 packVerication 能够正确获取组织信息
|
||||
if (loginUserOrganizationId != null) {
|
||||
detail.setOrganizationId(loginUserOrganizationId);
|
||||
}
|
||||
if (loginUserOrganizationName != null) {
|
||||
detail.setOrganizationName(loginUserOrganizationName);
|
||||
}
|
||||
if (loginUserTopOrganizationId != null) {
|
||||
detail.setTopOrganizationId(loginUserTopOrganizationId);
|
||||
}
|
||||
|
||||
//只有同意的才生成应付账单
|
||||
if(businessDocumentDetaliDO.getAuditStatus()==ApproveStatusEnum.AGREE.getKey()){
|
||||
log.info("审核通过,开始生成应付账单:businessDocumentDetaliId={}, firstSubject={}",
|
||||
detail.getBusinessDocumentDetaliId(), detail.getFirstSubject());
|
||||
if(SubjectCodeEnum.first_zycl_clhs.getCode().equals(detail.getFirstSubject())){//车辆核算的单独处理
|
||||
//查询要自有车辆费用明细
|
||||
R<List<SecondSubjectPO>> secondSubjectList = wlhyServiceFeign.getZyclClhsSecondSubjectList(detail.getBusinessCocumentId());
|
||||
@@ -1349,6 +1380,14 @@ public class BusinessDocumentApplicationService {
|
||||
verification.setAuditRemark(businessDocumentDetaliDO.getAuditRemark());
|
||||
verification.setCreateBy(loginUser.getUserid());
|
||||
verification.setCreateByName(loginUser.getUsername());
|
||||
verification.setCreateTime(now);
|
||||
verification.setUpdateTime(now);
|
||||
verification.setUpdateBy(loginUser.getUserid());
|
||||
verification.setUpdateByName(loginUser.getUsername());
|
||||
// 确保 delFlag 被设置(1=正常,2=已删除)
|
||||
if (verification.getDelFlag() == null) {
|
||||
verification.setDelFlag(1);
|
||||
}
|
||||
verification.setPayType(secondSubjectPO.getPayType());
|
||||
verification.setBillRemarks(detail.getRemark());
|
||||
verification.setPaymentMethod(detail.getPaymentMethod());
|
||||
@@ -1359,6 +1398,10 @@ public class BusinessDocumentApplicationService {
|
||||
verification.setPayName(secondSubjectPO.getPayName());
|
||||
}
|
||||
verificationList.add(verification);
|
||||
log.debug("车辆核算二级科目应付账单已添加到列表:businessDocumentDetaliId={}, secondSubject={}, verificationMoney={}, innerNumber={}, delFlag={}, organizationId={}, organizationName={}",
|
||||
detail.getBusinessDocumentDetaliId(), secondSubjectPO.getSecondSubject(),
|
||||
secondSubjectPO.getAmount(), innerNumber, verification.getDelFlag(),
|
||||
verification.getOrganizationId(), verification.getOrganizationName());
|
||||
}
|
||||
}else{
|
||||
throw new ServiceException("查询车辆核算二级科目异常!");
|
||||
@@ -1373,12 +1416,27 @@ public class BusinessDocumentApplicationService {
|
||||
verification.setAuditRemark(businessDocumentDetaliDO.getAuditRemark());
|
||||
verification.setCreateBy(loginUser.getUserid());
|
||||
verification.setCreateByName(loginUser.getUsername());
|
||||
verification.setCreateTime(now);
|
||||
verification.setUpdateTime(now);
|
||||
verification.setUpdateBy(loginUser.getUserid());
|
||||
verification.setUpdateByName(loginUser.getUsername());
|
||||
// 确保 delFlag 被设置(1=正常,2=已删除)
|
||||
if (verification.getDelFlag() == null) {
|
||||
verification.setDelFlag(1);
|
||||
}
|
||||
verification.setPayType(detail.getSecondSubjectName());//付款方式:油卡借款/现金借款=>与二级科目保持一致
|
||||
verification.setBillRemarks(detail.getRemark());
|
||||
verification.setPaymentMethod(detail.getPaymentMethod());
|
||||
verification.setFuelCardNumber(detail.getFuelCardNumber());
|
||||
verificationList.add(verification);
|
||||
log.debug("普通科目应付账单已添加到列表:businessDocumentDetaliId={}, firstSubject={}, secondSubject={}, verificationMoney={}, innerNumber={}, delFlag={}, organizationId={}, organizationName={}",
|
||||
detail.getBusinessDocumentDetaliId(), detail.getFirstSubject(), detail.getSecondSubject(),
|
||||
detail.getAmount(), innerNumber, verification.getDelFlag(),
|
||||
verification.getOrganizationId(), verification.getOrganizationName());
|
||||
}
|
||||
} else {
|
||||
log.info("审核状态不是已同意(当前状态:{}),不生成应付账单:businessDocumentDetaliId={}",
|
||||
businessDocumentDetaliDO.getAuditStatus(), detail.getBusinessDocumentDetaliId());
|
||||
}
|
||||
|
||||
detail.setAuditStatus(businessDocumentDetaliDO.getAuditStatus());//审批结果
|
||||
@@ -1388,21 +1446,7 @@ public class BusinessDocumentApplicationService {
|
||||
detail.setUpdateBy(loginUser.getUserid());
|
||||
detail.setUpdateByName(loginUser.getUsername());
|
||||
detail.setUpdateTime(now);
|
||||
// 设置审核人的组织ID和组织名称
|
||||
if (loginUser.getUserPo() != null) {
|
||||
Long organizationId = loginUser.getUserPo().getOrganizationId();
|
||||
String organizationName = loginUser.getUserPo().getOrganizationName();
|
||||
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
|
||||
if (organizationId != null) {
|
||||
detail.setOrganizationId(organizationId);
|
||||
}
|
||||
if (organizationName != null) {
|
||||
detail.setOrganizationName(organizationName);
|
||||
}
|
||||
if (topOrganizationId != null) {
|
||||
detail.setTopOrganizationId(topOrganizationId);
|
||||
}
|
||||
}
|
||||
// 组织信息已经在生成应付账单之前设置,这里不需要重复设置
|
||||
businessDocumentDetaliUpdateList.add(detail);
|
||||
|
||||
BusinessDocumentDetaliDTO detailDto = new BusinessDocumentDetaliDTO();
|
||||
@@ -1449,11 +1493,26 @@ public class BusinessDocumentApplicationService {
|
||||
}
|
||||
}
|
||||
//应付账单
|
||||
log.info("准备保存应付账单,应付账单数量:{}", verificationList.size());
|
||||
if (!verificationList.isEmpty()){
|
||||
// 记录应付账单详细信息,便于排查
|
||||
for (int i = 0; i < Math.min(verificationList.size(), 3); i++) {
|
||||
Verification v = verificationList.get(i);
|
||||
log.info("应付账单示例[{}]:businessDocumentDetaliId={}, innerNumber={}, verificationMoney={}, firstSubject={}, secondSubject={}",
|
||||
i, v.getBusinessDocumentDetaliId(), v.getInnerNumber(), v.getVerificationMoney(),
|
||||
v.getFirstSubject(), v.getSecondSubject());
|
||||
}
|
||||
|
||||
boolean saveFlag = verificationDomainService.batchAddVerification(verificationList);
|
||||
log.info("保存应付账单结果:saveFlag={}, 应付账单数量={}", saveFlag, verificationList.size());
|
||||
if(!saveFlag){
|
||||
log.error("保存应付账单失败!应付账单数量:{}", verificationList.size());
|
||||
throw new ServiceException("保存应付账单失败!");
|
||||
}
|
||||
log.info("应付账单保存成功,共保存 {} 条记录", verificationList.size());
|
||||
} else {
|
||||
log.warn("应付账单列表为空,未生成任何应付账单。审核状态:{},业务单据详情数量:{}",
|
||||
businessDocumentDetaliDO.getAuditStatus(), detailList.size());
|
||||
}
|
||||
//推送数据到tms:审核通过修改单据状态为【待付款】,审核拒绝修改状态为【已拒绝】并处理相关逻辑
|
||||
if(businessDocumentDetailDtoList.size()>0){
|
||||
|
||||
+13
-5
@@ -168,27 +168,32 @@ public class VerificationApplicationService
|
||||
Long topOrganizationId = userPo.getTopOrganizationId();
|
||||
|
||||
// 数据权限:根据organizationId来设置查询权限
|
||||
// topOrganizationId为null时,为顶级组织(南光组织),查所有;其他组织查自己
|
||||
if (topOrganizationId == null) {
|
||||
// 南光组织:可以查询所有组织的数据
|
||||
// organizationId=2827(南光组织)时,可查全部组织数据;其他组织只能查自己
|
||||
if (loginUserOrganizationId != null && loginUserOrganizationId.equals(2827L)) {
|
||||
// 南光组织(organizationId=2827):可以查询所有组织的数据
|
||||
// 如果前端传递了 organizationId,使用前端传递的值进行过滤
|
||||
// 如果前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId,使用前端传递的值进行过滤
|
||||
// 设置 topOrganizationId 为 -1,作为标记,表示南光组织查询指定组织(不是查询所有)
|
||||
verificationPo.setOrganizationId(frontendOrganizationId);
|
||||
verificationPo.setTopOrganizationId(null);
|
||||
verificationPo.setTopOrganizationId(-1L);
|
||||
log.info("应付账单查询 - 南光组织查询指定组织:organizationId={}", frontendOrganizationId);
|
||||
} else {
|
||||
// 前端没有传递 organizationId,清空组织过滤条件,查询所有组织的数据
|
||||
verificationPo.setOrganizationId(null);
|
||||
verificationPo.setTopOrganizationId(null);
|
||||
log.info("应付账单查询 - 南光组织查询所有组织:不设置组织过滤条件");
|
||||
}
|
||||
} else {
|
||||
// 其他组织:设置organizationId,只查询当前组织的数据
|
||||
// 其他组织只能查询自己组织的数据
|
||||
// 其他组织只能查询自己组织的数据,不能查询其他组织的数据
|
||||
if (frontendOrganizationId != null) {
|
||||
// 前端传递了 organizationId,验证是否与当前登录用户的组织ID一致
|
||||
if (!frontendOrganizationId.equals(loginUserOrganizationId)) {
|
||||
// 前端传递了其他组织的 organizationId,强制使用当前登录用户的组织ID,防止越权查询
|
||||
log.warn("应付账单查询 - 前端传递的组织ID {} 与当前登录用户的组织ID {} 不一致,使用当前登录用户的组织ID进行过滤",
|
||||
frontendOrganizationId, loginUserOrganizationId);
|
||||
verificationPo.setOrganizationId(loginUserOrganizationId);
|
||||
} else {
|
||||
// 前端传递的 organizationId 与当前登录用户的组织ID一致,使用前端传递的值
|
||||
@@ -202,6 +207,9 @@ public class VerificationApplicationService
|
||||
}
|
||||
}
|
||||
|
||||
log.info("应付账单查询 - 设置组织ID后,查询参数:organizationId={}, topOrganizationId={}",
|
||||
verificationPo.getOrganizationId(), verificationPo.getTopOrganizationId());
|
||||
|
||||
return verificationDomainService.selectOutVerificationList(verificationPo);
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -487,6 +487,7 @@ public class ApprovalDocumentImpl extends ServiceImpl<ApprovalDocumentMapper, Ap
|
||||
Verification verification = new Verification();
|
||||
verification.setOrganizationId(businessDocumentDetaliDTO.getOrganizationId());
|
||||
verification.setTopOrganizationId(businessDocumentDetaliDTO.getTopOrganizationId());
|
||||
verification.setOrganizationName(businessDocumentDetaliDTO.getOrganizationName());// 设置组织名称,确保查询时能够正确过滤
|
||||
verification.setVerificationStatus(1);//未支付
|
||||
verification.setBusinessDocumentDetaliId(businessDocumentDetaliDTO.getBusinessDocumentDetaliId());
|
||||
verification.setBusinessDocumentDetaliNumber(businessDocumentDetaliDTO.getBusinessDocumentDetaliNumber());
|
||||
|
||||
+8
-1
@@ -134,7 +134,14 @@ public class VerificationDomainService
|
||||
* @return 结果
|
||||
*/
|
||||
public boolean batchAddVerification(List<Verification> list){
|
||||
return verificationRepositoryImpl.saveBatch(list);
|
||||
if (list == null || list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// 使用自定义的批量插入方法,而不是 MyBatis-Plus 的 saveBatch
|
||||
// 因为自定义的 batchAddVerification 使用了完整的 SQL 插入语句,包含所有必要字段
|
||||
int result = verificationRepositoryImpl.batchAddVerification(list);
|
||||
// 返回 true 表示成功插入(插入行数大于0)
|
||||
return result > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -715,17 +715,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="batchAddVerification" parameterType="java.util.List">
|
||||
insert into verification
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
branch_id,
|
||||
mail_branch,
|
||||
arrive_branch,
|
||||
verification_status,
|
||||
business_document_detali_id,
|
||||
business_document_detali_number,
|
||||
business_document_id,
|
||||
business_document_number,
|
||||
business_type,
|
||||
inner_number,
|
||||
enter_account_time,
|
||||
expense_item,
|
||||
first_subject,
|
||||
second_subject,
|
||||
first_subject_name,
|
||||
second_subject_name,
|
||||
verification_money,
|
||||
audit_remark,
|
||||
pay_id,
|
||||
pay_person,
|
||||
pay_channel,
|
||||
@@ -734,26 +738,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
pay_way_name,
|
||||
bank_number,
|
||||
receipt_number,
|
||||
collection_remark,
|
||||
cancel_collection_remark,
|
||||
pay_remark,
|
||||
waybill_id,
|
||||
waybill_number,
|
||||
waybill_remark,
|
||||
waybill_source,
|
||||
waybill_source_name,
|
||||
revenue_expenses_number,
|
||||
enter_account_id,
|
||||
enter_account_name,
|
||||
cancel_after_verification_id,
|
||||
cancel_after_verification_name,
|
||||
cancel_after_verification_time,
|
||||
cancel_after_verification_type,
|
||||
verification_type,
|
||||
vehicle_id,
|
||||
vehicle_license_plate_number,
|
||||
driver_name,
|
||||
images,
|
||||
account_holder_bank,
|
||||
organization_id,
|
||||
top_organization_id,
|
||||
organization_name,
|
||||
department_id,
|
||||
department_name,
|
||||
payee,
|
||||
pay_name,
|
||||
pay_type,
|
||||
license_number,
|
||||
bill_remarks,
|
||||
payment_method,
|
||||
fuel_card_number,
|
||||
create_time,
|
||||
create_by,
|
||||
create_by_name,
|
||||
@@ -765,17 +763,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#{item.branchId},
|
||||
#{item.mailBranch},
|
||||
#{item.arriveBranch},
|
||||
#{item.verificationStatus},
|
||||
#{item.businessDocumentDetaliId},
|
||||
#{item.businessDocumentDetaliNumber},
|
||||
#{item.businessDocumentId},
|
||||
#{item.businessDocumentNumber},
|
||||
#{item.businessType},
|
||||
#{item.innerNumber},
|
||||
#{item.enterAccountTime},
|
||||
#{item.expenseItem},
|
||||
#{item.firstSubject},
|
||||
#{item.secondSubject},
|
||||
#{item.firstSubjectName},
|
||||
#{item.secondSubjectName},
|
||||
#{item.verificationMoney},
|
||||
#{item.auditRemark},
|
||||
#{item.payId},
|
||||
#{item.payPerson},
|
||||
#{item.payChannel},
|
||||
@@ -784,26 +786,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.payWayName},
|
||||
#{item.bankNumber},
|
||||
#{item.receiptNumber},
|
||||
#{item.collectionRemark},
|
||||
#{item.cancelCollectionRemark},
|
||||
#{item.payRemark},
|
||||
#{item.waybillId},
|
||||
#{item.waybillNumber},
|
||||
#{item.waybillRemark},
|
||||
#{item.waybillSource},
|
||||
#{item.waybillSourceName},
|
||||
#{item.revenueExpensesNumber},
|
||||
#{item.enterAccountId},
|
||||
#{item.enterAccountName},
|
||||
#{item.cancelAfterVerificationId},
|
||||
#{item.cancelAfterVerificationName},
|
||||
#{item.cancelAfterVerificationTime},
|
||||
#{item.cancelAfterVerificationType},
|
||||
#{item.verificationType},
|
||||
#{item.vehicleId},
|
||||
#{item.vehicleLicensePlateNumber},
|
||||
#{item.driverName},
|
||||
#{item.images},
|
||||
#{item.accountHolderBank},
|
||||
#{item.organizationId},
|
||||
#{item.topOrganizationId},
|
||||
#{item.organizationName},
|
||||
#{item.departmentId},
|
||||
#{item.departmentName},
|
||||
#{item.payee},
|
||||
#{item.payName},
|
||||
#{item.payType},
|
||||
#{item.licenseNumber},
|
||||
#{item.billRemarks},
|
||||
#{item.paymentMethod},
|
||||
#{item.fuelCardNumber},
|
||||
#{item.createTime},
|
||||
#{item.createBy},
|
||||
#{item.createByName},
|
||||
@@ -1015,19 +1011,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectVerificationVo"/>
|
||||
<where>
|
||||
and v.del_flag = 1
|
||||
<!-- 组织查询条件:南光组织查所有,其他组织查自己 -->
|
||||
<!-- 组织查询条件:南光组织(organizationId=2827)查所有,其他组织查自己 -->
|
||||
<if test="organizationId != null">
|
||||
<choose>
|
||||
<!-- 南光组织判断:如果topOrganizationId为null,则为顶级组织(南光组织),查所有 -->
|
||||
<when test="topOrganizationId == null">
|
||||
<!-- 南光组织查所有数据,不添加组织过滤条件 -->
|
||||
<!-- 南光组织查询所有数据:topOrganizationId为null且organizationId=2827(这种情况不应该出现,因为查询所有时organizationId为null) -->
|
||||
<!-- 但为了兼容性,保留此判断 -->
|
||||
<when test="topOrganizationId == null and organizationId == 2827">
|
||||
<!-- 南光组织查询所有数据,不添加组织过滤条件 -->
|
||||
<!-- 如果organizationName为null,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||
<if test="organizationName == null or organizationName == ''">
|
||||
AND v.organization_name IS NOT NULL
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
<!-- 其他组织只查自己组织的数据 -->
|
||||
<!-- 其他情况:查询指定组织的数据(包括南光组织查询指定组织的情况,此时topOrganizationId=-1) -->
|
||||
AND v.organization_id = #{organizationId}
|
||||
<!-- organizationName为null时,根据组织ID查询时不显示organizationName为null的数据 -->
|
||||
<if test="organizationName == null or organizationName == ''">
|
||||
@@ -1036,6 +1033,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<!-- 如果 organizationId 为 null,表示查询所有组织的数据(南光组织查询全部) -->
|
||||
<if test="organizationId == null">
|
||||
<!-- 查询所有组织的数据,只过滤 organization_name 不为 null 的数据 -->
|
||||
AND v.organization_name IS NOT NULL
|
||||
</if>
|
||||
<if test="businessDocumentNumberList != null and businessDocumentNumberList.size() != 0">
|
||||
AND v.business_document_number in
|
||||
<foreach item="waybill" collection="businessDocumentNumberList" open="(" separator="," close=")">
|
||||
|
||||
Reference in New Issue
Block a user