Kaynağa Gözat

修改bug:
私有应收-跟单,结算报表显示不对,有永诚,无法显示

jiakai 3 ay önce
ebeveyn
işleme
29fa47fefc

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/finance/dto/InsPlyIncomeDto.java

@@ -58,6 +58,10 @@ public class InsPlyIncomeDto extends BaseModel {
     @TableField(exist = false)
     private String signYear;
 
+    @Schema(description = "签单月份")
+    @TableField(exist = false)
+    private String signMonth;
+
     @Schema(description = "签单日期 yyyy-mm-dd 格式")
     @TableField(exist = false)
     private String signDate;

+ 56 - 9
tenant/organization/src/main/java/com/jzg/organization/service/impl/ReceivableServiceImpl.java

@@ -25,10 +25,7 @@ import com.jzg.commons.entity.finance.dto.*;
 import com.jzg.commons.entity.finance.po.*;
 import com.jzg.commons.entity.finance.vo.*;
 import com.jzg.commons.entity.orders.po.InsOrderAdjust;
-import com.jzg.commons.entity.po.EsmInsCompany;
-import com.jzg.commons.entity.po.InsFeeOrders;
-import com.jzg.commons.entity.po.PtlAgreement;
-import com.jzg.commons.entity.po.SysUploadFiles;
+import com.jzg.commons.entity.po.*;
 import com.jzg.commons.entity.quote.vo.orders.InsOrdersVo;
 import com.jzg.commons.entity.vo.PtlAgreementCostRatioVo;
 import com.jzg.commons.exception.ServiceException;
@@ -792,15 +789,65 @@ public class ReceivableServiceImpl extends ServiceImpl<ReceivableMapper, InsPlyI
             // 未结算金额
             followCompanyFeeVO.setTotalUnSettlementAmount(totalInvoiced.subtract(totalSettlementAmount));
             followCompanyFeeVO.setCompanyName(null != data.get(partnerCompanyId) ? data.get(partnerCompanyId).getName() : "");
+            followCompanyFeeVO.setYear(year);
+            followCompanyFeeVO.setMonth(month);
 
             resultList.add(followCompanyFeeVO);
         }
 
-//        for (FollowCompanyFeeVO followCompanyFeeVo : followCompanyFeeVos) {
-//            followCompanyFeeVo.setCompanyName(null != data.get(followCompanyFeeVo.getPartnerCompanyId()) ? data.get(followCompanyFeeVo.getPartnerCompanyId()).getName() : "");
-//            followCompanyFeeVo.setTotalUnSettlementAmount(followCompanyFeeVo.getTotalInvoiced().subtract(followCompanyFeeVo.getTotalSettlementAmount()));
-//            followCompanyFeeVo.setTotalUnInvoiced(followCompanyFeeVo.getTotalReceivable().subtract(followCompanyFeeVo.getTotalInvoiced()));
-//        }
+
+        // 根据incomes的partnerCompanyId + signYear + signMonth,过滤resultList的partnerCompanyId + year + month,根据过滤后的数据进行partnerCompanyId + signYear + signMonth的分组,然后将过滤后剩余的数据,将入到resultList中,
+        // 并且设置partnerCompanyId、year、month、totalReceivable为incomes的partnerCompanyId、signYear、signMonth、jq_other_costs_premiums + sy_other_costs_premiums
+        List<InsPlyIncomeDto> incomes = baseMapper.queryFollowIncome(null, null, baseController.getSystemCode());
+        if (CollUtil.isNotEmpty(incomes)) {
+            // 1. 将resultList现有数据构建 key: partnerCompanyId_year_month 映射,方便快速匹配
+            Map<String, FollowCompanyFeeVO> existVoMap = resultList.stream()
+                    .collect(Collectors.toMap(
+                            vo -> vo.getPartnerCompanyId() + "_" + vo.getYear() + "_" + vo.getMonth(),
+                            Function.identity(),
+                            (oldVal, newVal) -> oldVal // 重复key保留原有
+                    ));
+
+            // 2. 将incomes按 partnerCompanyId_signYear_signMonth 分组
+            Map<String, List<InsPlyIncomeDto>> incomeGroupMap = incomes.stream()
+                    .collect(Collectors.groupingBy(income -> income.getPartnerCompanyId() + "_" + income.getSignYear() + "_" + income.getSignMonth()));
+
+            // 3. 遍历分组后的收入数据
+            for (Map.Entry<String, List<InsPlyIncomeDto>> entry : incomeGroupMap.entrySet()) {
+                String groupKey = entry.getKey();
+                List<InsPlyIncomeDto> dtoList = entry.getValue();
+                InsPlyIncomeDto firstDto = CollUtil.getFirst(dtoList);
+                String partnerCompanyId = firstDto.getPartnerCompanyId();
+                String signYear = firstDto.getSignYear();
+                String signMonth = firstDto.getSignMonth();
+
+                // 汇总其他费用应收:jq_other_costs_premiums + sy_other_costs_premiums
+                BigDecimal totalOtherReceivable = dtoList.stream()
+                        .map(dto -> new BigDecimal(dto.getJqOtherCostsPremiums()).add(new BigDecimal(dto.getSyOtherCostsPremiums())))
+                        .reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
+
+                // 4. 判断当前分组是否已经存在于resultList(原有跟单数据)
+                FollowCompanyFeeVO existVo = existVoMap.get(groupKey);
+                if (existVo == null) {
+                    // 不存在原有数据,新建VO加入结果集
+                    FollowCompanyFeeVO newVo = new FollowCompanyFeeVO();
+                    newVo.setPartnerCompanyId(partnerCompanyId);
+                    newVo.setYear(signYear);
+                    newVo.setMonth(signMonth);
+                    // 设置总应收为其他费用合计
+                    newVo.setTotalReceivable(totalOtherReceivable);
+                    // 其余金额默认0(无开票、结算数据)
+                    newVo.setTotalInvoiced(BigDecimal.ZERO);
+                    newVo.setTotalUnInvoiced(BigDecimal.ZERO);
+                    newVo.setTotalSettlementAmount(BigDecimal.ZERO);
+                    newVo.setTotalUnSettlementAmount(BigDecimal.ZERO);
+                    // 匹配公司名称
+                    newVo.setCompanyName(null != data.get(partnerCompanyId) ? data.get(partnerCompanyId).getName() : "");
+                    resultList.add(newVo);
+                }
+            }
+        }
+
         return resultList;
     }
 

+ 2 - 0
tenant/organization/src/main/resources/mapper/ReceivableMapper.xml

@@ -2033,6 +2033,7 @@
         a.*,
         date(a.signing_time ) as sign_date,
         year(a.signing_time) as sign_year,
+        month(a.signing_time) as sign_month,
         b.partner_company_id,
         (SELECT eic.name FROM esm_ins_company eic WHERE b.partner_company_id = eic.id AND eic.is_delete = 0) AS partnerCompanyName,
         (SELECT eic.name FROM esm_ins_company eic WHERE a.company_id = eic.id AND eic.is_delete = 0) AS companyName
@@ -2041,6 +2042,7 @@
         <where>
             a.is_delete=0
             AND a.agreement_type = 2
+            AND a.signing_time is not null
             <if test="startYear != null and endYear != null">
                 AND YEAR(a.signing_time) BETWEEN #{startYear} AND #{endYear}
             </if>