Commit 30d3e955 by 叶立庆

Merge branch 'v5.8.4' into 'master'

上线合并

See merge request !7
2 parents 5c3b9ae7 01f7958d
Showing 27 changed files with 1254 additions and 25 deletions
......@@ -7,7 +7,7 @@
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-financial-api</artifactId>
<version>5.7.1-SNAPSHOT</version>
<version>5.8.4-SNAPSHOT</version>
<name>rpc-dj-financial-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.remote</deploy.scanPackage>
......@@ -57,7 +57,7 @@
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-financial-api</artifactId>
<version>5.7.1-SNAPSHOT</version>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
......
......@@ -2,8 +2,11 @@ package cn.com.glsx.dj.financial.dto;
import cn.com.glsx.dj.financial.model.NbCbAccDetail;
import cn.com.glsx.dj.financial.model.NbCbDetailLog;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.math.BigDecimal;
import java.util.List;
......@@ -16,6 +19,9 @@ import java.util.List;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(value = "NbCbAccDetailDTO", description = "财资明细查询与响应DTO")
public class NbCbAccDetailDTO extends NbCbAccDetail {
/**
......@@ -107,4 +113,40 @@ public class NbCbAccDetailDTO extends NbCbAccDetail {
@ApiModelProperty(name = "custType", notes = "主体类型:1-广联 2-优加", dataType = "Integer")
private Integer custType;
/**
* 财资标签路径名称
*/
@ApiModelProperty(value = "财资标签路径名称")
private String accDetailTagPathName;
/**
* 财务报表口径
*/
@ApiModelProperty(value = "财务报表口径")
private String financialReportCaliber;
/**
* 财资标签名称
*/
@ApiModelProperty(value = "财资标签名称")
private String accDetailTagName;
/**
* 财资标签可选项
*/
@ApiModelProperty(value = "财资标签可选项")
private List<NbCbAccDetailTagDTO> accDetailTagOptions;
/**
* 财务报表口径可选项
*/
@ApiModelProperty(value = "财务报表口径可选项")
private List<String> financialReportCaliberOptions;
/**
* 子孙标签ID列表(协助查询)
*/
@ApiModelProperty(value = "子孙标签ID列表", hidden = true)
private List<Integer> descendantTagIds;
}
package cn.com.glsx.dj.financial.dto;
import cn.com.glsx.dj.financial.model.NbCbAccDetail;
import cn.com.glsx.dj.financial.model.NbCbAccDetailTag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 财资汇总报表上下文。
*
* 承载报表导出需要的原始聚合数据,不包含 Excel sheet 结构。
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@ToString
@ApiModel(value = "NbCbAccDetailSummaryReportContext", description = "财资汇总报表上下文")
public class NbCbAccDetailSummaryReportContext implements Serializable {
private static final long serialVersionUID = -1678745088920035456L;
@ApiModelProperty(value = "统计开始日期")
private Date startDate;
@ApiModelProperty(value = "统计结束日期")
private Date endDate;
@ApiModelProperty(value = "统计月份列表,格式 yyyy-MM")
private List<String> monthKeys;
@ApiModelProperty(value = "全量有效标签")
private List<NbCbAccDetailTag> allTags;
@ApiModelProperty(value = "标签 ID 到标签实体的映射")
private Map<Integer, NbCbAccDetailTag> tagMap;
@ApiModelProperty(value = "标签节点对应的完整三级叶子标签 ID 集合")
private Map<Integer, List<Integer>> leafIdsByTag;
@ApiModelProperty(value = "纳入余额统计的账号列表")
private List<String> balanceAccountNos;
@ApiModelProperty(value = "内部往来检验使用的内部交易明细")
private List<NbCbAccDetail> internalTransactions;
@ApiModelProperty(value = "纳入内部往来检验的内部账号列表")
private List<String> internalAccountNos;
@ApiModelProperty(value = "统计开始日前一日余额")
private BigDecimal beginBalance;
@ApiModelProperty(value = "现金流量表期初现金及现金等价物余额")
private BigDecimal cashFlowBeginBalance;
@ApiModelProperty(value = "各月份月末余额,key 为 yyyy-MM")
private Map<String, BigDecimal> monthEndBalances;
@ApiModelProperty(value = "各月份叶子标签金额汇总,第一层 key 为 yyyy-MM")
private Map<String, Map<Integer, BigDecimal>> monthLeafAmountMap;
@ApiModelProperty(value = "收入口径金额汇总")
private Map<String, BigDecimal> incomeByCaliber;
@ApiModelProperty(value = "支出口径金额汇总")
private Map<String, BigDecimal> expenseByCaliber;
}
package cn.com.glsx.dj.financial.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/**
* 财资汇总报表查询DTO
*
*
*/
@Data
@ApiModel(value = "NbCbAccDetailSummaryReportQueryDTO", description = "财资明细汇总报表查询DTO")
public class NbCbAccDetailSummaryReportQueryDTO implements Serializable {
private static final long serialVersionUID = -4446227866762693837L;
@ApiModelProperty(value = "开始日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date startDate;
@ApiModelProperty(value = "结束日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date endDate;
@ApiModelProperty(value = "操作人")
private String operator;
}
package cn.com.glsx.dj.financial.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 财资明细打标签请求 DTO。
*
*
*/
@Data
@ApiModel(value = "NbCbAccDetailTagBindDTO", description = "财资明细打标签请求DTO")
public class NbCbAccDetailTagBindDTO implements Serializable {
private static final long serialVersionUID = -1352164927777449325L;
@ApiModelProperty(value = "明细ID集合,单条传一个元素,批量传多个元素", required = true)
private List<Long> detailIds;
@ApiModelProperty(value = "三级标签ID,传空表示解绑")
private Integer accDetailTagId;
@ApiModelProperty(value = "操作人")
private String operator;
}
package cn.com.glsx.dj.financial.dto;
import cn.com.glsx.dj.financial.model.NbCbAccDetailTag;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
/**
* 财资标签 DTO。
*
*
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@ApiModel(value = "NbCbAccDetailTagDTO", description = "财资标签DTO")
public class NbCbAccDetailTagDTO extends NbCbAccDetailTag {
private static final long serialVersionUID = 1879806618653593395L;
@ApiModelProperty(value = "子节点列表")
private List<NbCbAccDetailTagDTO> children;
}
package cn.com.glsx.dj.financial.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 财资标签操作预检查结果。
*
* 用于保存前确认、删除前确认等前置交互场景。
*/
@Data
@ApiModel(value = "NbCbAccDetailTagOperationPreviewDTO", description = "财资标签操作预检查结果DTO")
public class NbCbAccDetailTagOperationPreviewDTO implements Serializable {
private static final long serialVersionUID = -1971499528885768320L;
@ApiModelProperty(value = "是否需要前端弹出确认提示")
private Boolean confirmRequired;
@ApiModelProperty(value = "确认或提示文案")
private String message;
}
package cn.com.glsx.dj.financial.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 财资标签树查询 DTO。
*
*
*/
@Data
@ApiModel(value = "NbCbAccDetailTagQueryDTO", description = "财资标签树查询DTO")
public class NbCbAccDetailTagQueryDTO implements Serializable {
private static final long serialVersionUID = 7263672632754205678L;
@ApiModelProperty(value = "节点ID")
private Integer id;
@ApiModelProperty(value = "父节点ID")
private Integer parentId;
@ApiModelProperty(value = "层级")
private Integer level;
@ApiModelProperty(value = "名称模糊查询")
private String nameLike;
@ApiModelProperty(value = "路径查询条件,查询当前路径节点及全部子孙节点")
private String path;
@ApiModelProperty(value = "是否按节点ID查询当前节点及全部子孙节点,需配合id使用")
private Boolean descendantOfId;
@ApiModelProperty(value = "是否为结果补齐全部祖先节点")
private Boolean appendAncestors;
@ApiModelProperty(value = "是否仅返回完整三级标签")
private Boolean onlyComplete;
}
......@@ -14,6 +14,7 @@ public enum AccDetailOperationTypeEnum {
PUSH_RECEIPT((byte)7,"推送回单"),
REPUSH_DETAIL((byte)8,"重推流水明细"),
REPUSH_RECEIPT((byte)9,"重推回单"),
EDIT_CUSTOM_TAG((byte)10,"编辑自定义标签"),
;
private byte value;
......
......@@ -3,6 +3,7 @@ package cn.com.glsx.dj.financial.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import javax.persistence.Column;
......@@ -22,6 +23,7 @@ import java.util.Date;
@SuperBuilder
@Data
@Table(name = "nb_cb_acc_detail")
@ToString
public class NbCbAccDetail implements Serializable {
private static final long serialVersionUID = 3375716007879044226L;
......@@ -251,6 +253,12 @@ public class NbCbAccDetail implements Serializable {
private String labelValue4;
/**
* 财资自定义标签ID
*/
@Column(name = "acc_detail_tag_id")
private Integer accDetailTagId;
/**
* 排序规则
*/
@Column(name = "sort_rule")
......
package cn.com.glsx.dj.financial.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 财资标签目录。
*
*
*/
@Data
@ApiModel(value = "NbCbAccDetailTag", description = "财资标签目录")
@Table(name = "nb_cb_acc_detail_tag")
@ToString
public class NbCbAccDetailTag implements Serializable {
private static final long serialVersionUID = 8253168219092092100L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ApiModelProperty(value = "主键ID")
private Integer id;
@ApiModelProperty(value = "标签名称")
private String name;
@Column(name = "parent_id")
@ApiModelProperty(value = "父节点ID")
private Integer parentId;
@ApiModelProperty(value = "标签层级")
private Integer level;
@ApiModelProperty(value = "ID路径")
private String path;
@Column(name = "path_name")
@ApiModelProperty(value = "名称路径")
private String pathName;
@Column(name = "financial_report_caliber")
@ApiModelProperty(value = "财务报表口径")
private String financialReportCaliber;
@Column(name = "sort_num")
@ApiModelProperty(value = "排序值")
private Integer sortNum;
@ApiModelProperty(value = "状态:1启用,0停用")
private Integer status;
@ApiModelProperty(value = "备注")
private String remark;
@Column(name = "created_date")
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createdDate;
@Column(name = "created_by")
@ApiModelProperty(value = "创建人")
private String createdBy;
@Column(name = "updated_date")
@ApiModelProperty(value = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
@Column(name = "updated_by")
@ApiModelProperty(value = "更新人")
private String updatedBy;
@Column(name = "deleted_flag")
@ApiModelProperty(value = "删除标记")
private String deletedFlag;
}
......@@ -36,9 +36,10 @@ public class NbCbDetailLog implements Serializable {
private Byte logType;
/**
* 操作项 1-重推财资数据 2-推送财资数据 3-获取财资数据 4-获取流水明细 5-获取回单 6-推送流水明细 7-推送回单 8-重推流水明细 9-重推回单
* 操作项 1-重推财资数据 2-推送财资数据 3-获取财资数据 4-获取流水明细 5-获取回单
* 6-推送流水明细 7-推送回单 8-重推流水明细 9-重推回单 10-编辑自定义标签
*/
@ApiModelProperty(notes = "操作项 1-重推财资数据 2-推送财资数据 3-获取财资数据 4-获取流水明细 5-获取回单 6-推送流水明细 7-推送回单 8-重推流水明细 9-重推回单")
@ApiModelProperty(notes = "操作项 1-重推财资数据 2-推送财资数据 3-获取财资数据 4-获取流水明细 5-获取回单 6-推送流水明细 7-推送回单 8-重推流水明细 9-重推回单 10-编辑自定义标签")
@Column(name = "operation_type")
private Byte operationType;
......
package cn.com.glsx.dj.financial.remote;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportContext;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportQueryDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagBindDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagOperationPreviewDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagQueryDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 财资标签与汇总报表远程接口。
*
*
*/
@ApiService(value = "财资标签与汇总报表接口", owner = "lyj", protocol = ApiService.ProtocolEnum.dubbo, version = "1.0.0")
public interface NbCbAccDetailTagSummaryRemote {
@ApiMethod("查询财资标签树")
@ApiParam(name = "queryDTO", notes = "标签树查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("财资标签树")
RpcResponse<List<NbCbAccDetailTagDTO>> queryTagTree(@NotNull NbCbAccDetailTagQueryDTO queryDTO);
@ApiMethod("保存财资标签")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("保存结果")
RpcResponse<Integer> saveTag(@NotNull NbCbAccDetailTagDTO tagDTO);
@ApiMethod("财资标签保存前预检查")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("预检查结果")
RpcResponse<NbCbAccDetailTagOperationPreviewDTO> previewSaveTag(@NotNull NbCbAccDetailTagDTO tagDTO);
@ApiMethod("删除财资标签")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("删除结果")
RpcResponse<Boolean> deleteTag(@NotNull NbCbAccDetailTagDTO tagDTO);
@ApiMethod("财资标签删除前预检查")
@ApiParam(name = "tagDTO", notes = "标签信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("预检查结果")
RpcResponse<NbCbAccDetailTagOperationPreviewDTO> previewDeleteTag(@NotNull NbCbAccDetailTagDTO tagDTO);
@ApiMethod("财资明细打标签")
@ApiParam(name = "bindDTO", notes = "打标签参数", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("打标签结果")
RpcResponse<Boolean> bindDetailTag(@NotNull NbCbAccDetailTagBindDTO bindDTO);
@ApiMethod("生成财资汇总报表导出数据")
@ApiParam(name = "queryDTO", notes = "汇总报表查询条件", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("汇总报表上下文")
RpcResponse<NbCbAccDetailSummaryReportContext> buildAccDetailSummaryReport(@NotNull NbCbAccDetailSummaryReportQueryDTO queryDTO);
}
......@@ -18,7 +18,7 @@
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-financial-api</artifactId>
<version>5.7.1-SNAPSHOT</version>
<version>5.8.4-SNAPSHOT</version>
</dependency>
<!-- RAR解压依赖 -->
......
......@@ -3,6 +3,7 @@ package cn.com.glsx.dj.financial.mapper;
import cn.com.glsx.dj.financial.dto.NbCbAccAssociationDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailDTO;
import cn.com.glsx.dj.financial.model.NbCbAccDetail;
import cn.com.glsx.dj.financial.service.nb.NbCbAccDetailTagAmountSummary;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
......@@ -54,6 +55,20 @@ public interface NbCbAccDetailMapper extends OreMapper<NbCbAccDetail> {
List<NbCbAccDetail> queryByIds(@Param("ids") List<Long> ids);
/**
* 更新明细自定义标签。
*
* @param ids 明细ID
* @param accDetailTagId 自定义标签ID,传空表示解绑
* @param updatedBy 更新人
* @param updatedDate 更新时间
* @return 更新条数
*/
Integer updateAccDetailTagBatch(@Param("ids") List<Long> ids,
@Param("accDetailTagId") Integer accDetailTagId,
@Param("updatedBy") String updatedBy,
@Param("updatedDate") Date updatedDate);
/**
* 查询回单关联的交易明细列表
*
* @param receiptIds
......@@ -62,6 +77,16 @@ public interface NbCbAccDetailMapper extends OreMapper<NbCbAccDetail> {
List<NbCbAccDetail> queryByReceiptIds(@Param("receiptIds") List<Long> receiptIds);
/**
* 查询指定时间范围内的标签月度汇总结果
*
* @param startDateTime 开始时间
* @param endDateTime 结束时间
* @return 汇总结果
*/
List<NbCbAccDetailTagAmountSummary> queryTagAmountSummary(@Param("startDateTime") String startDateTime,
@Param("endDateTime") String endDateTime);
/**
* 查询账号指定日期的余额
*
* @param accList
......@@ -81,6 +106,27 @@ public interface NbCbAccDetailMapper extends OreMapper<NbCbAccDetail> {
List<NbCbAccDetail> queryRealCustomerTrans(@Param("accList") List<String> accList, @Param("innerAccList") List<String> innerAccList, @Param("beginDate") Date beginDate, @Param("endDate") Date endDate);
/**
* 查询内部往来检验明细
*
* @param accountNos 内部账号范围
* @param startDateTime 开始时间
* @param endDateTime 结束时间
* @return 明细列表
*/
List<NbCbAccDetail> queryInternalTransactions(@Param("accountNos") List<String> accountNos,
@Param("startDateTime") String startDateTime,
@Param("endDateTime") String endDateTime,
@Param("custId") String custId);
/**
* 统计标签已被引用的明细数量
*
* @param tagIds 标签ID列表
* @return 明细数量
*/
Integer countByAccDetailTagIds(@Param("tagIds") List<Integer> tagIds);
/**
* 通过回单id反查交易明细
*
* @param receiptIds
......@@ -136,4 +182,4 @@ public interface NbCbAccDetailMapper extends OreMapper<NbCbAccDetail> {
* @return
*/
List<NbCbAccDetail> queryNeedToSyncH5FileDetailList();
}
\ No newline at end of file
}
package cn.com.glsx.dj.financial.mapper;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagQueryDTO;
import cn.com.glsx.dj.financial.model.NbCbAccDetailTag;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
/**
* 财资明细标签 Mapper。
*
*
*/
@Mapper
public interface NbCbAccDetailTagMapper extends OreMapper<NbCbAccDetailTag> {
/**
* 按条件查询标签树节点。
*
* @param queryDTO 标签树查询条件
* @return 标签列表
*/
List<NbCbAccDetailTag> queryTagTreeByCondition(@Param("query") NbCbAccDetailTagQueryDTO queryDTO);
/**
* 查询全部有效标签。
*
* @return 标签列表
*/
List<NbCbAccDetailTag> listAllActiveTags();
/**
* 根据ID集合查询标签
*
* @param ids ID集合
* @return 标签列表
*/
List<NbCbAccDetailTag> listByIds(@Param("ids") List<Integer> ids);
/**
* 统计子标签数量。
*
* @param tagId 标签 ID
* @return 子标签数量
*/
Integer countChildTag(@Param("tagId") Integer tagId);
/**
* 统计当前节点下的全部子孙标签数量
*
* @param pathPrefix 路径前缀
* @return 子孙标签数量
*/
Integer countDescendantTag(@Param("pathPrefix") String pathPrefix);
/**
* 查询当前路径下的全部三级标签ID
*
* @param pathPrefix 路径前缀
* @return 三级标签ID集合
*/
List<Integer> listLeafTagIdsByPathPrefix(@Param("pathPrefix") String pathPrefix);
/**
* 根据标签ID查询标签的path
*
* @param tagId 标签ID
* @return 标签path
*/
String selectPathById(@Param("tagId") Integer tagId);
/**
* 查询指定路径下的所有子孙节点ID(包含当前节点)
*
* @param pathPrefix 路径前缀
* @return 节点ID集合
*/
List<Integer> listDescendantIdsByPath(@Param("pathPrefix") String pathPrefix);
/**
* 按完整路径名称统计重名标签数。
*
* @param currentId 当前标签ID
* @param pathName 完整路径名称
* @return 重名数量
*/
Integer countDuplicateByPathName(@Param("currentId") Integer currentId,
@Param("pathName") String pathName);
/**
* 按路径批量刷新子孙节点路径信息
*
* @param oldPath 原路径
* @param oldPathName 原名称路径
* @param newPath 新路径
* @param newPathName 新名称路径
* @param operator 操作人
* @param now 更新时间
* @return 更新数量
*/
Integer updateDescendantPath(@Param("oldPath") String oldPath,
@Param("oldPathName") String oldPathName,
@Param("newPath") String newPath,
@Param("newPathName") String newPathName,
@Param("operator") String operator,
@Param("now") java.util.Date now);
}
......@@ -4,6 +4,15 @@ import cn.com.glsx.dj.financial.model.NbCbDailyReportAccount;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface NbCbDailyReportAccountMapper extends OreMapper<NbCbDailyReportAccount> {
}
\ No newline at end of file
/**
* 查询启用中的内部账号。
*
* @return 内部账号列表
*/
List<String> listEnabledInternalAccounts();
}
package cn.com.glsx.dj.financial.remote;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportContext;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportQueryDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagBindDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagOperationPreviewDTO;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailTagQueryDTO;
import cn.com.glsx.dj.financial.service.nb.NbCbAccDetailTagSummaryService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
* 财资标签与汇总报表远程服务实现。
*
*
*/
@Slf4j
@DubboService(validation = "true", version = "1.0.0")
public class NbCbAccDetailTagSummaryRemoteImpl implements NbCbAccDetailTagSummaryRemote {
@Autowired
private NbCbAccDetailTagSummaryService nbCbAccDetailTagSummaryService;
@Override
public RpcResponse<List<NbCbAccDetailTagDTO>> queryTagTree(NbCbAccDetailTagQueryDTO queryDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.queryTagTree(queryDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Integer> saveTag(NbCbAccDetailTagDTO tagDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.saveTag(tagDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<NbCbAccDetailTagOperationPreviewDTO> previewSaveTag(NbCbAccDetailTagDTO tagDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.previewSaveTag(tagDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> deleteTag(NbCbAccDetailTagDTO tagDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.deleteTag(tagDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<NbCbAccDetailTagOperationPreviewDTO> previewDeleteTag(NbCbAccDetailTagDTO tagDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.previewDeleteTag(tagDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> bindDetailTag(NbCbAccDetailTagBindDTO bindDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.bindDetailTag(bindDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<NbCbAccDetailSummaryReportContext> buildAccDetailSummaryReport(NbCbAccDetailSummaryReportQueryDTO queryDTO) {
try {
return RpcResponse.success(nbCbAccDetailTagSummaryService.buildAccDetailSummaryReport(queryDTO));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.financial.service.nb;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* 现金流量表汇总行定义。
*
* 用于描述单行的名称、取值标记、取值说明以及计算方式,
* 其中取值标记、取值说明仅作为研发期的内部辅助信息,不作为最终sheet输出列。
* 便于按模板顺序统一组装“现金流量表汇总”sheet。
*
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NbCbAccDetailCashFlowRowDefinition {
/**
* 分组标题行。
*/
public static final String TYPE_SECTION = "SECTION";
/**
* 收入口径行。
*/
public static final String TYPE_INCOME = "INCOME";
/**
* 支出口径行。
*/
public static final String TYPE_EXPENSE = "EXPENSE";
/**
* 手工填写行。
*/
public static final String TYPE_MANUAL = "MANUAL";
/**
* 汇总求和行。
*/
public static final String TYPE_SUM = "SUM";
/**
* 差额计算行。
*/
public static final String TYPE_DIFF = "DIFF";
/**
* 期初余额行。
*/
public static final String TYPE_BEGIN_BALANCE = "BEGIN_BALANCE";
/**
* 行名称。
*/
private String name;
/**
* 模板中的取值标记。
*/
private String marker;
/**
* 模板中的取值说明。
*/
private String description;
/**
* 行类型。
*/
private String type;
/**
* 依赖的来源行名称。
*/
private List<String> refs;
public static NbCbAccDetailCashFlowRowDefinition section(String name) {
return new NbCbAccDetailCashFlowRowDefinition(name, "", "", TYPE_SECTION, Collections.emptyList());
}
public static NbCbAccDetailCashFlowRowDefinition income(String name) {
return new NbCbAccDetailCashFlowRowDefinition(name, "1", "取“报表口径”同名标签金额之和", TYPE_INCOME, Collections.emptyList());
}
public static NbCbAccDetailCashFlowRowDefinition expense(String name) {
return new NbCbAccDetailCashFlowRowDefinition(name, "2", "取“报表口径”同名标签金额之和", TYPE_EXPENSE, Collections.emptyList());
}
public static NbCbAccDetailCashFlowRowDefinition manual(String name) {
return new NbCbAccDetailCashFlowRowDefinition(name, "", "手动填写/无同名财务口径时留空", TYPE_MANUAL, Collections.emptyList());
}
public static NbCbAccDetailCashFlowRowDefinition sum(String name, String... refs) {
return new NbCbAccDetailCashFlowRowDefinition(name, "", "系统汇总计算", TYPE_SUM, Arrays.asList(refs));
}
public static NbCbAccDetailCashFlowRowDefinition diff(String name, String left, String right) {
return new NbCbAccDetailCashFlowRowDefinition(name, "", "系统差额计算", TYPE_DIFF, Arrays.asList(left, right));
}
public static NbCbAccDetailCashFlowRowDefinition beginBalance(String name) {
return new NbCbAccDetailCashFlowRowDefinition(name, "111", "系统获取:统计周期开始日前一日余额", TYPE_BEGIN_BALANCE, Collections.emptyList());
}
}
......@@ -5,10 +5,7 @@ import cn.com.glsx.dj.financial.constants.CommonConstants;
import cn.com.glsx.dj.financial.constants.NbCbDetailLogType;
import cn.com.glsx.dj.financial.dto.*;
import cn.com.glsx.dj.financial.enums.*;
import cn.com.glsx.dj.financial.mapper.ApprovalRecordsMapper;
import cn.com.glsx.dj.financial.mapper.NbCbAccDetailMapper;
import cn.com.glsx.dj.financial.mapper.NbCbDailyReportAccountMapper;
import cn.com.glsx.dj.financial.mapper.NbCbDetailLogMapper;
import cn.com.glsx.dj.financial.mapper.*;
import cn.com.glsx.dj.financial.model.*;
import cn.com.glsx.dj.financial.service.jd.JdInterfaceProxy;
import cn.com.glsx.dj.financial.util.DateUtils;
......@@ -97,6 +94,9 @@ public class NbCbAccDetailService {
private NbCbReceiptService nbReceiptService;
@Autowired
private NbCbAccDetailTagSummaryService nbCbAccDetailTagSummaryService;
@Autowired
private Environment env;
@Autowired
private JdInterfaceProxy jdInterfaceProxy;
......@@ -131,6 +131,9 @@ public class NbCbAccDetailService {
@Autowired
private NbCbCustInfoService nbCbCustInfoService;
@Autowired
private NbCbAccDetailTagMapper nbCbAccDetailTagMapper;
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = RpcServiceException.class)
public void insert(NbCbAccDetail nbAccDetail) {
RpcAssert.assertNotNull(nbAccDetail, DefaultErrorEnum.DATA_NULL, "nbCbReceipt is null");
......@@ -609,6 +612,22 @@ public class NbCbAccDetailService {
//获取主体配置
String custId = nbCbCustInfoService.getCustIdByType(pagination.getCondition().getCustType());
NbCbAccDetailDTO condition = pagination.getCondition();
// 如果传入了 accDetailTagId,先查询其子孙节点ID列表
if (condition.getAccDetailTagId() != null) {
String path = nbCbAccDetailTagMapper.selectPathById(condition.getAccDetailTagId());
List<Integer> descendantIds = Collections.singletonList(-1);
if (path != null) {
List<Integer> tagIds = nbCbAccDetailTagMapper.listDescendantIdsByPath(path);
if (CollectionUtils.isNotEmpty(tagIds)) {
descendantIds = tagIds;
}else {
log.error("未找到标签路径:{}", path);
}
}
condition.setDescendantTagIds(descendantIds);
}
Page<NbCbAccDetailDTO> page = PageHelper.startPage(pagination.getPageNum(), pagination.getPageSize(), pagination.isNeedCount());
// condition.setCustId(env.getProperty("nbcb.custId", "9000919969"));
condition.setCustId(custId);
......@@ -799,20 +818,27 @@ public class NbCbAccDetailService {
// String custId = nbCbCustInfoService.getCustIdByType(NbCbCustEnum.GL_CUST.getCustType());
String custId = nbCbCustInfoService.getCustIdByType(condition.getCustType());
condition.setCustId(custId);
NbCbAccDetailDTO nbCbAccDetailDTO = new NbCbAccDetailDTO();
nbCbAccDetailDTO.setAccNameList(nbCbAccDetailMapper.selectAccNameList(condition));
nbCbAccDetailDTO.setBankTypeList(nbCbAccDetailMapper.selectBankTypeList(condition));
nbCbAccDetailDTO.setBankAccList(nbCbAccDetailMapper.selectBankAccList(condition));
nbCbAccDetailDTO.setBankNameList(nbCbAccDetailMapper.selectBankNameList(condition));
//nbCbAccDetailDTO.setOppAccNameList(nbCbAccDetailMapper.selectOppAccNameList());
//nbCbAccDetailDTO.setOppAccNoList(nbCbAccDetailMapper.selectOppAccNoList());
NbCbAccDetailDTO configDTO = new NbCbAccDetailDTO();
configDTO.setAccNameList(nbCbAccDetailMapper.selectAccNameList(condition));
configDTO.setBankTypeList(nbCbAccDetailMapper.selectBankTypeList(condition));
configDTO.setBankAccList(nbCbAccDetailMapper.selectBankAccList(condition));
configDTO.setBankNameList(nbCbAccDetailMapper.selectBankNameList(condition));
//configDTO.setOppAccNameList(nbCbAccDetailMapper.selectOppAccNameList());
//configDTO.setOppAccNoList(nbCbAccDetailMapper.selectOppAccNoList());
List<CurCodeDTO> curCodeDTOList = new ArrayList<>();
for (CurCodeEnum value : CurCodeEnum.values()) {
curCodeDTOList.add(new CurCodeDTO(value.getValue(), value.getDisplayName()));
}
nbCbAccDetailDTO.setCurCodeList(curCodeDTOList);
return nbCbAccDetailDTO;
configDTO.setCurCodeList(curCodeDTOList);
NbCbAccDetailTagQueryDTO tagQueryDTO = new NbCbAccDetailTagQueryDTO();
tagQueryDTO.setOnlyComplete(true);
tagQueryDTO.setAppendAncestors(true);
List<NbCbAccDetailTagDTO> accDetailTagOptions = nbCbAccDetailTagSummaryService.queryTagTree(tagQueryDTO);
configDTO.setAccDetailTagOptions(accDetailTagOptions);
configDTO.setFinancialReportCaliberOptions(extractFinancialReportCaliberOptions(accDetailTagOptions));
return configDTO;
} catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
......@@ -821,6 +847,36 @@ public class NbCbAccDetailService {
}
}
/**
* 提取可选的财务报表口径列表
*
* @param tagOptions 财资标签树
* @return 口径列表
*/
private List<String> extractFinancialReportCaliberOptions(List<NbCbAccDetailTagDTO> tagOptions) {
LinkedHashSet<String> caliberSet = new LinkedHashSet<>();
collectFinancialReportCaliber(tagOptions, caliberSet);
return new ArrayList<>(caliberSet);
}
/**
* 递归提取财务报表口径
*
* @param tagOptions 财资标签列表
* @param caliberSet 口径集合
*/
private void collectFinancialReportCaliber(List<NbCbAccDetailTagDTO> tagOptions, Set<String> caliberSet) {
if (CollectionUtils.isEmpty(tagOptions)) {
return;
}
for (NbCbAccDetailTagDTO tagOption : tagOptions) {
if (StringUtils.isNotBlank(tagOption.getFinancialReportCaliber())) {
caliberSet.add(tagOption.getFinancialReportCaliber());
}
collectFinancialReportCaliber(tagOption.getChildren(), caliberSet);
}
}
/**
* 批量同步交易明细到金蝶系统
......
package cn.com.glsx.dj.financial.service.nb;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* 财资明细标签月度汇总结果。
*
* 用于承载数据库按“月份 + 三级标签”预聚合后的金额结果,
* 避免在报表生成时一次性把大量明细记录加载到内存再做二次统计。
*
*
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class NbCbAccDetailTagAmountSummary {
/**
* 月份键,格式 yyyy-MM。
*/
private String monthKey;
/**
* 三级标签 ID。
*/
private Integer accDetailTagId;
/**
* 收入金额汇总。
*/
private BigDecimal incomeAmount;
/**
* 支出金额汇总。
*/
private BigDecimal expenseAmount;
/**
* 带方向金额汇总,收入为正,支出为负。
*/
private BigDecimal signedAmount;
}
package cn.com.glsx.dj.financial.service.nb;
import cn.com.glsx.dj.financial.model.NbCbAccDetailTag;
import lombok.Data;
/**
* 财资标签保存上下文
*/
@Data
public class NbCbAccDetailTagSaveContext {
private NbCbAccDetailTag parent;
private NbCbAccDetailTag current;
private String oldPath;
private String oldPathName;
private int targetLevel;
}
......@@ -42,6 +42,7 @@
<result column="label_value2" property="labelValue2" jdbcType="VARCHAR" />
<result column="label_value3" property="labelValue3" jdbcType="VARCHAR" />
<result column="label_value4" property="labelValue4" jdbcType="VARCHAR" />
<result column="acc_detail_tag_id" property="accDetailTagId" jdbcType="INTEGER" />
<result column="sort_rule" property="sortRule" jdbcType="VARCHAR" />
<result column="order_no" property="orderNo" jdbcType="VARCHAR" />
<result column="alipay_trade_name" property="alipayTradeName" jdbcType="VARCHAR" />
......@@ -65,6 +66,9 @@
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.financial.dto.NbCbAccDetailDTO" extends="BaseResultMap">
<result column="receipt_jd_sync" property="receiptJdSync" jdbcType="TINYINT" />
<result column="acc_detail_tag_path_name" property="accDetailTagPathName" jdbcType="VARCHAR" />
<result column="financial_report_caliber" property="financialReportCaliber" jdbcType="VARCHAR" />
<result column="acc_detail_tag_name" property="accDetailTagName" jdbcType="VARCHAR" />
<collection property="logList" ofType="cn.com.glsx.dj.financial.model.NbCbDetailLog">
<id column="dl_id" property="id" jdbcType="BIGINT" />
<id column="dl_acc_detail_id" property="accDetailId" jdbcType="BIGINT" />
......@@ -90,6 +94,14 @@
</association>
</resultMap>
<resultMap id="tagAmountSummaryMap" type="cn.com.glsx.dj.financial.service.nb.NbCbAccDetailTagAmountSummary">
<result column="month_key" property="monthKey" jdbcType="VARCHAR"/>
<result column="acc_detail_tag_id" property="accDetailTagId" jdbcType="INTEGER"/>
<result column="income_amount" property="incomeAmount" jdbcType="DECIMAL"/>
<result column="expense_amount" property="expenseAmount" jdbcType="DECIMAL"/>
<result column="signed_amount" property="signedAmount" jdbcType="DECIMAL"/>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
......@@ -99,9 +111,9 @@
voucher_no, bif_code, bank_type, opp_bank_type, is_for_individual, serial_id, bank_serial_id,
group_trans, capital_trans, post_script, cash_tfr_flg, pay_bill_code, china_develop_bank_no,
china_develop_acc_type, alipay_base_order_number, alipay_business_description, label_value1,
label_value2, label_value3, label_value4, sort_rule, order_no, alipay_trade_name,
label_value2, label_value3, label_value4, acc_detail_tag_id, sort_rule, order_no, alipay_trade_name,
com_pre_remarks, match_code, receipt_info, bill_num, rec_time, opp_area_code, opp_bank_no,
jd_sync, jd_id, h5_jd_sync, created_date, created_by, updated_date, updated_by, deleted_flag
jd_sync, jd_id, h5_jd_sync, data_source, created_date, created_by, updated_date, updated_by, deleted_flag
</sql>
<update id="syncToJdSuccessUpdate">
......@@ -138,8 +150,12 @@
dl.deleted_flag dl_deleted_flag
from
(
select ad.*, ncr.jd_sync as receipt_jd_sync
select ad.*, ncr.jd_sync as receipt_jd_sync,
tag.path_name as acc_detail_tag_path_name,
tag.financial_report_caliber as financial_report_caliber,
tag.name as acc_detail_tag_name
from nb_cb_acc_detail ad
left join nb_cb_acc_detail_tag tag on ad.acc_detail_tag_id = tag.id and tag.deleted_flag = 'N'
left join nb_cb_receipt ncr on ncr.match_code = ad.match_code and ncr.sub_serial_no = ad.sub_serial_no
<include refid="conditionForDetailList"/>
order by ad.trans_time desc
......@@ -152,6 +168,7 @@
<select id="list_COUNT" resultType="Long">
select count(*)
from nb_cb_acc_detail ad
left join nb_cb_acc_detail_tag tag on ad.acc_detail_tag_id = tag.id and tag.deleted_flag = 'N'
left join nb_cb_receipt ncr on ncr.match_code = ad.match_code and ncr.sub_serial_no = ad.sub_serial_no
<include refid="conditionForDetailList"/>
</select>
......@@ -277,6 +294,17 @@
and ad.data_source = #{dataSource}
</if>
<if test="descendantTagIds != null and descendantTagIds.size() > 0">
and ad.acc_detail_tag_id in
<foreach collection="descendantTagIds" item="tagId" open="(" separator="," close=")">
#{tagId}
</foreach>
</if>
<if test="financialReportCaliber != null and financialReportCaliber != ''">
and tag.financial_report_caliber like CONCAT('%',#{financialReportCaliber},'%')
</if>
<if test="transTimeStart != null">
<![CDATA[ and ad.trans_time >= #{transTimeStart} ]]>
</if>
......@@ -382,6 +410,17 @@
and ad.data_source = #{dataSource}
</if>
<if test="descendantTagIds != null and descendantTagIds.size() > 0">
and ad.acc_detail_tag_id in
<foreach collection="descendantTagIds" item="tagId" open="(" separator="," close=")">
#{tagId}
</foreach>
</if>
<if test="financialReportCaliber != null and financialReportCaliber != ''">
and tag.financial_report_caliber like CONCAT('%',#{financialReportCaliber},'%')
</if>
<if test="transTimeStart != null">
<![CDATA[ and ad.trans_time >= #{transTimeStart} ]]>
</if>
......@@ -418,9 +457,39 @@
#{item}
</foreach>
</select>
<update id="updateAccDetailTagBatch">
update nb_cb_acc_detail
set acc_detail_tag_id = #{accDetailTagId},
updated_by = #{updatedBy},
updated_date = #{updatedDate}
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and deleted_flag = 'N'
</update>
<select id="queryTagAmountSummary" resultMap="tagAmountSummaryMap">
select
substring(trans_time, 1, 7) as month_key,
acc_detail_tag_id,
sum(case when cd_sign = '0' then amt else 0 end) as income_amount,
sum(case when cd_sign = '1' then amt else 0 end) as expense_amount,
sum(case when cd_sign = '0' then amt else -amt end) as signed_amount
from nb_cb_acc_detail
where deleted_flag = 'N'
and acc_detail_tag_id is not null
and trans_time <![CDATA[>=]]> #{startDateTime}
and trans_time <![CDATA[<=]]> #{endDateTime}
group by substring(trans_time, 1, 7), acc_detail_tag_id
order by month_key asc, acc_detail_tag_id asc
</select>
<select id="listDistinctBankAcc" resultType="java.lang.String">
select distinct(bank_acc)
from nb_cb_acc_detail ad
left join nb_cb_acc_detail_tag tag on ad.acc_detail_tag_id = tag.id and tag.deleted_flag = 'N'
<include refid="listCondition"/>
</select>
......@@ -479,6 +548,38 @@
and abs not like '%资金归集%'
order by cast(trans_time as datetime) desc
</select>
<select id="queryInternalTransactions" resultMap="BaseResultMap">
select
*
from nb_cb_acc_detail
where deleted_flag = 'N'
<if test="custId != null and custId != ''">
and cust_id = #{custId}
</if>
and bank_acc in
<foreach collection="accountNos" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and opp_acc_no in
<foreach collection="accountNos" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and trans_time <![CDATA[>=]]> #{startDateTime}
and trans_time <![CDATA[<=]]> #{endDateTime}
order by trans_time desc, id desc
</select>
<select id="countByAccDetailTagIds" resultType="java.lang.Integer">
select count(1)
from nb_cb_acc_detail
where deleted_flag = 'N'
and acc_detail_tag_id in
<foreach collection="tagIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectByReceiptIds" resultMap="BaseResultMap">
select
d.*
......@@ -581,4 +682,4 @@
and (d.h5_jd_sync = 0 or d.h5_jd_sync is null)
</select>
</mapper>
\ No newline at end of file
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.financial.mapper.NbCbAccDetailTagMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.financial.model.NbCbAccDetailTag">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="INTEGER"/>
<result column="level" property="level" jdbcType="INTEGER"/>
<result column="path" property="path" jdbcType="VARCHAR"/>
<result column="path_name" property="pathName" jdbcType="VARCHAR"/>
<result column="financial_report_caliber" property="financialReportCaliber" jdbcType="VARCHAR"/>
<result column="sort_num" property="sortNum" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="INTEGER"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, name, parent_id, level, path, path_name, financial_report_caliber, sort_num,
status, remark, created_date, created_by, updated_date, updated_by, deleted_flag
</sql>
<select id="queryTagTreeByCondition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from nb_cb_acc_detail_tag
<where>
deleted_flag = 'N'
<if test="query != null and query.id != null and (query.descendantOfId == null or !query.descendantOfId)">
and id = #{query.id}
</if>
<if test="query != null and query.parentId != null">
and parent_id = #{query.parentId}
</if>
<if test="query != null and query.level != null">
and level = #{query.level}
</if>
<if test="query != null and query.nameLike != null and query.nameLike != ''">
and name like concat('%', #{query.nameLike}, '%')
</if>
<if test="query != null and query.onlyComplete != null and query.onlyComplete">
and level = 3
and (status is null or status = 1)
and financial_report_caliber is not null
and financial_report_caliber != ''
</if>
<if test="query != null and query.path != null and query.path != ''">
and path like concat(#{query.path}, '%')
</if>
</where>
order by level asc, sort_num asc, id asc
</select>
<select id="listAllActiveTags" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
order by level asc, sort_num asc, id asc
</select>
<select id="listByIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
<if test="ids != null and ids.size() > 0">
and id in
<foreach collection="ids" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
order by level asc, sort_num asc, id asc
</select>
<select id="countChildTag" resultType="java.lang.Integer">
select count(1)
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
and parent_id = #{tagId}
</select>
<select id="countDescendantTag" resultType="java.lang.Integer">
select count(1)
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
and path like concat(#{pathPrefix}, '%')
and path != #{pathPrefix}
</select>
<select id="listLeafTagIdsByPathPrefix" resultType="java.lang.Integer">
select id
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
and level = 3
and path like concat(#{pathPrefix}, '%')
order by sort_num asc, id asc
</select>
<select id="selectPathById" resultType="java.lang.String">
select path
from nb_cb_acc_detail_tag
where id = #{tagId}
and deleted_flag = 'N'
limit 1
</select>
<select id="listDescendantIdsByPath" resultType="java.lang.Integer">
select id
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
and path like concat(#{pathPrefix}, '%')
order by level asc, sort_num asc, id asc
</select>
<select id="countDuplicateByPathName" resultType="java.lang.Integer">
select count(1)
from nb_cb_acc_detail_tag
where deleted_flag = 'N'
and path_name = #{pathName}
<if test="currentId != null">
and id != #{currentId}
</if>
</select>
<update id="updateDescendantPath">
update nb_cb_acc_detail_tag
set path = concat(#{newPath}, substring(path, char_length(#{oldPath}) + 1)),
path_name = concat(#{newPathName}, substring(path_name, char_length(#{oldPathName}) + 1)),
updated_by = #{operator},
updated_date = #{now}
where deleted_flag = 'N'
and path like concat(#{oldPath}, '%')
</update>
</mapper>
......@@ -26,4 +26,12 @@
id, account, company_name, short_name, bank_name, remark, company_level, domestic,
status, created_by, created_date, updated_by, updated_date
</sql>
</mapper>
\ No newline at end of file
<select id="listEnabledInternalAccounts" resultType="java.lang.String">
select distinct account
from nb_cb_daily_report_account
where status = 1
and account is not null
and account != ''
</select>
</mapper>
package cn.com.glsx.dj.financial.service.nb;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportContext;
import cn.com.glsx.dj.financial.dto.NbCbAccDetailSummaryReportQueryDTO;
import cn.com.glsx.dj.financial.service.BaseServiceTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2025/4/17
**/
public class NbCbAccDetailTagSummaryServiceTest extends BaseServiceTest {
@Autowired
private Environment env;
@Autowired
private NbCbAccDetailTagSummaryService nbCbAccDetailTagSummaryService;
@Test
public void testLoadBalanceForDate() {
String summaryCustId = env.getProperty("nbcb.custId", "9000919969");
List<String> accountNos = nbCbAccDetailTagSummaryService.listSummaryAccountNos(summaryCustId);
BigDecimal balance = nbCbAccDetailTagSummaryService.loadBalanceForDate(accountNos, new Date());
System.out.println(balance);
}
@Test
public void testSummaryReport() {
NbCbAccDetailSummaryReportQueryDTO dto = new NbCbAccDetailSummaryReportQueryDTO();
dto.setOperator("test");
// dto.setEndDate(new Date());
NbCbAccDetailSummaryReportContext resp = nbCbAccDetailTagSummaryService.buildAccDetailSummaryReport(dto);
System.out.println(resp);
}
}
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(Top 3)

    1. 批量操作的 List 传参未见分片保护,存在 SQL 异常与性能风险(重要性:高)

    • 问题描述:在 NbCbAccDetailTagBindDTO 中定义了 List<Long> detailIds,且在 NbCbAccDetailMapper.updateAccDetailTagBatch 等方法中直接接收 List 作为参数。通常这些参数在 MyBatis 的 XML 中会被拼接为 IN (...) 条件。
    • 影响分析:如果调用方传入的 ID 数量过大(例如超过 1000 个),会导致拼接的 SQL 语句过长,极易触发数据库的限制(如 Oracle 对 IN 元素的 1000 个限制,或 MySQL 的 max_allowed_packet 限制),直接导致 SQL 执行失败。同时,超大范围的 IN 查询会导致索引失效或严重的性能瓶颈。
    • 优化建议:
      1. 在 API 层的 DTO 入参上增加校验注解,限制单次批量操作的上限,例如 @Size(max = 500, message = "单次操作不能超过500条")。
      2. 在 Service 层处理时,使用工具类(如 Guava 的 Lists.partition(ids, 500))将大集合切片,分批次调用 Mapper 方法。

    2. 接口传参包含操作人字段,存在身份伪造与越权风险(重要性:中)

    • 问题描述:在 NbCbAccDetailTagBindDTO 和 NbCbAccDetailSummaryReportQueryDTO 等请求对象中,定义了 operator(操作人)字段,并由客户端/调用方传入。
    • 影响分析:将操作人身份交由前端或调用方传递是不安全的做法。恶意的客户端可以轻易修改该字段,伪造他人身份进行标签绑定或数据查询,导致系统的操作审计日志失效,甚至引发越权风险。
    • 优化建议:移除 DTO 中的 operator 字段。操作人身份应在服务端统一管控,通过拦截器解析网关透传的 Token、Session,或通过 Dubbo 的 RpcContext 在上下文中获取,确保操作人身份的真实性和不可篡改性。

    3. DTO 直接继承数据库实体类,破坏了系统分层架构(重要性:低)

    • 问题描述:NbCbAccDetailDTO 继承了数据库实体 NbCbAccDetail,NbCbAccDetailTagDTO 继承了实体 NbCbAccDetailTag。
    • 影响分析:这是一种反模式(Anti-pattern)。DTO(数据传输对象)用于对外暴露 API 契约,而 Entity 用于映射底层数据库表结构。直接继承会导致数据库的任何字段变更(甚至敏感字段)隐式、无差别地暴露给外部接口;同时也会导致持久层注解(如 @Table, @Column)污染到 API 层,降低了代码的可维护性和独立演进能力。
    • 优化建议:解除继承关系。DTO 应作为独立的 POJO 类,仅包含前端或调用方实际需要的字段。可以使用 MapStruct、Spring BeanUtils 等对象映射工具在 Service 层进行 Entity 与 DTO 之间的转换。

    二、评分明细

    • 功能实现的正确性与健壮性(35/40分): 业务逻辑实现较为完整,新增的 Dubbo 接口符合规范,未修改原有接口参数,符合安全要求。扣 5 分原因在于批量处理的 List 参数存在潜在的边界容量溢出风险(MyBatis IN 语句超长)。

    • 安全性与潜在风险(25/30分): 整体未发现明显的 SQL 注入(假设 XML 中使用的是 # 而非 $)或 XSS 风险。扣 5 分原因在于 DTO 设计中直接接收前端传入的 operator 字段,存在身份伪造的安全隐患。

    • 最佳实践与可维护性(16/20分): 代码结构清晰,Swagger 注解完备,Lombok 使用合理。扣 4 分原因在于传输层 DTO 强耦合继承了底层数据库 Entity,破坏了领域模型的隔离性。

    • 性能与资源利用(4/5分): 未见明显的内存泄漏或死循环风险。扣 1 分原因在于大批量 IN 查询可能对数据库带来偶发性的性能抖动,建议在业务层做好分片防护。

    • 提交信息质量(5/5分): Commit 信息非常优秀,严格遵循了 Angular 规范(如 feat:, refactor:, fix:),详细且清晰地描述了每个提交的功能点与上下文,可追溯性极强,满分。

    总分:85分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!