集成bms服务模块

This commit is contained in:
hjx
2026-02-09 14:41:55 +08:00
parent 5d89fdc0a6
commit 7ab77cfbf7
267 changed files with 27070 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# 基础镜像
FROM kdvolder/jdk8
# author
MAINTAINER manhuoda
#指定东八区时区
ENV TZ Asia/Shanghai
#指定utf-8编码格
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF-8"
# VOLUME 指定了临时文件目录为/tmp。
# 其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp
VOLUME /tmp
#将当前jar 复制到容器根目录下
ADD mhd_bms.jar mhd_bms.jar
#暴露容器端口 Docker镜像告知Docker宿主机应用监听了端口
EXPOSE 8019
# 运行jar包
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-Xms1000m", "-Xmx1500m","-jar","/mhd_bms.jar"]
+177
View File
@@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mhd</artifactId>
<groupId>com.mhd</groupId>
<version>3.6.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mhd_bms</artifactId>
<dependencies>
<!--添加web依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--添加feign依赖 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-loadbalancer</artifactId>
</dependency>
<!--nacos 服务注册客户端依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- Sentinel⽀持采⽤ Nacos 作为规则配置数据源,引⼊该适配依赖 -->
<dependency>
<groupId>com.alibaba.csp</groupId>
<artifactId>sentinel-datasource-nacos</artifactId>
</dependency>
<!--sentinel 核⼼环境 依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!--spring cloud stream 依赖(rabbit-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>-->
<!-- Jackson -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!-- Alibaba Fastjson -->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
</dependency>
<!-- Mhd Common Core-->
<dependency>
<groupId>com.mhd</groupId>
<artifactId>mhd-common-core</artifactId>
</dependency>
<!-- Mhd Common Redis-->
<dependency>
<groupId>com.mhd</groupId>
<artifactId>mhd-common-redis</artifactId>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!--添加druid连接池 依赖 -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
<!--lombok工具-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
<!--import mybatis plus 它会自动引入mybatis及mybatis spring切勿重复引用以免冲突-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<!--链路追踪-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
<version>2.2.8.RELEASE</version>
</dependency>
<!-- Mhd Common Security-->
<dependency>
<groupId>com.mhd</groupId>
<artifactId>mhd-common-security</artifactId>
</dependency>
<dependency>
<groupId>com.mhd</groupId>
<artifactId>mhd-common-log</artifactId>
</dependency>
<!-- JEP 动态计算 -->
<dependency>
<groupId>jep</groupId>
<artifactId>jep</artifactId>
<version>2.24</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<profiles>
<profile>
<id>mhd_bms</id>
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
@@ -0,0 +1,21 @@
package com.mhd.bms;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication(scanBasePackages = {"com.mhd"})
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.mhd"})
@MapperScan("com.mhd.bms.domain.**.mapper")
@EnableAsync
public class BmsServiceApplication {
public static void main(String[] args) {
SpringApplication.run(BmsServiceApplication.class, args);
}
}
@@ -0,0 +1,494 @@
package com.mhd.bms.application.server.billManage;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.bms.application.server.billingStatement.BillingStatementApplicationService;
import com.mhd.bms.application.server.receiptManage.ReceiptManageApplicationService;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService;
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
import com.mhd.bms.domain.billManage.service.BillDetailDomainService;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.paymentOrder.repository.po.PaymentOrderPO;
import com.mhd.bms.domain.paymentOrder.repository.todo.PaymentOrderDO;
import com.mhd.bms.domain.paymentOrder.service.PaymentOrderDomainService;
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptDetailPO;
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptManagePO;
import com.mhd.bms.domain.receiptManage.service.ReceiptManageDomainService;
import com.mhd.bms.infrastructure.constant.BillLogsConstants;
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 账单管理ApplicationService
*
* @author gen
* @date 2024-07-02
*/
@Service
@Slf4j
public class BillManageApplicationService {
@Autowired
private BillManageDomainService billManageDomainService;
@Autowired
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private BillDetailDomainService billDetailDomainService;
@Autowired
private BillingStatementApplicationService billingStatementApplicationService;
@Autowired
private BillOperationLogDomainService billOperationLogDomainService;
@Autowired
private ReceiptManageDomainService receiptManageDomainService;
@Autowired
private PaymentOrderDomainService paymentOrderDomainService;
/**
* 分页查询账单管理列表
*/
public List<BillManagePO> queryList(BillManageDO billManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
billManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return billManageDomainService.queryList(billManageDO);
}
/**
* 新增账单管理
*/
public Boolean insert(BillManageDO billManageDO) {
return billManageDomainService.insert(billManageDO);
}
/**
* 修改账单管理
*/
public Boolean update(BillManageDO billManageDO) {
return billManageDomainService.update(billManageDO);
}
/**
* 批量删除账单管理
*/
public boolean delete(Long[] billManageIds) {
return billManageDomainService.delete(billManageIds);
}
/**
* 获取账单管理详细信息
*/
public BillManagePO getInfo(Long billManageId)
{
return billManageDomainService.getInfo(billManageId);
}
/**
* 保存账单
*/
public Boolean saveBill(BillingStatementDTO billingStatementDTO) {
return billManageDomainService.save(billingStatementDTO);
}
/**
* 批量删除账单管理
*/
@Transactional
public Boolean deleteByIds(BillManageDTO billManageDTO) {
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
throw new ServiceException("账单管理ids不能为空");
}
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
Long[] billManageIdsLong = billManageIds.stream().map(Long::valueOf).toArray(Long[]::new);
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillManage::getBillManageId,billManageIds);
List<BillManage> billManageList = billManageDomainService.queryListLambda(queryWrapper);
//校验状态,如果不是未确认状态,则不允许作废
for (BillManage billManage : billManageList) {
if(billManage.getBillState() != 6){
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不为未作废,不可操作删除");
}
}
//校验通过删除明细
boolean flag = billDetailDomainService.deletByManageIds(billManageIds);
boolean flagTwo = billManageDomainService.delete(billManageIdsLong);
//保存账单操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageIdSet(billManageIds);
billOperationLogDO.setOperationInfo(BillLogsConstants.delete_bill_text);
billOperationLogDO.setOperationType(9);
boolean three = billOperationLogDomainService.saveBillOperationLogBatch(billOperationLogDO);
return flag && flagTwo && three;
}
/**
* 批量作废账单
*/
@Transactional
public Boolean nullifyByIds(BillManageDTO billManageDTO) {
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
throw new ServiceException("账单管理ids不能为空");
}
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillManage::getBillManageId,billManageIds);
List<BillManage> billManageList = billManageDomainService.queryListLambda(queryWrapper);
//校验状态,如果不是未确认状态,则不允许作废
for (BillManage billManage : billManageList) {
if(billManage.getBillState() != 1){
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不为未确认,不可操作作废");
}
}
//符合条件后,账单作废,且计费流水状态还原到已审核状态
Boolean flag = billManageDomainService.nullifyByIds(billManageIds);
//查询账单包含所有计费流水
List<BillDetail> billDetailList = billDetailDomainService.queryByLambda(new LambdaQueryWrapper<BillDetail>().in(BillDetail::getBillManageId,billManageIds));
Set<Long> billingStatementIds = billDetailList.stream().map(BillDetail::getBillingStatementId).collect(Collectors.toSet());
Boolean flagTwo = billingStatementDomainService.billNullify(billingStatementIds);
return flag && flagTwo;
}
/**
* 发起对账
*/
@Transactional
public Boolean reconciliation(BillManageDTO billManageDTO) {
//发起对账:账单状态变更到对账中,只有未确认的状态才能进行发起对账
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
throw new ServiceException("账单管理ids不能为空");
}
//校验
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
BillManageDO billManageDO = new BillManageDO();
billManageDO.setBillManageIdSet(billManageIds);
List<BillManagePO> billManageList = billManageDomainService.queryList(billManageDO);
for (BillManagePO billManage : billManageList) {
if(billManage.getBillState() != 1){
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不为未确认,不可操作发起对账");
}
}
//发起对账
return billManageDomainService.reconciliation(billManageDO);
}
/**
* 确认账单
*/
@Transactional
public Boolean confirmBilling(BillManageDTO billManageDTO) {
//确认账单:未收款状态之前都可以进行确认账单,跳过核账流程,直接到未收款状态
if(!StringUtils.isNotEmpty(billManageDTO.getBillManageIds())){
throw new ServiceException("账单管理ids不能为空");
}
//校验
Set<String> billManageIds = Stream.of(billManageDTO.getBillManageIds().split(",")).collect(Collectors.toSet());
BillManageDO billManageDO = new BillManageDO();
billManageDO.setBillManageIdSet(billManageIds);
List<BillManagePO> billManageList = billManageDomainService.queryList(billManageDO);
for (BillManagePO billManage : billManageList) {
if(billManage.getBillState() > 2){
throw new ServiceException("选中数据"+ billManage.getBillNumber() + "状态不可操作确认账单");
}
}
return billManageDomainService.confirmBilling(billManageDO);
}
/**
* 查询对账详情
*/
public BillManagePO getInfoById(BillManageDTO billManageDTO) {
BillManagePO billManagePO = billManageDomainService.getInfo(billManageDTO.getBillManageId());
if(billManagePO == null){
throw new ServiceException("账单信息不存在");
}
List<BillDetailPO> billDetailPOList = billDetailDomainService.getDetailsByBillManageId(billManageDTO.getBillManageId());
billManagePO.setBillDetailPOList(billDetailPOList);
return billManagePO;
}
/**
* 调整账单
*/
@Transactional
public Boolean confirmChangeBill(BillManageDTO billManageDTO) {
/*
删除该账单的所有明细,并将所有新数据新增并绑定当前账单,并重新计算账单总额,与传来的是否一致,如果不一致则进行报错,如果一致,则修改账单总额信息
*/
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(billManageDTO.getBillDetailDTOList()==null || billManageDTO.getBillDetailDTOList().size()==0){
throw new ServiceException("账单明细不能为空");
}
BillManagePO billManagePO = billManageDomainService.getInfo(billManageDTO.getBillManageId());
if(null == billManagePO){
throw new ServiceException("账单信息未找到");
}
if(billManagePO.getBillState() != 1){
throw new ServiceException("账单状态不为未确认,不可操作调整账单");
}
List<BillDetailDTO> billDetailDTOList = billManageDTO.getBillDetailDTOList();
Boolean deleteFlag = billDetailDomainService.removeByBillManageId(billManageDTO.getBillManageId());
if(!deleteFlag){
throw new ServiceException("调整失败,请重试");
}
//计算集合中所有账单总额、账单金额、账单优惠金额
BigDecimal billingTotalAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billingAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billingDiscountAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingDiscountAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//比较传来的账单总额、账单金额、账单优惠金额与计算的是否一致,不一致则报错
if(billingTotalAmount.compareTo(billManageDTO.getBillTotalAmount())!=0 || billingAmount.compareTo(billManageDTO.getBillAmount())!=0 || billingDiscountAmount.compareTo(billManageDTO.getBillDiscountAmount())!=0){
throw new ServiceException("账单金额不一致,调整失败,请重试");
}
//将集合中没有计费流水id的过滤到另一个集合,将添加费用的集合保存到计费流水并返回计费流水id
List<BillDetailDTO> billDetailDTOListNoBillingStatementId = billDetailDTOList.stream().filter(billDetailDTO -> billDetailDTO.getBillingStatementId()==null).collect(Collectors.toList());
//遍历集合并保存流水
for (BillDetailDTO billDetailDTO : billDetailDTOListNoBillingStatementId) {
BillingStatementDTO billingStatementDTO = new BillingStatementDTO();
BeanUtils.copyProperties(billDetailDTO,billingStatementDTO);
billingStatementDTO.setAccountExpenseType(billDetailDTO.getBillType());
Long billingStatementId = billingStatementApplicationService.insertAndReturnId(billingStatementDTO);
//遍历billDetailDTOList集合,将计费流水号相同的,赋值计费流水id
billDetailDTOList.stream().filter(item -> item.getBillingFlow().equals(billDetailDTO.getBillingFlow())).forEach(billDetailDTO1 -> {
billDetailDTO1.setBillingStatementId(billingStatementId);
billDetailDTO1.setBillType(billManagePO.getBillType());
billDetailDTO1.setBillManageId(billManagePO.getBillManageId());
billDetailDTO1.setBillNumber(billManagePO.getBillNumber());
});
}
//保存账单明细
Boolean flag = billDetailDomainService.saveBatch(billDetailDTOList);
//更新账单金额
BillManageDO billManageDO = new BillManageDO();
BeanUtils.copyProperties(billManagePO,billManageDO);
billManageDO.setBillAmount(billingAmount);
billManageDO.setBillAmountUnsettled(billingAmount);
billManageDO.setBillDiscountAmount(billingDiscountAmount);
billManageDO.setBillTotalAmount(billingTotalAmount);
billManageDO.setCostAccuracyCode(billManageDTO.getCostAccuracyCode());
billManageDO.setTailCalculationCode(billManageDTO.getTailCalculationCode());
billManageDO.setAmountAccuracyCode(billManageDTO.getAmountAccuracyCode());
billManageDO.setBillDiscount(billManageDTO.getBillDiscount());
billManageDO.setBillDiscountLimit(billManageDTO.getBillDiscountLimit());
billManageDO.setCreateTime(billManageDTO.getCreateTime());
billManageDO.setUpdateTime(new Date());
billManageDO.setUpdateBy(loginUser.getUserid());
billManageDO.setUpdateByName(loginUser.getUserPo().getUserName());
billManageDomainService.handlData(billManageDO);
Boolean flagTwo = billManageDomainService.update(billManageDO);
//调整账单操作日志
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageId(billManageDO.getBillManageId());
billOperationLogDO.setOperationInfo(StringUtils.format(BillLogsConstants.change_bill_text, billManageDO.getBillAmount()));
billOperationLogDO.setOperationType(2);
boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO);
return flag && flagTwo && three;
}
/**
* 应收账单-客户确认
*/
@Transactional
public Boolean customerConfirmation(BillManageDTO billManageDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillManagePO billManagePO = billManageDomainService.getInfo(billManageDTO.getBillManageId());
if(null == billManagePO){
throw new ServiceException("账单信息未找到");
}
if(billManageDTO.getBillDetailDTOList()==null || billManageDTO.getBillDetailDTOList().size()==0){
throw new ServiceException("账单明细不能为空");
}
if(billManagePO.getBillState() != 2 || billManagePO.getBillStep() != 2){
throw new ServiceException("账单状态错误,不可操作客户确认");
}
List<BillDetailDTO> billDetailDTOList = billManageDTO.getBillDetailDTOList();
//更新账单金额
BillManageDO billManageDO = new BillManageDO();
billManageDO.setBillManageId(billManagePO.getBillManageId());
billManageDO.setReconciliationStatus(billManageDTO.getReconciliationStatus());
billManageDO.setReconciliationOpinion(billManageDTO.getReconciliationOpinion());
billManageDO.setVoucherAddress(billManageDTO.getVoucherAddress());
billManageDO.setBillStep(3);
billManageDO.setUpdateTime(new Date());
billManageDO.setUpdateBy(loginUser.getUserid());
billManageDO.setUpdateByName(loginUser.getUserPo().getUserName());
//只有申请调账,才去修改明细
Boolean flag = true;
String operationInfo = BillLogsConstants.customer_confirm_text_one;
if(billManageDTO.getReconciliationStatus() == 2){
flag = billDetailDomainService.changeAmount(billDetailDTOList);
//计算集合期望金额
BigDecimal billExpectedAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingExpectedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
billManageDO.setBillExpectedAmount(billExpectedAmount);
operationInfo = StringUtils.format(BillLogsConstants.customer_confirm_text_two,billManageDTO.getReconciliationOpinion(),billExpectedAmount);
}
//保存操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageId(billManageDO.getBillManageId());
billOperationLogDO.setOperationInfo(operationInfo);
billOperationLogDO.setOperationType(5);
Boolean flagTwo = billManageDomainService.update(billManageDO);
Boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO);
return flag && flagTwo && three;
}
/**
* 财务审核
*/
public Boolean financialReview(BillManageDTO billManageDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillManagePO billManagePO = billManageDomainService.getInfo(billManageDTO.getBillManageId());
if(null == billManagePO){
throw new ServiceException("账单信息未找到");
}
if(billManageDTO.getBillDetailDTOList()==null || billManageDTO.getBillDetailDTOList().size()==0){
throw new ServiceException("账单明细不能为空");
}
if(billManagePO.getBillState() != 2 || billManagePO.getBillStep() != 3 || (billManagePO.getReconciliationStatus() != 4 && billManagePO.getReconciliationStatus() != 2)){
throw new ServiceException("账单状态错误,不可操作审核");
}
List<BillDetailDTO> billDetailDTOList = billManageDTO.getBillDetailDTOList();
//只有审核拒绝,才去修改明细
Boolean flag = billDetailDomainService.changeAmount(billDetailDTOList);
//计算集合中所有账单总额、账单金额、账单优惠金额
BigDecimal billingTotalAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billingAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billingDiscountAmount = billDetailDTOList.stream().map(BillDetailDTO::getBillingDiscountAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
//更新账单金额
BillManageDO billManageDO = new BillManageDO();
billManageDO.setBillManageId(billManagePO.getBillManageId());
billManageDO.setReconciliationStatus(billManageDTO.getReconciliationStatus());
billManageDO.setReconciliationOpinion(billManageDTO.getReconciliationOpinion());
billManageDO.setFinancialReviewOpinion(billManageDTO.getFinancialReviewOpinion());
billManageDO.setBillAmount(billingAmount);
billManageDO.setBillAmountUnsettled(billingAmount);
billManageDO.setBillDiscountAmount(billingDiscountAmount);
billManageDO.setBillTotalAmount(billingTotalAmount);
billManageDO.setCostAccuracyCode(billManageDTO.getCostAccuracyCode());
billManageDO.setTailCalculationCode(billManageDTO.getTailCalculationCode());
billManageDO.setAmountAccuracyCode(billManageDTO.getAmountAccuracyCode());
billManageDO.setBillDiscount(billManageDTO.getBillDiscount());
billManageDO.setBillDiscountLimit(billManageDTO.getBillDiscountLimit());
billManageDO.setUpdateTime(new Date());
billManageDO.setUpdateBy(loginUser.getUserid());
billManageDO.setUpdateByName(loginUser.getUserPo().getUserName());
billManageDO.setFinancialReviewFlag(billManageDTO.getFinancialReviewFlag());
billManageDomainService.handlData(billManageDO);
String operationInfo = "";
if(billManageDTO.getFinancialReviewFlag()==1){
//同意审核
billManageDO.setReconciliationStatus(4);
billManageDO.setBillStep(4);
billManageDO.setBillState(3);
operationInfo = StringUtils.format(BillLogsConstants.financial_review_text_one,billManageDO.getFinancialReviewOpinion(),billManageDO.getBillAmount());
}else {
//拒绝审核
billManageDO.setReconciliationStatus(1);
billManageDO.setBillStep(2);
operationInfo = StringUtils.format(BillLogsConstants.financial_review_text_two,billManageDO.getFinancialReviewOpinion(),billManageDO.getBillAmount());
}
//保存操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageId(billManageDO.getBillManageId());
billOperationLogDO.setOperationInfo(operationInfo);
billOperationLogDO.setOperationType(6);
Boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO);
Boolean flagTwo = billManageDomainService.update(billManageDO);
return flag && flagTwo && three;
}
/**
* 获取账单详情
*/
public Map<String,Object> getDetailsById(BillManageDTO billManageDTO) {
//该详情由三部分组成:账单信息、收款信息、操作日志
if(billManageDTO.getBillManageId() == null){
throw new ServiceException("账单id不能为空");
}
Map<String,Object> result = new HashMap<>();
BillManagePO billManagePO = billManageDomainService.getDetailsById(billManageDTO.getBillManageId());
result.put("billManage",billManagePO);
if(billManagePO.getBillType()==1){
List<ReceiptDetailPO> receiptManagePOList = receiptManageDomainService.getDetailsByBillManageId(billManageDTO.getBillManageId());
result.put("billPayment",receiptManagePOList);
}else {
List<PaymentOrderPO> paymentOrderPOList = paymentOrderDomainService.getDetailsByBillManageId(billManageDTO.getBillManageId());
result.put("billPayment",paymentOrderPOList);
}
result.put("billOperationLog",billOperationLogDomainService.getDetailsById(billManageDTO.getBillManageId()));
return result;
}
/**
* 列表查询统计
*/
public Map<String,String> listCount(BillManageDO billManageDO) {
Map<String,String> result = new HashMap<>();
result.put("all","0");
result.put("uncleared","0");
result.put("settled","0");
result.put("invalid","0");
billManageDO.setQueryParam(0);
List<BillManagePO> billManagePOList = queryList(billManageDO);
//过滤出账单状态billState<5的为uncleared
long uncleared = billManagePOList.stream().filter(billManagePO -> billManagePO.getBillState() < 5).count();
long settled = billManagePOList.stream().filter(billManagePO -> billManagePO.getBillState() == 5).count();
long invalid = billManagePOList.stream().filter(billManagePO -> billManagePO.getBillState() == 6).count();
result.put("all", String.valueOf(billManagePOList.size()));
result.put("uncleared",String.valueOf(uncleared));
result.put("settled",String.valueOf(settled));
result.put("invalid",String.valueOf(invalid));
return result;
}
}
@@ -0,0 +1,72 @@
package com.mhd.bms.application.server.billOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 账单操作日志ApplicationService
*
* @author gen
* @date 2024-07-09
*/
@Service
@Slf4j
public class BillOperationLogApplicationService {
@Autowired
private BillOperationLogDomainService billOperationLogDomainService;
/**
* 分页查询账单操作日志列表
*/
public List<BillOperationLogPO> queryList(BillOperationLogDO billOperationLogDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
billOperationLogDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return billOperationLogDomainService.queryList(billOperationLogDO);
}
/**
* 新增账单操作日志
*/
public Boolean insert(BillOperationLogDO billOperationLogDO) {
return billOperationLogDomainService.insert(billOperationLogDO);
}
/**
* 修改账单操作日志
*/
public Boolean update(BillOperationLogDO billOperationLogDO) {
return billOperationLogDomainService.update(billOperationLogDO);
}
/**
* 批量删除账单操作日志
*/
public boolean delete(Long[] billOperationLogIds) {
return billOperationLogDomainService.delete(billOperationLogIds);
}
/**
* 获取账单操作日志详细信息
*/
public BillOperationLogPO getInfo(Long billOperationLogId)
{
return billOperationLogDomainService.getInfo(billOperationLogId);
}
}
@@ -0,0 +1,167 @@
package com.mhd.bms.application.server.billingRules;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import com.mhd.bms.domain.billingRules.service.BillingParamsDomainService;
import com.mhd.bms.domain.billingRules.service.BillingRulesDomainService;
import com.mhd.bms.interfaces.dto.billingRules.BillingRulesDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 计费规则ApplicationService
*
* @author gen
* @date 2024-07-12
*/
@Service
@Slf4j
public class BillingRulesApplicationService {
@Autowired
private BillingRulesDomainService billingRulesDomainService;
@Autowired
private BillingParamsDomainService billingParamsDomainService;
/**
* 分页查询计费规则列表
*/
public List<BillingRulesPO> queryList(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
billingRulesDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return billingRulesDomainService.queryList(billingRulesDO);
}
/**
* 新增计费规则
*/
@Transactional
public Boolean insert(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(billingRulesDO.getBillingParamsDTOList()==null || billingRulesDO.getBillingParamsDTOList().size()==0){
throw new ServiceException("计费参数不能为空");
}
//校验计费规则编码是否重复
BillingRulesPO billingRulesPO = billingRulesDomainService.getInfoByCode(billingRulesDO.getBillingRulesCode());
if (ObjectUtil.isNotEmpty(billingRulesPO)) {
throw new ServiceException("计费规则编码重复");
}
//保存计费规则
boolean flag = billingRulesDomainService.insert(billingRulesDO);
//保存计费参数(计费参数在表单中缓存,在最终提交时保存)
boolean flagTwo = billingParamsDomainService.saveBillParam(billingRulesDO);
return flag && flagTwo;
}
/**
* 修改计费规则
*/
public Boolean update(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(billingRulesDO.getBillingParamsDTOList()==null || billingRulesDO.getBillingParamsDTOList().size()==0){
throw new ServiceException("计费参数不能为空");
}
//校验计费规则编码是否重复
BillingRulesPO billingRulesPO = billingRulesDomainService.getInfoByCode(billingRulesDO.getBillingRulesCode());
if (billingRulesPO != null && !Objects.equals(billingRulesPO.getBillingRulesId(), billingRulesDO.getBillingRulesId())) {
throw new ServiceException("计费规则编码重复");
}
//更新计费规则
boolean flag = billingRulesDomainService.update(billingRulesDO);
//更新计费参数(计费参数在表单中缓存,在最终提交时保存)
boolean flagTwo = billingParamsDomainService.updateBillParam(billingRulesDO);
return flag && flagTwo;
}
/**
* 批量删除计费规则
*/
public boolean delete(Long[] billingRulesIds) {
return billingRulesDomainService.delete(billingRulesIds);
}
/**
* 获取计费规则详细信息
*/
public BillingRulesPO getInfo(Long billingRulesId)
{
if(null == billingRulesId){
throw new ServiceException("计费规则id不能为空");
}
return billingRulesDomainService.getInfo(billingRulesId);
}
/**
* 根据id删除
*/
public Boolean deleteByIds(BillingRulesDTO billingRulesDTO) {
if(!StringUtils.isNotEmpty(billingRulesDTO.getBillingRulesIds())){
throw new ServiceException("选中计费规则不能为空");
}
Set<String> billingRulesIdSet = Stream.of(billingRulesDTO.getBillingRulesIds().split(",")).collect(Collectors.toSet());
Long[] billingRulesIds = billingRulesIdSet.stream().map(Long::valueOf).toArray(Long[]::new);
return billingRulesDomainService.delete(billingRulesIds);
}
/**
* 修改计费规则状态
*/
public Boolean changeStates(BillingRulesDTO billingRulesDTO) {
if(billingRulesDTO.getBillingRulesId() == null){
throw new ServiceException("计费规则id不能为空");
}
return billingRulesDomainService.changeStates(billingRulesDTO);
}
/**
* 根据id查询计费规则信息
*/
public BillingRulesPO getInfoById(BillingRulesDTO billingRulesDTO) {
if(billingRulesDTO.getBillingRulesId() == null){
throw new ServiceException("计费规则id不能为空");
}
return billingRulesDomainService.getInfoById(billingRulesDTO.getBillingRulesId());
}
/**
* 根据编码查询计费规则信息
*/
public BillingRulesPO getInfoByCode(String billingRulesCode) {
if(StringUtils.isEmpty(billingRulesCode)){
throw new ServiceException("计费策略编码不能为空");
}
return billingRulesDomainService.getInfoByCode(billingRulesCode);
}
}
@@ -0,0 +1,340 @@
package com.mhd.bms.application.server.billingRules;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.service.BillingParamsDomainService;
import com.mhd.bms.domain.billingRules.service.BillingRulesDomainService;
import com.mhd.bms.domain.costCalculation.entity.BillingOutputEntity;
import com.mhd.bms.domain.costCalculation.entity.BillingParamsEntity;
import com.mhd.bms.domain.costCalculation.po.BillingCostPo;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.domain.taskFlowRecords.repository.todo.TaskFlowRecordsDO;
import com.mhd.bms.domain.taskFlowRecords.service.TaskFlowRecordsDomainService;
import com.mhd.bms.infrastructure.feign.vo.ContractManageDetailPO;
import com.mhd.bms.infrastructure.feign.vo.ContractManagePO;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.infrastructure.utils.DynamicCalculationUtil;
import com.mhd.bms.interfaces.dto.billingRules.CostCalculationDTO;
import com.mhd.common.core.domain.po.UserRoleMenuPO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.RegexUtil;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 费用计算
*
*/
@Service
@Slf4j
public class CostCalculationApplicationService {
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private BillingRulesDomainService billingRulesDomainService;
@Autowired
private BillingParamsDomainService billingParamsDomainService;
@Autowired
private TaskFlowRecordsDomainService taskFlowRecordsDomainService;
@Autowired
private DocumentTypeDomainService documentTypeDomainService;
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
/**
* 费用计算器
*/
public BillingCostPo costCalculation(CostCalculationDTO costCalculationDTO) {
/* 1:根据合同编码查询合同并根据费用科目,获取计费策略,查询计费策略计算对应的字段,判断传来的计费参数必填项是否完整
2:根据计费策略公式进行替换,并根据配置的公式计算结果
3:产生计费任务记录
*/
//获取当前登录人信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillingCostPo result = new BillingCostPo();
BeanUtils.copyProperties(costCalculationDTO, result);
TaskFlowRecordsDO taskFlowRecordsDO = new TaskFlowRecordsDO();
//第一步 根据合同编码查询合同并根据费用科目,获取计费策略,查询计费策略计算对应的字段,判断传来的计费参数必填项是否完整
BillingRulesPO billingRulesPO = chooseBillingParams(costCalculationDTO,taskFlowRecordsDO);
//第二步 根据计费策略公式进行替换,并根据配置的公式计算结果
BigDecimal computationalCost = computational(billingRulesPO,costCalculationDTO,taskFlowRecordsDO);
result.setComputationalCost(computationalCost);
//第三步 产生计费任务记录
taskFlowRecordsDO.setBillingResults(computationalCost.toString());
taskFlowRecordsDO.setTaskFlow(OrderSequence.getOrderCode("JFRW"));
taskFlowRecordsDO.setRequestParams(JSON.toJSONString(costCalculationDTO));
taskFlowRecordsDO.setOriginalBusinessNum(costCalculationDTO.getOriginalBusinessNum());
Boolean flag = taskFlowRecordsDomainService.saveInCost(taskFlowRecordsDO);
if (!flag) {
throw new ServiceException("计费任务记录保存失败,请重试");
}
return result;
}
/**
* 校验必填,并获取本次计算合适的计费参数公式
* @param costCalculationDTO 计算参数
* @return 计费规则实体
*/
private BillingRulesPO chooseBillingParams(CostCalculationDTO costCalculationDTO,TaskFlowRecordsDO taskFlowRecordsDO) {
//获取合同信息
AjaxResult ajaxResult = systemServiceFeign.getInfoByCode(costCalculationDTO.getContractNumber());
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}
ContractManagePO contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class);
if (null == contractPO) {
throw new ServiceException("合同信息未找到");
}
if(contractPO.getContractManageDetailPOList() == null || contractPO.getContractManageDetailPOList().size() == 0){
throw new ServiceException("合同详情列表为空,无法进行计算");
}
//查询单据信息
DocumentType documentType = documentTypeDomainService.queryByCode(costCalculationDTO.getDocumentTypeCode());
if(documentType == null){
throw new ServiceException("单据类型未找到");
}
//遍历费用科目取出对应配置的费用科目项
AjaxResult expenseAccountAjax = systemServiceFeign.getSubInfoByCode(costCalculationDTO.getSubjectCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("费用科目不存在或已被删除");
}
ExpenseAccountPO expenseAccountPO = JSON.parseObject(JSONObject.toJSONString(expenseAccountAjax.get("data")), ExpenseAccountPO.class);
if (null == expenseAccountPO) {
throw new ServiceException("费用科目信息未找到");
}
ContractManageDetailPO contractManageDetailPO = null;
//如果是一级科目
if(expenseAccountPO.getFirstSubjectFlag()==1){
contractManageDetailPO = contractPO.getContractManageDetailPOList().stream().filter(item -> ObjectUtil.equal(item.getFirstSubjectCode(),costCalculationDTO.getSubjectCode())).findAny().orElse(null);
taskFlowRecordsDO.setFirstSubjectCode(expenseAccountPO.getSubjectCode());
taskFlowRecordsDO.setFirstSubjectName(expenseAccountPO.getSubjectName());
}else {
contractManageDetailPO = contractPO.getContractManageDetailPOList().stream().filter(item -> ObjectUtil.equal(item.getSecondSubjectCode(),costCalculationDTO.getSubjectCode())).findAny().orElse(null);
taskFlowRecordsDO.setFirstSubjectCode(expenseAccountPO.getUpperSubjectCode());
taskFlowRecordsDO.setFirstSubjectName(expenseAccountPO.getUpperSubject());
taskFlowRecordsDO.setSecondSubjectCode(expenseAccountPO.getSubjectCode());
taskFlowRecordsDO.setSecondSubjectName(expenseAccountPO.getSubjectName());
}
if(null == contractManageDetailPO){
throw new ServiceException("合同中不包含该费用科目的计费策略,请查正后重试");
}
//根据计费策略查询计费规则信息
BillingRulesPO billingRulesPO = billingRulesDomainService.getInfo(contractManageDetailPO.getAccountingStrategyId());
if(null == billingRulesPO){
throw new ServiceException("计费策略信息未找到");
}
//查询计费参数表获取参数字段,并判断所需字段是否必填
List<BillingParamsPO> billingParamsPOList = billingParamsDomainService.getInfoByRuleId(billingRulesPO.getBillingRulesId());
//先默认一个计费规则中有一个计费参数表
if(billingParamsPOList ==null || billingParamsPOList.size() != 1){
throw new ServiceException("计费规则未配置计费参数或参数不合规");
}
//校验计算参数是否完整
BillingParamsPO billingParamsPO = billingParamsPOList.get(0);
//使用反射校验字段必填是否完整
List<BillingParamsEntity> billingParamsEntityList = JSON.parseArray(billingParamsPO.getBillingParamsJson(), BillingParamsEntity.class);
JSONObject paramObj = JSONObject.parseObject(costCalculationDTO.getFormJson());
billingParamsEntityList.forEach(item -> {
if(paramObj.get(item.getFields()) == null){
throw new ServiceException("计费参数"+ item.getFields() +"不能为空");
}
});
billingRulesPO.setBillingParamsPOList(billingParamsPOList);
//查询结算对象信息
if(contractPO.getSettlementCustomersId() != null){
SettlementCustomersPO settlementCustomersPO = settlementCustomersDomainService.getInfo(contractPO.getSettlementCustomersId());
if(null != settlementCustomersPO){
taskFlowRecordsDO.setSettlementCustomersId(settlementCustomersPO.getSettlementCustomersId());
taskFlowRecordsDO.setSettlementEntity(settlementCustomersPO.getSettlementEntity());
taskFlowRecordsDO.setMainRole(settlementCustomersPO.getMainRole());
}
}
taskFlowRecordsDO.setBelongModule(documentType.getBelongModule());
taskFlowRecordsDO.setBelongModuleCode(documentType.getBelongModuleCode());
taskFlowRecordsDO.setDocumentTypeId(documentType.getDocumentTypeId());
taskFlowRecordsDO.setDocumentType(documentType.getDocumentType());
taskFlowRecordsDO.setDocumentTypeCode(documentType.getDocumentTypeCode());
taskFlowRecordsDO.setContractName(contractPO.getContractName());
taskFlowRecordsDO.setContractNumber(contractPO.getContractNumber());
taskFlowRecordsDO.setBillingRulesId(billingRulesPO.getBillingRulesId());
taskFlowRecordsDO.setBillingRulesCode(billingRulesPO.getBillingRulesCode());
taskFlowRecordsDO.setBillingRules(billingRulesPO.getBillingRulesName());
return billingRulesPO;
}
/**
* 根据计费公式、计费参数 计算费用
* @param billingRulesPO 计费策略
* @param costCalculationDTO 计费参数
* @param taskFlowRecordsDO 计费任务实体
* @return 计费金额
*/
private BigDecimal computational(BillingRulesPO billingRulesPO, CostCalculationDTO costCalculationDTO, TaskFlowRecordsDO taskFlowRecordsDO) {
String billingFormula = billingRulesPO.getBillingFormula();
//第一版先默认计费规则中只有一条计费参数
BillingParamsPO billingParamsPO = billingRulesPO.getBillingParamsPOList().get(0);
JSONObject paramObj = JSONObject.parseObject(costCalculationDTO.getFormJson());
//需要判断阶梯类型进行获取各计费标志的取值,拼接公式
List<BillingParamsEntity> billingParamsEntityList = JSON.parseArray(billingParamsPO.getBillingParamsJson(), BillingParamsEntity.class);
//将计费参数实体分成两组,即:固定参数和条件参数
List<BillingParamsEntity> fixedParamsEntityList = billingParamsEntityList.stream().filter(item -> ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
List<BillingParamsEntity> ladderParamsEntityList = billingParamsEntityList.stream().filter(item -> !ObjectUtil.equal(item.getLadderType(),1)).collect(Collectors.toList());
//获取输出字段
List<BillingOutputEntity> billingOutputEntityList = JSON.parseArray(billingParamsPO.getBillingOutputJson(), BillingOutputEntity.class);
//获取预制规则
String preSetRules = billingParamsPO.getPreSetRules();
//获取字段序号下,所有有值的预置规则
JSONArray preSetRulesArray = JSONArray.parseArray(preSetRules);
//==============固定参数直接替换===============
if(fixedParamsEntityList.size()>0){
for (BillingParamsEntity billingParamsEntity : fixedParamsEntityList) {
String flagValue = paramObj.getString(billingParamsEntity.getFields());
//替换计费公式中的代号
billingFormula = billingFormula.replace(billingParamsEntity.getChargingId(), flagValue);
}
}
//=============条件参数需要根据条件满足情况取值预置规则中的数据===========
if(ladderParamsEntityList.size() > 0){
if(preSetRulesArray.size()==0){
throw new ServiceException("阶梯计算没有预置规则,请检查后重试");
}
BillingParamsEntity ladderParamsEntity = ladderParamsEntityList.stream().filter(item -> item.getLadderType()>2).findAny().orElse(null);
//循环预置规则,根据条件参数,找出满足条件的唯一规则,并替换公式
JSONObject ladderParams = new JSONObject();
for (Object rule : preSetRulesArray) {
JSONObject jsonObject = (JSONObject) rule;
//参数集合map
Map<String, String> params = new HashMap<>();
for (BillingParamsEntity billingParamsEntity : ladderParamsEntityList) {
String flagValue = paramObj.getString(billingParamsEntity.getFields());
params.put("fields"+billingParamsEntity.getSort(), flagValue);
}
if(null != ladderParamsEntity){
//有特殊阶梯时,需要对特殊阶梯特殊处理
String ladderParam = "fields" + ladderParamsEntity.getSort();
//先满足阶梯,在判断无阶梯
String ladderNum = params.get(ladderParam);
String outLadderNum = jsonObject.get(ladderParam).toString();
if(determineParam(ladderNum,outLadderNum)){
//将该特殊阶梯从jsonObject集合中移除
// jsonObject.remove(ladderParam);
ladderParams = jsonObject;
break;
}
}
else {
//全部是无阶梯时
//判断jsonObject中的取值是否和参数集合paramObj中的值一致
if(params.values().containsAll(jsonObject.values())){
ladderParams = jsonObject;
break;
}
}
}
for (BillingParamsEntity billingParamsEntity : ladderParamsEntityList) {
String flagValue = ladderParams.getString("outFields" + billingParamsEntity.getSort());
//替换计费公式中的代号
billingFormula = billingFormula.replace(billingParamsEntity.getChargingId(), flagValue);
}
//拿到满足条件的预置规则后,替换输出字段,和输入字段
if(billingOutputEntityList.size()>0){
for (BillingOutputEntity billingOutputEntity : billingOutputEntityList) {
//获取输出字段的序号,并取对应序号下的
String outFields = ladderParams.getString("outFields" + billingOutputEntity.getSort());
//替换公式
billingFormula = billingFormula.replace(billingOutputEntity.getOutChargingId(), outFields);
}
}
}
else {
//==================没有条件参数的时候,也要过滤输出字段,输出字段直接替换===============
if(billingOutputEntityList.size()>0){
if(preSetRulesArray.size()==0){
throw new ServiceException("输出字段没有预置规则,请检查后重试");
}
//直接取值输出字段对应的预置规则信息,没有条件参数时,预置规则默认只取第一条
JSONObject jsonObject = preSetRulesArray.getJSONObject(0);
for (BillingOutputEntity billingOutputEntity : billingOutputEntityList) {
//获取输出字段的序号,并取对应序号下的
String outFields = jsonObject.getString("outFields" + billingOutputEntity.getSort());
//替换公式
billingFormula = billingFormula.replace(billingOutputEntity.getOutChargingId(), outFields);
}
}
}
//这里用正则校验是否还含有英文或者汉字
if(RegexUtil.isEngOrChinese(billingFormula)){
throw new ServiceException("计费公式不合规,请重试");
}
taskFlowRecordsDO.setBillingProcess(billingFormula);
//用拼接好的公式,计算
return DynamicCalculationUtil.calculate(billingFormula);
}
/**
* 判断阶梯参数是否满足
* @param ladderNum 传来的阶梯参数
* @param outLadderNum 预置规则参数
* @return 是否满足
*/
private boolean determineParam(String ladderNum, String outLadderNum) {
int ladderNumInt = Integer.parseInt(ladderNum);
//将outLadderNum中的 (替换为>, )替换为<,[替换为<=,]替换为>=,并且判断ladderNum是否在条件范围中
//将数值用逗号拆分
int lowerBound = Integer.parseInt(outLadderNum.substring(1, outLadderNum.indexOf(',')));
int upperBound = Integer.parseInt(outLadderNum.substring(outLadderNum.indexOf(',') + 1, outLadderNum.length() - 1));
if(outLadderNum.contains("(") && outLadderNum.contains("]")){
if(ladderNumInt > lowerBound && ladderNumInt <= upperBound){
return true;
}
}
if(outLadderNum.contains("[") && outLadderNum.contains(")")){
if(ladderNumInt >= lowerBound && ladderNumInt < upperBound){
return true;
}
}
return false;
}
}
@@ -0,0 +1,501 @@
package com.mhd.bms.application.server.billingStatement;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.mhd.bms.application.server.billManage.BillManageApplicationService;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementCollectPO;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementCollectDO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.infrastructure.feign.vo.ContractManagePO;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.interfaces.assembler.billingStatement.BillingStatementAssembler;
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
import com.mhd.common.core.domain.po.OrganizationPo;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.domain.po.projectManagement.ProjectManagementPO;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.ProductServiceFeign;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 计费流水ApplicationService
*
* @author gen
* @date 2024-06-26
*/
@Service
@Slf4j
public class BillingStatementApplicationService {
@Autowired
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private ProductServiceFeign productServiceFeign;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
@Autowired
private BillManageApplicationService billManageApplicationService;
@Autowired
private BillManageDomainService billManageDomainService;
/**
* 分页查询计费流水列表
*/
public List<BillingStatementPO> queryList(BillingStatementDO billingStatementDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return billingStatementDomainService.queryList(billingStatementDO);
}
/**
* 查询出账汇总
*/
public List<BillingStatementCollectPO> queryCollectList(BillingStatementCollectDO billingStatementCollectDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
billingStatementCollectDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return billingStatementDomainService.queryCollectList(billingStatementCollectDO);
}
/**
* 查询出账未出账全部
*/
public Map<String, String> collectListSize(BillingStatementCollectDO billingStatementCollectDO) {
Map<String, String> map = new HashMap<>();
map.put("notBeen","0");
map.put("been","0");
map.put("all","0");
billingStatementCollectDO.setBillingState(0);
List<BillingStatementCollectPO> all = queryCollectList(billingStatementCollectDO);
//统计出all集合中billingStateCount字段中含有的1和2的数量
long notBeen = all.stream().filter(billingStatementCollectPO -> billingStatementCollectPO.getBillingStateCount().contains("1") || billingStatementCollectPO.getBillingStateCount().contains("2")).count();
//统计出all集合中billingStateCount字段中含有的3的数量
long been = all.stream().filter(billingStatementCollectPO -> billingStatementCollectPO.getBillingStateCount().contains("3")).count();
map.put("notBeen",String.valueOf(notBeen));
map.put("been",String.valueOf(been));
map.put("all", String.valueOf(all.size()));
return map;
}
/**
* 查询出账详情
*/
public List<BillingStatementPO> queryDetails(BillingStatementCollectDO bdo) {
return billingStatementDomainService.queryDetails(bdo);
}
/**
* 新增计费流水
*/
public Boolean insert(BillingStatementDO billingStatementDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//处理数据
handleDate(billingStatementDO);
billingStatementDO.setDataSources(2);
billingStatementDO.setBillingFlow(OrderSequence.getOrderCode("JFLS"));
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingStatementDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingStatementDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return billingStatementDomainService.insert(billingStatementDO);
}
/**
* 处理数据
*/
private void handleDate(BillingStatementDO billingStatementDO) {
if (billingStatementDO.getOrganizationId() != null) {
//获取组织信息
AjaxResult ajaxResult = productServiceFeign.getOrganizationInfo(billingStatementDO.getOrganizationId());
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("选中组织信息未找到");
}
OrganizationPo organizationPo = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), OrganizationPo.class);
if (null == organizationPo) {
throw new ServiceException("组织信息未找到");
}
billingStatementDO.setOrganizationName(organizationPo.getOrganizationName());
billingStatementDO.setTopOrganizationId(organizationPo.getParentOrganizationId());
}
//根据费用科目code查询费用信息,并赋值
if (StringUtils.isNotEmpty(billingStatementDO.getSecondSubjectCode())) {
AjaxResult ajaxResult = systemServiceFeign.getSubInfoByCode(billingStatementDO.getSecondSubjectCode());
if ("200".equals(String.valueOf(ajaxResult.get("code")))) {
ExpenseAccountPO expenseAccountPO = JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), ExpenseAccountPO.class);
if (null == expenseAccountPO) {
throw new ServiceException("费用科目信息未找到");
}
if (expenseAccountPO.getFirstSubjectFlag() == 1) {
//如果是一级科目
billingStatementDO.setFirstSubjectName(expenseAccountPO.getSubjectName());
billingStatementDO.setFirstSubjectCode(expenseAccountPO.getSubjectCode());
billingStatementDO.setSecondSubjectCode("");
billingStatementDO.setSecondSubjectName("");
} else {
//不是一级科目
billingStatementDO.setFirstSubjectName(expenseAccountPO.getUpperSubject());
billingStatementDO.setFirstSubjectCode(expenseAccountPO.getUpperSubjectCode());
billingStatementDO.setSecondSubjectCode(expenseAccountPO.getSubjectCode());
billingStatementDO.setSecondSubjectName(expenseAccountPO.getSubjectName());
}
billingStatementDO.setBelongModuleCode(expenseAccountPO.getBelongModuleCode());
billingStatementDO.setBelongModule(expenseAccountPO.getBelongModule());
}
}
//根据结算对象id查询结算对象数据,并赋值
if (StringUtils.isNotEmpty(billingStatementDO.getSettlementCustomersCode())) {
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(billingStatementDO.getSettlementCustomersCode());
if (null != settlementCustomers) {
billingStatementDO.setSettlementCustomersCode(settlementCustomers.getSettlementCustomersCode());
billingStatementDO.setSettlementEntity(settlementCustomers.getSettlementEntity());
billingStatementDO.setSettlementCustomersId(settlementCustomers.getSettlementCustomersId());
}
}
//根据费用类型id查询费用类型对象数据,并赋值
if (StringUtils.isNotEmpty(billingStatementDO.getServiceItemsCode())) {
AjaxResult ajaxResult = systemServiceFeign.getServiceItemsByCode(billingStatementDO.getServiceItemsCode());
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("费用类型未找到");
}
billingStatementDO.setServiceItemsManageId(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getLong("serviceItemsManageId"));
billingStatementDO.setServiceItemsName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("serviceItemsName"));
}
//根据合同编码查询合同信息,并赋值
if (StringUtils.isNotEmpty(billingStatementDO.getContractNumber())) {
AjaxResult ajaxResult = systemServiceFeign.getInfoByCode(billingStatementDO.getContractNumber());
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}
ContractManagePO contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class);
if (null == contractPO) {
throw new ServiceException("合同信息未找到");
}
billingStatementDO.setContractName(contractPO.getContractName());
billingStatementDO.setContractManageId(contractPO.getContractManageId());
billingStatementDO.setContractType(contractPO.getContractType());
}
//根据项目编码,查询项目信息并赋值
if (StringUtils.isNotEmpty(billingStatementDO.getProjectCode())) {
AjaxResult ajaxResult = systemServiceFeign.getProjectByCode(billingStatementDO.getProjectCode());
if (!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("项目信息未找到");
}
ProjectManagementPO projectManagePO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ProjectManagementPO.class);
if (null == projectManagePO) {
throw new ServiceException("项目信息未找到");
}
billingStatementDO.setProjectManageId(projectManagePO.getProjectManagementId());
billingStatementDO.setProjectName(projectManagePO.getProjectManagementName());
}
//来源系统
if (StringUtils.isNotEmpty(billingStatementDO.getBelongModuleCode())){
List<SysDictDataVo> modulesTypeList = null;
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.MODULES.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
modulesTypeList = JSON.parseArray(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if (modulesTypeList != null && modulesTypeList.size() > 0){
for (SysDictDataVo sysDictDataVo : modulesTypeList) {
if (billingStatementDO.getBelongModuleCode().equals(sysDictDataVo.getDictValue())){
billingStatementDO.setBelongModule(sysDictDataVo.getDictLabel());
break;
}
}
}
}
}
/**
* 修改计费流水
*/
public Boolean update(BillingStatementDO billingStatementDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//处理数据
handleDate(billingStatementDO);
return billingStatementDomainService.update(billingStatementDO);
}
/**
* 批量删除计费流水
*/
public boolean delete(Long[] billingStatementIds) {
return billingStatementDomainService.delete(billingStatementIds);
}
/**
* 获取计费流水详细信息
*/
public BillingStatementPO getInfo(Long billingStatementId) {
return billingStatementDomainService.getInfo(billingStatementId);
}
/**
* 根据id删除计费流水
*/
public Boolean deleteByIds(BillingStatementDTO billingStatementDTO) {
//只有已作废状态的记录可以操作删除
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选数据不能为空");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Set<String> billingStatementIds = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
Long[] documentTypeIds = billingStatementIds.stream().map(Long::valueOf).toArray(Long[]::new);
return billingStatementDomainService.delete(documentTypeIds);
}
/**
* 批量审核
*/
@Transactional
public void reviewBilling(BillingStatementDTO billingStatementDTO) {
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选审核对象不能为空");
}
billingStatementDomainService.reviewBilling(billingStatementDTO);
}
/**
* 批量费用红冲
*/
@Transactional
public void redFlushBilling(BillingStatementDTO billingStatementDTO) {
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选红冲对象不能为空");
}
billingStatementDomainService.redFlushBilling(billingStatementDTO);
}
/**
* 生成账单
*/
@Transactional
public Boolean generateBills(BillingStatementDTO billingStatementDTO) {
//获取当前登录用户信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
/*
首先对账单主体、来源系统、账单类型、组织进行唯一校验
对要生成账单的流水加锁
然后判断流水状态是否满足生成账单需求
最后生成账单
*/
billingStatementDomainService.checkUniqueEntity(billingStatementDTO.getBillingStatementIds());
//校验完成后,生成账单
Boolean flag1 = billManageApplicationService.saveBill(billingStatementDTO);
//修改流水状态
billingStatementDTO.setBillingState(3);
Boolean flag2 = billingStatementDomainService.updateBillingState(billingStatementDTO);
if (flag1 && flag2) {
return true;
} else {
throw new ServiceException("生成账单失败");
}
}
/**
* 批量流水作废
*/
@Transactional
public void nullifyByIds(BillingStatementDTO billingStatementDTO) {
if (!StringUtils.isNotEmpty(billingStatementDTO.getBillingStatementIds())) {
throw new ServiceException("所选作废对象不能为空");
}
billingStatementDomainService.nullifyByIds(billingStatementDTO);
}
/**
* 查询批量出账列表
*/
public List<BillManagePO> queryPaymentOutList(BillingStatementDO billingStatementDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
List<BillManagePO> billManagePOList = new ArrayList<>();
List<BillingStatementPO> billingStatementPOList = billingStatementDomainService.queryPaymentOutList(billingStatementDO);
if(billingStatementPOList != null && billingStatementPOList.size() > 0){
//按 结算对象、来源系统、收支类型、组织进行分组
Map<String, List<BillingStatementPO>> billingStatementPOSMap = billingStatementPOList.stream().collect(Collectors.groupingBy(billingStatementPO -> billingStatementPO.getOrganizationId()+"_"+billingStatementPO.getSettlementCustomersCode()+"_"+billingStatementPO.getAccountExpenseType()+"_"+billingStatementPO.getBelongModuleCode()));
billingStatementPOSMap.forEach((key,value)->{
if(value.size()>0){
//生成账单浏览
BillManagePO billManagePO = billManageDomainService.getBillBrowse(value);
billManagePOList.add(billManagePO);
}
});
}
return billManagePOList;
}
/**
* 批量生成账单
*/
@Transactional
public void batchGenerateBills(BillingStatementDTO billingStatementDTO) {
/*
首先查询所有数据,并根据结算对象、来源系统、收支类型、组织进行分组
然后每组分别调用生成账单
如果生成失败,则回滚流水账单到已审核状态,如果成功则状态更新到已出账
*/
//校验是否可进行生成账单操作
if (!billingStatementDomainService.checkGenerateBills(billingStatementDTO)) {
throw new ServiceException("生成账单失败,请刷新后再试");
}
billingStatementDomainService.batchGenerateBills(billingStatementDTO);
}
/**
* 查询计费流水列表统计
*/
public Map<String, String> queryListCount(BillingStatementDO billingStatementDO) {
Map<String, String> result = new HashMap<>();
result.put("all","0");
result.put("outgoing","0");
result.put("unpaidAccount","0");
result.put("other","0");
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
List<BillingStatementPO> billingStatementPOS = billingStatementDomainService.queryList(billingStatementDO);
if(billingStatementPOS != null && billingStatementPOS.size() > 0){
//过滤出流水状态为待审核和已审核的并统计
long unpaidAccount = billingStatementPOS.stream().filter(billingStatementPO -> billingStatementPO.getBillingState() == 1 || billingStatementPO.getBillingState() == 2).count();
long outgoing = billingStatementPOS.stream().filter(billingStatementPO -> billingStatementPO.getBillingState() == 3).count();
long other = billingStatementPOS.stream().filter(billingStatementPO -> billingStatementPO.getBillingState() == 4 || billingStatementPO.getBillingState() == 5).count();
result.put("all",String.valueOf(billingStatementPOS.size()));
result.put("outgoing",String.valueOf(outgoing));
result.put("unpaidAccount",String.valueOf(unpaidAccount));
result.put("other",String.valueOf(other));
}
return result;
}
/**
* 新增并返回id
*/
public Long insertAndReturnId(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillingStatementDO billingStatementDO = new BillingStatementAssembler().toDO(billingStatementDTO);
//处理数据
handleDate(billingStatementDO);
billingStatementDO.setDataSources(2);
if(StringUtils.isEmpty(billingStatementDO.getBillingFlow())){
billingStatementDO.setBillingFlow(OrderSequence.getOrderCode("JFLS"));
}
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingStatementDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingStatementDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return billingStatementDomainService.insertAndReturnId(billingStatementDO);
}
/**
* 应收账单-添加费用
*/
public BillingStatementPO addCost(BillingStatementDO billingStatementDO) {
/*
此方法只进行实体返回,并不进行数据保存
*/
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillingStatementPO billingStatementPO = new BillingStatementPO();
//处理数据
handleDate(billingStatementDO);
BeanUtils.copyProperties(billingStatementDO,billingStatementPO);
billingStatementPO.setBillingTotalAmount(billingStatementDO.getBillingAmount());
billingStatementPO.setDataSources(2);
billingStatementPO.setBillingFlow(OrderSequence.getOrderCode("JFLS"));
billingStatementPO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingStatementPO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingStatementPO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return billingStatementPO;
}
/**
* 应收账单-添加明细
*/
public List<BillingStatementPO> getBillDetailsList(BillingStatementDO billingStatementDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1) {
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
return billingStatementDomainService.getBillDetailsList(billingStatementDO);
}
}
@@ -0,0 +1,725 @@
package com.mhd.bms.application.server.businessDocument;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.application.server.billingRules.CostCalculationApplicationService;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import com.mhd.bms.domain.businessDocument.service.BusinessDocumentDomainService;
import com.mhd.bms.domain.costCalculation.po.BillingCostPo;
import com.mhd.bms.domain.documentType.entity.DocumentFromEntity;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.infrastructure.feign.vo.ContractManageDetailPO;
import com.mhd.bms.infrastructure.feign.vo.ContractManagePO;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.interfaces.assembler.businessDocument.BusinessDocumentAssembler;
import com.mhd.bms.interfaces.dto.billingRules.CostCalculationDTO;
import com.mhd.bms.interfaces.dto.businessDocument.BusinessDocumentDTO;
import com.mhd.common.core.domain.dto.BusinessDataPushDTO;
import com.mhd.common.core.domain.po.OrganizationPo;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.enums.BelongModuleCode;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.ProductServiceFeign;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 业务单据ApplicationService
*
* @author gen
* @date 2024-06-21
*/
@Service
@Slf4j
public class BusinessDocumentApplicationService {
@Autowired
private BusinessDocumentDomainService businessDocumentDomainService;
@Autowired
private ProductServiceFeign productServiceFeign;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private DocumentTypeDomainService documentTypeDomainService;
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
@Autowired
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private CostCalculationApplicationService costCalculationApplicationService;
/**
* 分页查询业务单据列表
*/
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
businessDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return businessDocumentDomainService.queryList(businessDocumentDO);
}
/**
* 新增业务单据
*/
@Transactional(rollbackFor = Exception.class)
public Boolean insert(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验使用的表单是否必填校验
checkDoucumentType(businessDocumentDO);
//处理数据
handleDate(businessDocumentDO);
businessDocumentDO.setDataSources(2);
businessDocumentDO.setBusinessFlow(OrderSequence.getOrderCode("LS"));
businessDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
businessDocumentDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
businessDocumentDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
//调用费用计算,计算费用金额进行保存
CostCalculationDTO costCalculationDTO = new CostCalculationDTO();
costCalculationDTO.setOriginalBusinessNum(businessDocumentDO.getOriginalBusinessNum());
costCalculationDTO.setContractNumber(businessDocumentDO.getContractNumber());
costCalculationDTO.setFormJson(businessDocumentDO.getDocumentFormJson());
costCalculationDTO.setSubjectCode(StringUtils.isEmpty(businessDocumentDO.getSecondSubjectCode()) ? businessDocumentDO.getFirstSubjectCode():businessDocumentDO.getSecondSubjectCode());
costCalculationDTO.setDocumentTypeCode(businessDocumentDO.getDocumentTypeCode());
BillingCostPo billingCostPo = costCalculationApplicationService.costCalculation(costCalculationDTO);
businessDocumentDO.setEstimatedCost(billingCostPo.getComputationalCost());
// businessDocumentDO.setEstimatedCost(new BigDecimal("100"));
return businessDocumentDomainService.insert(businessDocumentDO);
}
/**
* 校验表单单据类型必填
* @param businessDocumentDO
*/
private void checkDoucumentType(BusinessDocumentDO businessDocumentDO) {
if(!StringUtils.isNotEmpty(businessDocumentDO.getDocumentTypeCode())){
throw new ServiceException("所选表单不能为空");
}
DocumentType documentType = documentTypeDomainService.queryByCode(businessDocumentDO.getDocumentTypeCode());
if(null == documentType){
throw new ServiceException("表单类型信息未找到");
}
if(StringUtils.isNotEmpty(documentType.getFormJson())){
//将form的json数据转换为DocumentFromEntity实体集合
List<DocumentFromEntity> documentFromEntityList = JSONObject.parseArray(documentType.getFormJson(), DocumentFromEntity.class);
//将传来的documentFormJson表单json数据和查询出的集合比较,判断是否必填
//将documentFormJson转为jsonObject
JSONObject businessDocumentDOJsonObject = JSONObject.parseObject(businessDocumentDO.getDocumentFormJson());
documentFromEntityList.forEach(documentFromEntity -> {
if(documentFromEntity.getNotNull() == 1){
if(businessDocumentDOJsonObject.get(documentFromEntity.getField()) == null){
throw new ServiceException(documentFromEntity.getTitle()+"不能为空");
}
}
});
}
}
/**
* 处理数据
*/
private void handleDate(BusinessDocumentDO businessDocumentDO) {
if(businessDocumentDO.getOrganizationId() != null){
//获取组织信息
AjaxResult ajaxResult = productServiceFeign.getOrganizationInfo(businessDocumentDO.getOrganizationId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("选中组织信息未找到");
}
OrganizationPo organizationPo = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), OrganizationPo.class);
if(null == organizationPo){
throw new ServiceException("组织信息未找到");
}
businessDocumentDO.setOrganizationName(organizationPo.getOrganizationName());
businessDocumentDO.setTopOrganizationId(organizationPo.getParentOrganizationId());
if(organizationPo.getParentOrganizationId()==0){
businessDocumentDO.setTopOrganizationId(businessDocumentDO.getOrganizationId());
}
}
if(StringUtils.isNotEmpty(businessDocumentDO.getProjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getProjectByCode(businessDocumentDO.getProjectCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("项目信息未找到");
}
businessDocumentDO.setProjectName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("projectName"));
businessDocumentDO.setProjectManageId(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getLong("projectManageId"));
}
//根据单据类型id查询单据类型数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getDocumentTypeCode())){
DocumentType documentType = documentTypeDomainService.queryByCode(businessDocumentDO.getDocumentTypeCode());
if(null != documentType){
businessDocumentDO.setDocumentType(documentType.getDocumentType());
businessDocumentDO.setDocumentTypeCode(documentType.getDocumentTypeCode());
businessDocumentDO.setDocumentTypeId(documentType.getDocumentTypeId());
}
}
//来源系统
if (StringUtils.isNotEmpty(businessDocumentDO.getBelongModuleCode())){
List<SysDictDataVo> modulesTypeList = null;
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.MODULES.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
modulesTypeList = JSON.parseArray(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if (modulesTypeList != null && modulesTypeList.size() > 0){
for (SysDictDataVo sysDictDataVo : modulesTypeList) {
if (businessDocumentDO.getBelongModuleCode().equals(sysDictDataVo.getDictValue())){
businessDocumentDO.setBelongModule(sysDictDataVo.getDictLabel());
break;
}
}
}
}
//根据结算对象code查询结算对象数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getSettlementCustomersCode())){
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(businessDocumentDO.getSettlementCustomersCode());
if(null == settlementCustomers){
throw new ServiceException("结算对象信息未找到");
}
businessDocumentDO.setSettlementCustomersCode(settlementCustomers.getSettlementCustomersCode());
businessDocumentDO.setSettlementEntity(settlementCustomers.getSettlementEntity());
businessDocumentDO.setSettlementCustomersId(settlementCustomers.getSettlementCustomersId());
//如果前端没传项目code则从结算对象中获取
if(StringUtils.isEmpty(businessDocumentDO.getProjectCode())){
businessDocumentDO.setProjectCode(settlementCustomers.getProjectCode());
businessDocumentDO.setProjectName(settlementCustomers.getProjectName());
}
}
//根据费用类型id查询费用类型对象数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getServiceItemsCode())){
AjaxResult ajaxResult = systemServiceFeign.getServiceItemsByCode(businessDocumentDO.getServiceItemsCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("费用类型未找到");
}
businessDocumentDO.setServiceItemsManageId(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getLong("serviceItemsManageId"));
businessDocumentDO.setServiceItemsName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("serviceItemsName"));
}
//根据费用科目code查询费用信息,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getSecondSubjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getSubInfoByCode(businessDocumentDO.getSecondSubjectCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
ExpenseAccountPO expenseAccountPO = JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), ExpenseAccountPO.class);
if(null == expenseAccountPO || expenseAccountPO.getExpenseAccountId()==null){
throw new ServiceException("费用科目信息未找到");
}
if(expenseAccountPO.getFirstSubjectFlag()==1){
//如果是一级科目
businessDocumentDO.setFirstSubjectName(expenseAccountPO.getSubjectName());
businessDocumentDO.setFirstSubjectCode(expenseAccountPO.getSubjectCode());
businessDocumentDO.setSecondSubjectCode("");
}else {
//不是一级科目
businessDocumentDO.setFirstSubjectName(expenseAccountPO.getUpperSubject());
businessDocumentDO.setFirstSubjectCode(expenseAccountPO.getUpperSubjectCode());
businessDocumentDO.setSecondSubjectCode(expenseAccountPO.getSubjectCode());
businessDocumentDO.setSecondSubjectName(expenseAccountPO.getSubjectName());
}
//判断如果前端没有传费用类别,则此处根据费用科目获取关联费用类别
if(StringUtils.isEmpty(businessDocumentDO.getServiceItemsCode())){
AjaxResult ajaxResultServiceItems = systemServiceFeign.getServiceItemsById(businessDocumentDO.getServiceItemsManageId());
if("200".equals(String.valueOf(ajaxResultServiceItems.get("code")))) {
businessDocumentDO.setServiceItemsCode(JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResultServiceItems.get("data"))).getString("serviceItemsCode"));
businessDocumentDO.setServiceItemsName(JSONObject.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResultServiceItems.get("data"))).getString("serviceItemsName"));
}
}
}
}
//根据结算对象和费用科目,获取合同
int contractType = 2;
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1;
}
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomer(businessDocumentDO.getSettlementCustomersCode(),contractType);
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}
ContractManagePO contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class);
if (null == contractPO) {
throw new ServiceException("合同信息未找到");
}
businessDocumentDO.setContractName(contractPO.getContractName());
businessDocumentDO.setContractNumber(contractPO.getContractNumber());
}
/**
* 修改业务单据
*/
@Transactional(rollbackFor = Exception.class)
public Boolean update(BusinessDocumentDO businessDocumentDO) {
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.getInfo(businessDocumentDO.getBusinessDocumentId());
if(null == businessDocumentPO){
throw new ServiceException("业务单据信息未找到");
}
if(businessDocumentPO.getDataSources()==1){
throw new ServiceException("非手工录入数据,无法修改");
}
//校验使用的表单是否必填校验
checkDoucumentType(businessDocumentDO);
//处理数据
handleDate(businessDocumentDO);
return businessDocumentDomainService.update(businessDocumentDO);
}
/**
* 批量删除业务单据
*/
public boolean delete(Long[] businessDocumentIds) {
return businessDocumentDomainService.delete(businessDocumentIds);
}
/**
* 获取业务单据详细信息
*/
public BusinessDocumentPO getInfo(Long businessDocumentId)
{
return businessDocumentDomainService.getInfo(businessDocumentId);
}
/**
* 同步业务单据数据
*/
public String syncData(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验必填项
checkDoucumentType(businessDocumentDO);
//处理数据
handleDate(businessDocumentDO);
String flow = OrderSequence.getOrderCode("LS");
businessDocumentDO.setBusinessFlow(flow);
businessDocumentDO.setDataSources(1);
businessDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
businessDocumentDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
businessDocumentDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
//TODO 计算费用并保存
businessDocumentDomainService.insert(businessDocumentDO);
return flow;
}
/**
* 费用重算(批量)
*/
@Transactional
public Boolean costRecalculation(List<BusinessDocumentDTO> businessDocumentDTOList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(businessDocumentDTOList == null || businessDocumentDTOList.size()==0){
throw new ServiceException("所选记录不能为空");
}
//循环遍历并保存重算后金额
List<BusinessDocument> businessDocumentList = new ArrayList<>();
for (BusinessDocumentDTO businessDocumentDTO : businessDocumentDTOList) {
BusinessDocument businessDocument = new BusinessDocument();
businessDocument.setBusinessDocumentId(businessDocumentDTO.getBusinessDocumentId());
businessDocument.setBillAmount(businessDocumentDTO.getNewBillAmount());
businessDocument.setEstimatedCost(businessDocumentDTO.getRecalculateCost());
businessDocument.setUpdateBy(loginUser.getUserPo().getUserId());
businessDocument.setUpdateByName(loginUser.getUserPo().getUserName());
businessDocument.setUpdateTime(new Date());
businessDocumentList.add(businessDocument);
}
return businessDocumentDomainService.saveOrUpdateBatch(businessDocumentList);
}
/**
* 批量删除业务单据
* @param businessDocumentDTO
* @return
*/
@Transactional
public void deleteByIds(BusinessDocumentDTO businessDocumentDTO) {
//只有已作废状态的记录可以操作删除
if(!StringUtils.isNotEmpty(businessDocumentDTO.getBusinessDocumentIds())){
throw new ServiceException("所选数据不能为空");
}
List<Long> businessDocumentIdLongList = new ArrayList<>();
Set<String> businessDocumentIds = Stream.of(businessDocumentDTO.getBusinessDocumentIds().split(",")).collect(Collectors.toSet());
for (String businessDocumentId : businessDocumentIds) {
Long businessDocumentIdLong = Long.valueOf(businessDocumentId);
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.getInfo(businessDocumentIdLong);
if(null == businessDocumentPO){
throw new ServiceException("业务单据信息未找到");
}
if(businessDocumentPO.getBusinessState()!=5){
throw new ServiceException("所选记录"+ businessDocumentPO.getBusinessFlow() +"未作废不可删除");
}
businessDocumentIdLongList.add(businessDocumentIdLong);
}
if(businessDocumentIdLongList.size()>0){
businessDocumentDomainService.deleteByIds(businessDocumentIdLongList);
}
}
/**
* 作废业务单据
*/
@Transactional
public void nullifyByIds(BusinessDocumentDTO businessDocumentDTO) {
//只有未生效状态的记录可以操作作废
if(!StringUtils.isNotEmpty(businessDocumentDTO.getBusinessDocumentIds())){
throw new ServiceException("所选数据不能为空");
}
List<Long> businessDocumentIdLongList = new ArrayList<>();
Set<String> businessDocumentIds = Stream.of(businessDocumentDTO.getBusinessDocumentIds().split(",")).collect(Collectors.toSet());
for (String businessDocumentId : businessDocumentIds) {
Long businessDocumentIdLong = Long.valueOf(businessDocumentId);
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.getInfo(businessDocumentIdLong);
if(null == businessDocumentPO){
throw new ServiceException("业务单据信息未找到");
}
if(businessDocumentPO.getBusinessState()!=1){
throw new ServiceException("所选记录"+ businessDocumentPO.getBusinessFlow() +"已生效不可作废");
}
businessDocumentIdLongList.add(businessDocumentIdLong);
}
if(businessDocumentIdLongList.size()>0){
businessDocumentDomainService.nullifyByIds(businessDocumentIdLongList);
}
}
/**
* 生效业务单据
*/
@Transactional
public void takeEffectByIds(BusinessDocumentDTO businessDocumentDTO) {
//只有未生效状态的记录可以操作生效变更为已生效状态
if(!StringUtils.isNotEmpty(businessDocumentDTO.getBusinessDocumentIds())){
throw new ServiceException("所选数据不能为空");
}
List<Long> businessDocumentIdLongList = new ArrayList<>();
Set<String> businessDocumentIds = Stream.of(businessDocumentDTO.getBusinessDocumentIds().split(",")).collect(Collectors.toSet());
for (String businessDocumentId : businessDocumentIds) {
Long businessDocumentIdLong = Long.valueOf(businessDocumentId);
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.getInfo(businessDocumentIdLong);
if(null == businessDocumentPO){
throw new ServiceException("业务单据信息未找到");
}
if(businessDocumentPO.getBusinessState()!=1 && businessDocumentPO.getBusinessState()!=4){
throw new ServiceException("所选记录"+ businessDocumentPO.getBusinessFlow() +"已生效不可操作");
}
businessDocumentIdLongList.add(businessDocumentIdLong);
}
if(businessDocumentIdLongList.size()>0){
businessDocumentDomainService.takeEffectByIds(businessDocumentIdLongList);
}
}
/**
* 审核业务单据
*/
@Transactional
public void auditByIds(BusinessDocumentDTO businessDocumentDTO) {
//只有已生效状态的记录可以操作审核变更为已计费状态并生成计费流水
if(!StringUtils.isNotEmpty(businessDocumentDTO.getBusinessDocumentIds())){
throw new ServiceException("所选数据不能为空");
}
List<Long> businessDocumentIdLongList = new ArrayList<>();
Set<String> businessDocumentIds = Stream.of(businessDocumentDTO.getBusinessDocumentIds().split(",")).collect(Collectors.toSet());
for (String businessDocumentId : businessDocumentIds) {
Long businessDocumentIdLong = Long.valueOf(businessDocumentId);
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.getInfo(businessDocumentIdLong);
if(null == businessDocumentPO){
throw new ServiceException("业务单据信息未找到");
}
if(businessDocumentPO.getBusinessState()!=2){
throw new ServiceException("所选记录"+ businessDocumentPO.getBusinessFlow() +"不是已生效状态不可操作");
}
//生成计费流水
billingStatementDomainService.generateFlow(businessDocumentPO);
businessDocumentIdLongList.add(businessDocumentIdLong);
}
if(businessDocumentIdLongList.size()>0){
businessDocumentDomainService.auditByIds(businessDocumentIdLongList,businessDocumentDTO);
}
}
/**
* 导入业务单据
*/
public Boolean importDocument(List<BusinessDocumentDTO> businessDocumentDTOList) {
List<BusinessDocument> businessDocumentList = new ArrayList<>();
if(businessDocumentDTOList != null && businessDocumentDTOList.size()>0){
for (BusinessDocumentDTO businessDocumentDTO : businessDocumentDTOList) {
BusinessDocument businessDocument = new BusinessDocument();
//处理导入业务单据
BeanUtils.copyProperties(businessDocumentDTO,businessDocument);
businessDocument.setDataSources(2);
businessDocumentList.add(businessDocument);
}
}
return businessDocumentDomainService.saveBatch(businessDocumentList);
}
/**
* 费用重算列表查询
* @param businessDocumentDO
* @return
*/
public List<BusinessDocumentPO> costRecalculationList(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(!StringUtils.isNotEmpty(businessDocumentDO.getBusinessDocumentIds())){
throw new ServiceException("所选记录不能为空");
}
Set<String> businessDocumentIds = Stream.of(businessDocumentDO.getBusinessDocumentIds().split(",")).collect(Collectors.toSet());
if(businessDocumentIds.size()>10){
throw new ServiceException("重算数量过大,建议选中十条以内");
}
//查询业务单据
BusinessDocumentDO queryParam = new BusinessDocumentDO();
queryParam.setBusinessDocumentIdSet(businessDocumentIds);
List<BusinessDocumentPO> businessDocumentPOList = businessDocumentDomainService.queryList(queryParam);
if(null == businessDocumentPOList || businessDocumentPOList.size()==0){
throw new ServiceException("业务单据信息未找到");
}
//判断是否可进行费用重算,盘算业务状态是否已计费,计费之前可进行费用重算并保存
long count = businessDocumentPOList.stream().filter(businessDocumentPO -> businessDocumentPO.getBusinessState() > 2).count();
if(count >0){
throw new ServiceException("所选数据中包含已计费等状态,无法进行费用重算");
}
//循环集合,重新计算费用
for (BusinessDocumentPO businessDocumentPO : businessDocumentPOList) {
//计算费用
CostCalculationDTO costCalculationDTO = new CostCalculationDTO();
costCalculationDTO.setOriginalBusinessNum(businessDocumentPO.getOriginalBusinessNum());
costCalculationDTO.setContractNumber(businessDocumentPO.getContractNumber());
costCalculationDTO.setFormJson(businessDocumentPO.getDocumentFormJson());
costCalculationDTO.setSubjectCode(StringUtils.isEmpty(businessDocumentPO.getSecondSubjectCode()) ? businessDocumentPO.getFirstSubjectCode():businessDocumentPO.getSecondSubjectCode());
costCalculationDTO.setDocumentTypeCode(businessDocumentPO.getDocumentTypeCode());
BillingCostPo billingCostPo = null;
try {
billingCostPo = costCalculationApplicationService.costCalculation(costCalculationDTO);
}catch (Exception e){
businessDocumentPO.setRecalculateCostFailRemark(e.getMessage());
}
if(null != billingCostPo){
businessDocumentPO.setRecalculateCost(billingCostPo.getComputationalCost());
}
}
return businessDocumentPOList;
}
/**
* 业务系统推送BMS业务单据保存
*/
@Transactional
public Boolean pushSyncData(BusinessDocumentDO businessDocumentDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验使用的表单是否必填校验
checkDoucumentType(businessDocumentDO);
//根据结算对象和费用科目,获取合同
int contractType = 2;
if(businessDocumentDO.getBelongModuleCode().equals(BelongModuleCode.WMS.getCode())){
contractType = 1;
}
AjaxResult ajaxResult = systemServiceFeign.getInfoByCustomer(businessDocumentDO.getSettlementCustomersCode(),contractType);
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("合同信息未找到");
}
ContractManagePO contractPO = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class);
if (null == contractPO) {
throw new ServiceException("合同信息未找到");
}
businessDocumentDO.setContractName(contractPO.getContractName());
businessDocumentDO.setContractNumber(contractPO.getContractNumber());
//处理数据
businessDocumentDO.setDataSources(1);
businessDocumentDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
businessDocumentDO.setOrganizationId(businessDocumentDO.getOrganizationId()==null ? loginUser.getUserPo().getOrganizationId() : businessDocumentDO.getOrganizationId());
handleDateSync(businessDocumentDO);
List<BusinessDocument> businessDocumentList = new ArrayList<>();
//根据合同获取合同明细信息
List<ContractManageDetailPO> contractManageDetailPOList = contractPO.getContractManageDetailPOList();
//遍历contractManageDetailPOList集合,根据合同维护的费用科目,生成业务单据
for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOList) {
/*
判断合同详情中的单据类型,如果传来的单据类型在合同中,则生成对应的费用科目所对应的业务单据
校验根据原始业务单号和费用科目,查询业务单据是否已存在,如果已存在则修改,如果不存在则新增
业务系统只传业务数据,同时还要传结算主体,bms根据结算主体获取合同信息,进而进行下一步操作
*/
Set<String> documentTypeCodeSet = Stream.of(contractManageDetailPO.getDocumentTypeCode().split(",")).collect(Collectors.toSet());
if(documentTypeCodeSet.contains(businessDocumentDO.getDocumentTypeCode())){
//生成一条业务单据
BusinessDocument businessDocument = new BusinessDocument();
BeanUtils.copyProperties(businessDocumentDO,businessDocument);
BusinessDocumentDO params = new BusinessDocumentDO();
params.setOriginalBusinessNum(businessDocumentDO.getOriginalBusinessNum());
params.setSecondSubjectCode(StringUtils.isEmpty(contractManageDetailPO.getSecondSubjectCode()) ? contractManageDetailPO.getFirstSubjectCode():contractManageDetailPO.getSecondSubjectCode());
BusinessDocumentPO businessDocumentPO = businessDocumentDomainService.queryByOriginalBusinessNumAndSubjectCode(params);
if(null != businessDocumentPO){
businessDocument.setBusinessDocumentId(businessDocumentPO.getBusinessDocumentId());
}
businessDocument.setBusinessFlow(OrderSequence.getOrderCode("LS"));
businessDocument.setFirstSubjectCode(contractManageDetailPO.getFirstSubjectCode());
businessDocument.setFirstSubjectName(contractManageDetailPO.getFirstSubjectName());
businessDocument.setSecondSubjectCode(contractManageDetailPO.getSecondSubjectCode());
businessDocument.setSecondSubjectName(contractManageDetailPO.getSecondSubjectName());
//调用费用计算,计算费用金额进行保存
CostCalculationDTO costCalculationDTO = new CostCalculationDTO();
costCalculationDTO.setOriginalBusinessNum(businessDocument.getOriginalBusinessNum());
costCalculationDTO.setContractNumber(businessDocument.getContractNumber());
costCalculationDTO.setFormJson(businessDocument.getDocumentFormJson());
costCalculationDTO.setSubjectCode(StringUtils.isEmpty(businessDocument.getSecondSubjectCode()) ? businessDocument.getFirstSubjectCode():businessDocument.getSecondSubjectCode());
costCalculationDTO.setDocumentTypeCode(businessDocument.getDocumentTypeCode());
BillingCostPo billingCostPo = costCalculationApplicationService.costCalculation(costCalculationDTO);
businessDocumentDO.setEstimatedCost(billingCostPo.getComputationalCost());
businessDocumentList.add(businessDocument);
}
}
return businessDocumentDomainService.saveOrUpdateBatch(businessDocumentList);
}
private void handleDateSync(BusinessDocumentDO businessDocumentDO) {
if(businessDocumentDO.getOrganizationId() != null){
//获取组织信息
AjaxResult ajaxResult = productServiceFeign.getOrganizationInfo(businessDocumentDO.getOrganizationId());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))){
throw new ServiceException("选中组织信息未找到");
}
OrganizationPo organizationPo = JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), OrganizationPo.class);
if(null == organizationPo){
throw new ServiceException("组织信息未找到");
}
businessDocumentDO.setOrganizationName(organizationPo.getOrganizationName());
businessDocumentDO.setTopOrganizationId(organizationPo.getParentOrganizationId());
if(organizationPo.getParentOrganizationId()==0){
businessDocumentDO.setTopOrganizationId(businessDocumentDO.getOrganizationId());
}
}
if(StringUtils.isNotEmpty(businessDocumentDO.getProjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getProjectByCode(businessDocumentDO.getProjectCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("项目信息未找到");
}
businessDocumentDO.setProjectName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("projectName"));
businessDocumentDO.setProjectManageId(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getLong("projectManageId"));
}
//根据单据类型id查询单据类型数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getDocumentTypeCode())){
DocumentType documentType = documentTypeDomainService.queryByCode(businessDocumentDO.getDocumentTypeCode());
if(null != documentType){
businessDocumentDO.setDocumentType(documentType.getDocumentType());
businessDocumentDO.setDocumentTypeCode(documentType.getDocumentTypeCode());
businessDocumentDO.setDocumentTypeId(documentType.getDocumentTypeId());
}
}
//来源系统
if (StringUtils.isNotEmpty(businessDocumentDO.getBelongModuleCode())){
List<SysDictDataVo> modulesTypeList = null;
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.MODULES.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
modulesTypeList = JSON.parseArray(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if (modulesTypeList != null && modulesTypeList.size() > 0){
for (SysDictDataVo sysDictDataVo : modulesTypeList) {
if (businessDocumentDO.getBelongModuleCode().equals(sysDictDataVo.getDictValue())){
businessDocumentDO.setBelongModule(sysDictDataVo.getDictLabel());
break;
}
}
}
}
//根据结算对象code查询结算对象数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getSettlementCustomersCode())){
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(businessDocumentDO.getSettlementCustomersCode());
if(null == settlementCustomers){
throw new ServiceException("结算对象信息未找到");
}
businessDocumentDO.setSettlementCustomersCode(settlementCustomers.getSettlementCustomersCode());
businessDocumentDO.setSettlementEntity(settlementCustomers.getSettlementEntity());
businessDocumentDO.setSettlementCustomersId(settlementCustomers.getSettlementCustomersId());
//如果前端没传项目code则从结算对象中获取
if(StringUtils.isEmpty(businessDocumentDO.getProjectCode())){
businessDocumentDO.setProjectCode(settlementCustomers.getProjectCode());
businessDocumentDO.setProjectName(settlementCustomers.getProjectName());
}
}
//根据费用类型id查询费用类型对象数据,并赋值
if(StringUtils.isNotEmpty(businessDocumentDO.getServiceItemsCode())){
AjaxResult ajaxResult = systemServiceFeign.getServiceItemsByCode(businessDocumentDO.getServiceItemsCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("费用类型未找到");
}
businessDocumentDO.setServiceItemsManageId(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getLong("serviceItemsManageId"));
businessDocumentDO.setServiceItemsName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("serviceItemsName"));
}
}
/**
* 业务系统推送BMS业务单据保存 (批量)
*/
@Transactional
public Boolean pushSyncDataList(List<BusinessDataPushDTO> businessDataPushDTOList) {
if(businessDataPushDTOList != null && businessDataPushDTOList.size() > 0){
for (BusinessDataPushDTO businessDataPushDTO : businessDataPushDTOList) {
//转换实体
BusinessDocumentDO businessDocumentDO = new BusinessDocumentAssembler().syncDataAssemble(businessDataPushDTO);
if(!pushSyncData(businessDocumentDO)){
throw new ServiceException("保存单据失败,请重试");
}
}
}
return true;
}
}
@@ -0,0 +1,102 @@
package com.mhd.bms.application.server.conditionalMapping;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.conditionalMapping.repository.po.ConditionalMappingPO;
import com.mhd.bms.domain.conditionalMapping.repository.todo.ConditionalMappingDO;
import com.mhd.bms.domain.conditionalMapping.service.ConditionalMappingDomainService;
import com.mhd.bms.interfaces.dto.conditionalMapping.ConditionalMappingDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 条件映射管理ApplicationService
*
* @author gen
* @date 2024-08-07
*/
@Service
@Slf4j
public class ConditionalMappingApplicationService {
@Autowired
private ConditionalMappingDomainService conditionalMappingDomainService;
/**
* 分页查询条件映射管理列表
*/
public List<ConditionalMappingPO> queryList(ConditionalMappingDO conditionalMappingDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
conditionalMappingDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return conditionalMappingDomainService.queryList(conditionalMappingDO);
}
/**
* 新增条件映射管理
*/
public Boolean insert(ConditionalMappingDO conditionalMappingDO) {
//获取当前登录人
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
conditionalMappingDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
conditionalMappingDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
conditionalMappingDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return conditionalMappingDomainService.insert(conditionalMappingDO);
}
/**
* 修改条件映射管理
*/
public Boolean update(ConditionalMappingDO conditionalMappingDO) {
return conditionalMappingDomainService.update(conditionalMappingDO);
}
/**
* 批量删除条件映射管理
*/
public boolean delete(Long[] conditionalMappingIds) {
return conditionalMappingDomainService.delete(conditionalMappingIds);
}
/**
* 获取条件映射管理详细信息
*/
public ConditionalMappingPO getInfo(Long conditionalMappingId)
{
return conditionalMappingDomainService.getInfo(conditionalMappingId);
}
/**
* 批量删除
* @param conditionalMappingDTO
* @return
*/
public Boolean deleteByIds(ConditionalMappingDTO conditionalMappingDTO) {
if(!StringUtils.isNotEmpty(conditionalMappingDTO.getConditionalMappingIds())){
throw new ServiceException("条件映射ID不能为空");
}
Set<String> conditionalMappingIds = Stream.of(conditionalMappingDTO.getConditionalMappingIds().split(",")).collect(Collectors.toSet());
Long[] ids = conditionalMappingIds.stream().map(Long::valueOf).toArray(Long[]::new);
return conditionalMappingDomainService.delete(ids);
}
}
@@ -0,0 +1,174 @@
package com.mhd.bms.application.server.documentType;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.repository.todo.DocumentTypeDO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.interfaces.dto.documentType.DocumentTypeDTO;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 单据类型ApplicationService
*
* @author gen
* @date 2024-06-18
*/
@Service
@Slf4j
public class DocumentTypeApplicationService {
@Autowired
private DocumentTypeDomainService documentTypeDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
/**
* 分页查询单据类型列表
*/
public List<DocumentTypePO> queryList(DocumentTypeDO documentTypeDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
documentTypeDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return documentTypeDomainService.queryList(documentTypeDO);
}
/**
* 新增单据类型
*/
public Boolean insert(DocumentTypeDO documentTypeDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验编码唯一性
checkCode(documentTypeDO);
//处理数据字典
handleDict(documentTypeDO);
documentTypeDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
documentTypeDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
documentTypeDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return documentTypeDomainService.insert(documentTypeDO);
}
/**
* 校验单据类型编码唯一性
*/
private void checkCode(DocumentTypeDO documentTypeDO) {
if(!StringUtils.isNotEmpty(documentTypeDO.getDocumentTypeCode())){
throw new ServiceException("单据类型编码不能为空");
}
DocumentType documentType = documentTypeDomainService.queryByCode(documentTypeDO.getDocumentTypeCode());
if (documentType != null){
throw new ServiceException("单据类型编码已存在");
}
}
/**
* 处理数据字典信息
*/
private void handleDict(DocumentTypeDO documentTypeDO) {
//查询来源模块数据字典
if(StringUtils.isNotEmpty(documentTypeDO.getBelongModuleCode())){
List<SysDictDataVo> modulesTypeList = null;
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.MODULES.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
modulesTypeList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if (modulesTypeList != null && modulesTypeList.size() > 0){
for (SysDictDataVo sysDictDataVo : modulesTypeList) {
if (documentTypeDO.getBelongModuleCode().equals(sysDictDataVo.getDictValue())){
documentTypeDO.setBelongModule(sysDictDataVo.getDictLabel());
break;
}
}
}
}
}
/**
* 修改单据类型
*/
public Boolean update(DocumentTypeDO documentTypeDO) {
//校验编码唯一性
if(!StringUtils.isNotEmpty(documentTypeDO.getDocumentTypeCode())){
throw new ServiceException("单据类型编码不能为空");
}
DocumentType documentType = documentTypeDomainService.queryByCode(documentTypeDO.getDocumentTypeCode());
if (documentType != null && !Objects.equals(documentType.getDocumentTypeId(), documentTypeDO.getDocumentTypeId())){
throw new ServiceException("单据类型编码已存在");
}
//处理数据字典
handleDict(documentTypeDO);
return documentTypeDomainService.update(documentTypeDO);
}
/**
* 批量删除单据类型
*/
public boolean delete(Long[] documentTypeIds) {
return documentTypeDomainService.delete(documentTypeIds);
}
/**
* 获取单据类型详细信息
*/
public DocumentTypePO getInfo(Long documentTypeId)
{
return documentTypeDomainService.getInfo(documentTypeId);
}
/**
* 批量删除单据类型
* @param documentTypeDTO
* @return
*/
public Boolean deleteByIds(DocumentTypeDTO documentTypeDTO) {
if(!StringUtils.isNotEmpty(documentTypeDTO.getDocumentTypeIds())){
throw new ServiceException("单据类型ids不能为空");
}
Set<String> idSet = Stream.of(documentTypeDTO.getDocumentTypeIds().split(",")).collect(Collectors.toSet());
Long[] documentTypeIds = idSet.stream().map(Long::valueOf).toArray(Long[]::new);
return documentTypeDomainService.delete(documentTypeIds);
}
public boolean changeStatus(DocumentTypeDO documentTypeDO) {
if(documentTypeDO.getDocumentTypeId()==null){
throw new ServiceException("单据类型id不能为空");
}
if(documentTypeDO.getEnablingStatus() != 1 && documentTypeDO.getEnablingStatus() != 2){
throw new ServiceException("单据类型状态错误");
}
DocumentTypeDO documentTypeSave = new DocumentTypeDO();
documentTypeSave.setDocumentTypeId(documentTypeDO.getDocumentTypeId());
documentTypeSave.setEnablingStatus(documentTypeDO.getEnablingStatus());
return documentTypeDomainService.update(documentTypeSave);
}
}
@@ -0,0 +1,100 @@
package com.mhd.bms.application.server.mappingMethod;
import com.mhd.bms.domain.mappingMethod.repository.po.MappingMethodPO;
import com.mhd.bms.domain.mappingMethod.repository.todo.MappingMethodDO;
import com.mhd.bms.domain.mappingMethod.service.MappingMethodDomainService;
import com.mhd.bms.interfaces.dto.mappingMethod.MappingMethodDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 方法映射ApplicationService
*
* @author gen
* @date 2024-07-12
*/
@Service
@Slf4j
public class MappingMethodApplicationService {
@Autowired
private MappingMethodDomainService mappingMethodDomainService;
/**
* 分页查询方法映射列表
*/
public List<MappingMethodPO> queryList(MappingMethodDO mappingMethodDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
mappingMethodDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return mappingMethodDomainService.queryList(mappingMethodDO);
}
/**
* 新增方法映射
*/
public Boolean insert(MappingMethodDO mappingMethodDO) {
return mappingMethodDomainService.insert(mappingMethodDO);
}
/**
* 修改方法映射
*/
public Boolean update(MappingMethodDO mappingMethodDO) {
return mappingMethodDomainService.update(mappingMethodDO);
}
/**
* 批量删除方法映射
*/
public boolean delete(Long[] mappingMethodIds) {
return mappingMethodDomainService.delete(mappingMethodIds);
}
/**
* 获取方法映射详细信息
*/
public MappingMethodPO getInfo(Long mappingMethodId)
{
return mappingMethodDomainService.getInfo(mappingMethodId);
}
/**
* 根据ID删除
*/
@Transactional
public Boolean deleteByIds(MappingMethodDTO mappingMethodDTO) {
if(!StringUtils.isNotEmpty(mappingMethodDTO.getMappingMethodIds())){
throw new ServiceException("方法ID不能为空");
}
Set<String> mappingMethodIdSet = Stream.of(mappingMethodDTO.getMappingMethodIds().split(",")).collect(Collectors.toSet());
Long[] mappingMethodIds = mappingMethodIdSet.stream().map(Long::valueOf).toArray(Long[]::new);
return mappingMethodDomainService.delete(mappingMethodIds);
}
public MappingMethodPO getInfoById(MappingMethodDTO mappingMethodDTO) {
if(null == mappingMethodDTO.getMappingMethodId()){
throw new ServiceException("方法ID不能为空");
}
return mappingMethodDomainService.getInfo(mappingMethodDTO.getMappingMethodId());
}
}
@@ -0,0 +1,110 @@
package com.mhd.bms.application.server.paymentManage;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.paymentManage.entity.PaymentManage;
import com.mhd.bms.domain.paymentManage.repository.po.PaymentManagePO;
import com.mhd.bms.domain.paymentManage.repository.todo.PaymentManageDO;
import com.mhd.bms.domain.paymentManage.service.PaymentManageDomainService;
import com.mhd.bms.interfaces.dto.paymentManage.PaymentManageDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 支付管理ApplicationService
*
* @author gen
* @date 2024-07-09
*/
@Service
@Slf4j
public class PaymentManageApplicationService {
@Autowired
private PaymentManageDomainService paymentManageDomainService;
/**
* 分页查询支付管理列表
*/
public List<PaymentManagePO> queryList(PaymentManageDO paymentManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
paymentManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return paymentManageDomainService.queryList(paymentManageDO);
}
/**
* 新增支付管理
*/
public Boolean insert(PaymentManageDO paymentManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验支付编码是否重复
PaymentManage paymentManage = paymentManageDomainService.selectByPaymentCode(paymentManageDO.getPaymentMethodCode());
if(null != paymentManage){
throw new ServiceException("支付编码不能重复");
}
paymentManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
paymentManageDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
paymentManageDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return paymentManageDomainService.insert(paymentManageDO);
}
/**
* 修改支付管理
*/
public Boolean update(PaymentManageDO paymentManageDO) {
//校验支付编码是否重复
PaymentManage paymentManage = paymentManageDomainService.selectByPaymentCode(paymentManageDO.getPaymentMethodCode());
if(null != paymentManage && !Objects.equals(paymentManage.getPaymentManageId(), paymentManageDO.getPaymentManageId())){
throw new ServiceException("支付编码不能重复");
}
return paymentManageDomainService.update(paymentManageDO);
}
/**
* 批量删除支付管理
*/
public boolean delete(Long[] paymentManageIds) {
return paymentManageDomainService.delete(paymentManageIds);
}
/**
* 获取支付管理详细信息
*/
public PaymentManagePO getInfo(Long paymentManageId)
{
return paymentManageDomainService.getInfo(paymentManageId);
}
/**
* 根据id删除支付管理
*/
public Boolean deleteByIds(PaymentManageDTO paymentManageDTO) {
if(!StringUtils.isNotEmpty(paymentManageDTO.getPaymentManageIds())){
throw new ServiceException("支付管理id不能为空");
}
Set<String> paymentManageIdSet = Stream.of(paymentManageDTO.getPaymentManageIds().split(",")).collect(Collectors.toSet());
Long[] paymentManageIds = paymentManageIdSet.stream().map(Long::valueOf).toArray(Long[]::new);
return paymentManageDomainService.delete(paymentManageIds);
}
}
@@ -0,0 +1,118 @@
package com.mhd.bms.application.server.paymentOrder;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.paymentOrder.repository.po.PaymentOrderPO;
import com.mhd.bms.domain.paymentOrder.repository.todo.PaymentOrderDO;
import com.mhd.bms.domain.paymentOrder.service.PaymentOrderDomainService;
import com.mhd.bms.infrastructure.utils.CheckPasswordUtil;
import com.mhd.bms.interfaces.dto.paymentOrder.PaymentOrderDTO;
import com.mhd.common.core.constant.PaymentChannelConstants;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 付款单ApplicationService
*
* @author gen
* @date 2024-07-16
*/
@Service
@Slf4j
public class PaymentOrderApplicationService {
@Autowired
private PaymentOrderDomainService paymentOrderDomainService;
@Autowired
private BillManageDomainService billManageDomainService;
/**
* 分页查询付款单列表
*/
public List<PaymentOrderPO> queryList(PaymentOrderDO paymentOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
paymentOrderDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return paymentOrderDomainService.queryList(paymentOrderDO);
}
/**
* 新增付款单
*/
public Boolean insert(PaymentOrderDO paymentOrderDO) {
return paymentOrderDomainService.insert(paymentOrderDO);
}
/**
* 修改付款单
*/
public Boolean update(PaymentOrderDO paymentOrderDO) {
return paymentOrderDomainService.update(paymentOrderDO);
}
/**
* 批量删除付款单
*/
public boolean delete(Long[] paymentOrderIds) {
return paymentOrderDomainService.delete(paymentOrderIds);
}
/**
* 获取付款单详细信息
*/
public PaymentOrderPO getInfo(Long paymentOrderId)
{
return paymentOrderDomainService.getInfo(paymentOrderId);
}
/**
* 批量付款
*/
// @Transactional
public boolean batchPayment(PaymentOrderDO paymentOrderDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验支付密码
CheckPasswordUtil.checkPayPassword(paymentOrderDO.getPayPassword(),null);
//校验账单状态是否合规
paymentOrderDomainService.checkSettlementStatus(paymentOrderDO);
//判断支付通道类型 TODO 此处先只做线下支付
if(ObjectUtil.equal(paymentOrderDO.getPaymentChannelCode(), PaymentChannelConstants.offline_pay)){
//付款
Boolean flag = paymentOrderDomainService.batchPayment(paymentOrderDO);
//更改账单状态
Boolean flagTwo = billManageDomainService.updateBillPaymentInfo(paymentOrderDO);
return flag && flagTwo;
}
return false;
}
/**
* 根据id获取付款单信息
*/
public PaymentOrderPO getInfoById(PaymentOrderDTO paymentOrderDTO) {
if(paymentOrderDTO.getPaymentOrderId() == null){
throw new ServiceException("付款单id不能为空");
}
return paymentOrderDomainService.getInfoById(paymentOrderDTO.getPaymentOrderId());
}
}
@@ -0,0 +1,136 @@
package com.mhd.bms.application.server.paymentWallet;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.paymentManage.entity.PaymentManage;
import com.mhd.bms.domain.paymentManage.repository.po.PaymentManagePO;
import com.mhd.bms.domain.paymentManage.service.PaymentManageDomainService;
import com.mhd.bms.domain.paymentWallet.repository.po.PaymentWalletPO;
import com.mhd.bms.domain.paymentWallet.repository.todo.PaymentWalletDO;
import com.mhd.bms.domain.paymentWallet.service.PaymentWalletDomainService;
import com.mhd.bms.interfaces.dto.paymentWallet.PaymentWalletDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 支付钱包管理ApplicationService
*
* @author gen
* @date 2024-07-09
*/
@Service
@Slf4j
public class PaymentWalletApplicationService {
@Autowired
private PaymentWalletDomainService paymentWalletDomainService;
@Autowired
private PaymentManageDomainService paymentManageDomainService;
/**
* 分页查询支付钱包管理列表
*/
public List<PaymentWalletPO> queryList(PaymentWalletDO paymentWalletDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
paymentWalletDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return paymentWalletDomainService.queryList(paymentWalletDO);
}
/**
* 新增支付钱包管理
*/
public Boolean insert(PaymentWalletDO paymentWalletDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//根据支付方式编码查询支付方式
if(!StringUtils.isNotEmpty(paymentWalletDO.getPaymentMethodCode())){
throw new ServiceException("支付方式编码不能为空");
}
PaymentManage paymentManage = paymentManageDomainService.selectByPaymentCode(paymentWalletDO.getPaymentMethodCode());
if(null == paymentManage){
throw new ServiceException("支付方式信息未找到");
}
paymentWalletDO.setPaymentMethod(paymentManage.getPaymentMethod());
paymentWalletDO.setPaymentManageId(paymentManage.getPaymentManageId());
paymentWalletDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
paymentWalletDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
paymentWalletDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
return paymentWalletDomainService.insert(paymentWalletDO);
}
/**
* 修改支付钱包管理
*/
public Boolean update(PaymentWalletDO paymentWalletDO) {
//根据支付方式编码查询支付方式
if(!StringUtils.isNotEmpty(paymentWalletDO.getPaymentMethodCode())){
throw new ServiceException("支付方式编码不能为空");
}
PaymentManage paymentManage = paymentManageDomainService.selectByPaymentCode(paymentWalletDO.getPaymentMethodCode());
if(null == paymentManage){
throw new ServiceException("支付方式信息未找到");
}
paymentWalletDO.setPaymentMethod(paymentWalletDO.getPaymentMethod());
paymentWalletDO.setPaymentWalletId(paymentWalletDO.getPaymentWalletId());
return paymentWalletDomainService.update(paymentWalletDO);
}
/**
* 批量删除支付钱包管理
*/
public boolean delete(Long[] paymentWalletIds) {
return paymentWalletDomainService.delete(paymentWalletIds);
}
/**
* 获取支付钱包管理详细信息
*/
public PaymentWalletPO getInfo(Long paymentWalletId)
{
return paymentWalletDomainService.getInfo(paymentWalletId);
}
/**
* 批量删除支付钱包管理
*/
public Boolean deleteByIds(PaymentWalletDTO paymentWalletDTO) {
if(!StringUtils.isNotEmpty(paymentWalletDTO.getPaymentWalletIds())){
throw new ServiceException("支付钱包管理id不能为空");
}
Set<String> paymentWalletIdSet = Stream.of(paymentWalletDTO.getPaymentWalletIds().split(",")).collect(Collectors.toSet());
Long[] paymentWalletIds = paymentWalletIdSet.stream().map(Long::valueOf).toArray(Long[]::new);
return paymentWalletDomainService.delete(paymentWalletIds);
}
/**
* 查看详情
* @param paymentWalletDTO
* @return
*/
public PaymentWalletPO getInfoById(PaymentWalletDTO paymentWalletDTO) {
if(null == paymentWalletDTO.getPaymentWalletId()){
throw new ServiceException("支付钱包id不能为空");
}
return paymentWalletDomainService.getInfo(paymentWalletDTO.getPaymentWalletId());
}
}
@@ -0,0 +1,131 @@
package com.mhd.bms.application.server.receiptManage;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.receiptManage.entity.ReceiptManage;
import com.mhd.bms.domain.receiptManage.repository.po.ReceiptManagePO;
import com.mhd.bms.domain.receiptManage.repository.todo.ReceiptManageDO;
import com.mhd.bms.domain.receiptManage.service.ReceiptManageDomainService;
import com.mhd.bms.infrastructure.utils.CheckPasswordUtil;
import com.mhd.bms.interfaces.dto.receiptManage.ReceiptManageDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 收款单管理ApplicationService
*
* @author gen
* @date 2024-07-08
*/
@Service
@Slf4j
public class ReceiptManageApplicationService {
@Autowired
private ReceiptManageDomainService receiptManageDomainService;
@Autowired
private BillManageDomainService billManageDomainService;
/**
* 分页查询收款单管理列表
*/
public List<ReceiptManagePO> queryList(ReceiptManageDO receiptManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
receiptManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return receiptManageDomainService.queryList(receiptManageDO);
}
/**
* 新增收款单管理
*/
public Boolean insert(ReceiptManageDO receiptManageDO) {
return receiptManageDomainService.insert(receiptManageDO);
}
/**
* 修改收款单管理
*/
public Boolean update(ReceiptManageDO receiptManageDO) {
return receiptManageDomainService.update(receiptManageDO);
}
/**
* 批量删除收款单管理
*/
public boolean delete(Long[] receiptManageIds) {
return receiptManageDomainService.delete(receiptManageIds);
}
/**
* 获取收款单管理详细信息
*/
public ReceiptManagePO getInfo(Long receiptManageId)
{
return receiptManageDomainService.getInfo(receiptManageId);
}
/**
* 批量收款
*/
@Transactional
public Boolean batchCollection(ReceiptManageDO receiptManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验支付密码
CheckPasswordUtil.checkPayPassword(receiptManageDO.getPayPassword(),null);
//校验结算状态是否正确
// receiptManageDomainService.checkSettlementStatus(receiptManageDO);
//保存结算单
Boolean flag = receiptManageDomainService.batchCollection(receiptManageDO);
//更新账单信息
Boolean flagTwo = billManageDomainService.updateBillSettlementInfo(receiptManageDO);
return flag && flagTwo;
}
/**
* 退款
*/
@Transactional
public Boolean refund(ReceiptManageDO receiptManageDO) {
//校验支付密码
CheckPasswordUtil.checkPayPassword(receiptManageDO.getPayPassword(),null);
return receiptManageDomainService.refund(receiptManageDO);
}
/**
* 查询收款单详情
*/
public ReceiptManagePO getDetailsInfo(ReceiptManageDTO receiptManageDTO) {
if(null == receiptManageDTO.getReceiptManageId()){
throw new ServiceException("收款单id不能为空");
}
return receiptManageDomainService.getDetailsInfo(receiptManageDTO.getReceiptManageId());
}
}
@@ -0,0 +1,134 @@
package com.mhd.bms.application.server.reportForm;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.reportForm.entity.FormQueryManage;
import com.mhd.bms.domain.reportForm.repository.po.FormQueryManagePO;
import com.mhd.bms.domain.reportForm.repository.po.FormQueryParamsPO;
import com.mhd.bms.domain.reportForm.repository.todo.FormQueryManageDO;
import com.mhd.bms.domain.reportForm.service.FormQueryManageDomainService;
import com.mhd.bms.interfaces.dto.reportForm.FormQueryManageDTO;
import com.mhd.bms.interfaces.dto.reportForm.FormQueryParamsDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 查询条件管理ApplicationService
*
* @author gen
* @date 2024-07-26
*/
@Service
@Slf4j
public class FormQueryManageApplicationService {
@Autowired
private FormQueryManageDomainService formQueryManageDomainService;
@Autowired
private FormQueryParamsApplicationService formQueryParamsApplicationService;
/**
* 分页查询查询条件管理列表
*/
public List<FormQueryManagePO> queryList(FormQueryManageDO formQueryManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(formQueryManageDO.getFormType() == null){
throw new ServiceException("所属报表类型不能为空");
}
if(formQueryManageDO.getReportFormId() == null){
throw new ServiceException("报表ID不能为空");
}
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
formQueryManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
formQueryManageDO.setCreateBy(loginUser.getUserPo().getUserId());
List<FormQueryManagePO> formQueryManagePOList = formQueryManageDomainService.queryList(formQueryManageDO);
if(null != formQueryManagePOList && formQueryManagePOList.size() > 0){
for (FormQueryManagePO formQueryManagePO : formQueryManagePOList) {
List<FormQueryParamsPO> formQueryParamsPOList = formQueryParamsApplicationService.getInfoByFormQueryManageId(formQueryManagePO.getFormQueryManageId());
formQueryManagePO.setFormQueryParamsPOList(formQueryParamsPOList);
}
}
return formQueryManagePOList;
}
/**
* 新增查询条件管理
*/
@Transactional
public Boolean insert(FormQueryManageDO formQueryManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
formQueryManageDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
formQueryManageDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
formQueryManageDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
//判断如果该查询条件设为了默认,则将其他的设为非默认
if (formQueryManageDO.getDefaultFlag() == 1){
formQueryManageDomainService.updateDefaultFlag(formQueryManageDO.getFormType());
}
boolean flagTwo = formQueryManageDomainService.insert(formQueryManageDO);
for (FormQueryParamsDTO formQueryParamsDTO : formQueryManageDO.getFormQueryParamsDTOList()) {
formQueryParamsDTO.setFormQueryManageId(formQueryManageDO.getFormQueryManageId());
}
boolean flag = formQueryParamsApplicationService.insert(formQueryManageDO.getFormQueryParamsDTOList());
return flag && flagTwo;
}
/**
* 修改查询条件管理
*/
@Transactional(rollbackFor = Exception.class)
public Boolean update(FormQueryManageDO formQueryManageDO) {
//先将之前的旧数据删除
Boolean flagThree = formQueryParamsApplicationService.deleteByFormQueryManageId(formQueryManageDO.getFormQueryManageId());
Boolean flag = formQueryParamsApplicationService.update(formQueryManageDO.getFormQueryParamsDTOList());
Boolean flagTwo = formQueryManageDomainService.update(formQueryManageDO);
return flag && flagTwo && flagThree;
}
/**
* 批量删除查询条件管理
*/
public boolean delete(Long[] formQueryManageIds) {
return formQueryManageDomainService.delete(formQueryManageIds);
}
/**
* 获取查询条件管理详细信息
*/
public FormQueryManagePO getInfo(Long formQueryManageId)
{
FormQueryManagePO formQueryManagePO = formQueryManageDomainService.getInfo(formQueryManageId);
List<FormQueryParamsPO> formQueryParamsPOList = formQueryParamsApplicationService.getInfoByFormQueryManageId(formQueryManageId);
if(null != formQueryManagePO){
formQueryManagePO.setFormQueryParamsPOList(formQueryParamsPOList);
}
return formQueryManagePO;
}
public Boolean deleteByIds(FormQueryManageDTO formQueryManageDTO) {
if(formQueryManageDTO.getFormQueryManageId() == null){
throw new ServiceException("查询条件管理id不能为空");
}
Boolean flag = formQueryManageDomainService.deleteById(formQueryManageDTO.getFormQueryManageId());
Boolean flagTwo = formQueryParamsApplicationService.deleteByFormQueryManageId(formQueryManageDTO.getFormQueryManageId());
return flag && flagTwo;
}
}
@@ -0,0 +1,90 @@
package com.mhd.bms.application.server.reportForm;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.reportForm.entity.FormQueryParams;
import com.mhd.bms.domain.reportForm.repository.po.FormQueryParamsPO;
import com.mhd.bms.domain.reportForm.repository.todo.FormQueryParamsDO;
import com.mhd.bms.domain.reportForm.service.FormQueryParamsDomainService;
import com.mhd.bms.interfaces.dto.reportForm.FormQueryParamsDTO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 报查询条件管理ApplicationService
*
* @author gen
* @date 2024-07-25
*/
@Service
@Slf4j
public class FormQueryParamsApplicationService {
@Autowired
private FormQueryParamsDomainService formQueryParamsDomainService;
/**
* 分页查询报查询条件管理列表
*/
public List<FormQueryParamsPO> queryList(FormQueryParamsDO formQueryParamsDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
formQueryParamsDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
formQueryParamsDO.setCreateBy(loginUser.getUserPo().getUserId());
return formQueryParamsDomainService.queryList(formQueryParamsDO);
}
/**
* 新增报查询条件管理
*/
public Boolean insert(List<FormQueryParamsDTO> formQueryParamsDTOList) {
return formQueryParamsDomainService.saveBatch(formQueryParamsDTOList);
}
/**
* 修改报查询条件管理
*/
public Boolean update(List<FormQueryParamsDTO> formQueryParamsDTOList) {
return formQueryParamsDomainService.update(formQueryParamsDTOList);
}
/**
* 批量删除报查询条件管理
*/
public boolean delete(Long[] formQueryParamsIds) {
return formQueryParamsDomainService.delete(formQueryParamsIds);
}
/**
* 获取报查询条件管理详细信息
*/
public FormQueryParamsPO getInfo(Long formQueryParamsId)
{
return formQueryParamsDomainService.getInfo(formQueryParamsId);
}
/**
* 根据表单查询管理ID,删除表单参数列表
*/
public Boolean deleteByFormQueryManageId(Long formQueryManageId) {
return formQueryParamsDomainService.deleteByFormQueryManageId(formQueryManageId);
}
public List<FormQueryParamsPO> getInfoByFormQueryManageId(Long formQueryManageId) {
return formQueryParamsDomainService.getInfoByFormQueryManageId(formQueryManageId);
}
}
@@ -0,0 +1,768 @@
package com.mhd.bms.application.server.reportForm;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReflectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.paymentManage.entity.PaymentManage;
import com.mhd.bms.domain.paymentOrder.entity.PaymentOrder;
import com.mhd.bms.domain.paymentOrder.entity.PaymentOrderDetails;
import com.mhd.bms.domain.paymentOrder.service.PaymentOrderDetailsDomainService;
import com.mhd.bms.domain.paymentOrder.service.PaymentOrderDomainService;
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
import com.mhd.bms.domain.receiptManage.entity.ReceiptManage;
import com.mhd.bms.domain.receiptManage.service.ReceiptDetailDomainService;
import com.mhd.bms.domain.receiptManage.service.ReceiptManageDomainService;
import com.mhd.bms.domain.reportForm.entity.FormQueryParams;
import com.mhd.bms.domain.reportForm.repository.po.ReportFormPO;
import com.mhd.bms.domain.reportForm.repository.todo.ReportFormDO;
import com.mhd.bms.domain.reportForm.service.ReportFormDomainService;
import com.mhd.bms.interfaces.dto.reportForm.ReportFormDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.PageUtils;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.temporal.WeekFields;
import java.util.*;
import java.util.stream.Collectors;
/**
* 分析报管理ApplicationService
*
* @author gen
* @date 2024-07-25
*/
@Service
@Slf4j
public class ReportFormApplicationService {
@Autowired
private ReportFormDomainService reportFormDomainService;
@Autowired
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private BillManageDomainService billManageDomainService;
@Autowired
private PaymentOrderDomainService paymentOrderDomainService;
@Autowired
private PaymentOrderDetailsDomainService paymentOrderDetailsDomainService;
@Autowired
private ReceiptManageDomainService receiptManageDomainService;
@Autowired
private ReceiptDetailDomainService receiptDetailDomainService;
//特殊字段集合
private static ArrayList<String> specialFieldsList = new ArrayList<>();
static {
specialFieldsList.add("form_years");
specialFieldsList.add("form_month");
specialFieldsList.add("form_day");
specialFieldsList.add("form_week");
}
/**
* 分页查询分析报管理列表
*/
public List<ReportFormPO> queryList(ReportFormDO reportFormDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(reportFormDO.getFormType()==null){
throw new ServiceException("报表类型不能为空");
}
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
reportFormDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
reportFormDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
return reportFormDomainService.queryList(reportFormDO);
}
/**
* 新增分析报管理
*/
public Boolean insert(ReportFormDO reportFormDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
reportFormDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
reportFormDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
reportFormDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return reportFormDomainService.insert(reportFormDO);
}
/**
* 修改分析报管理
*/
public Boolean update(ReportFormDO reportFormDO) {
return reportFormDomainService.update(reportFormDO);
}
/**
* 批量删除分析报管理
*/
public boolean delete(Long[] reportFormIds) {
return reportFormDomainService.delete(reportFormIds);
}
/**
* 获取分析报管理详细信息
*/
public ReportFormPO getInfo(Long reportFormId)
{
return reportFormDomainService.getInfo(reportFormId);
}
public Boolean deleteByIds(ReportFormDTO reportFormDTO) {
if(reportFormDTO.getReportFormId()==null){
throw new ServiceException("报表信息ID不能为空");
}
return reportFormDomainService.deleteByIds(reportFormDTO.getReportFormId());
}
/**
* 综合分析报表查询
*/
public List<Map<String,Object>> comprehensiveList(ReportFormDO reportFormDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(StringUtils.isEmpty(reportFormDO.getQueryParamJson())){
throw new ServiceException("查询参数不能为空");
}
//解析传来的参数
String queryParamJson = reportFormDO.getQueryParamJson();
//转成FormQueryParams集合
List<FormQueryParams> formQueryParamsListAll = JSON.parseArray(queryParamJson, FormQueryParams.class);
//根据传来的查询参数,拼接查询SQL
if(formQueryParamsListAll==null || formQueryParamsListAll.size()==0){
throw new ServiceException("查询参数不能为空");
}
//将formQueryParamsList过滤,将inputBoxText不为空的筛选出
List<FormQueryParams> formQueryParamsList = formQueryParamsListAll.stream().filter(formQueryParams -> StringUtils.isNotEmpty(formQueryParams.getInputBoxText())).collect(Collectors.toList());
QueryWrapper<BillingStatement> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
FormQueryParams beforeFormQueryParams = null;
if(i > 0){
//小于最后一个,则修改可判断状态
beforeFormQueryParams = formQueryParamsList.get(i-1);
}
//根据字段名称,判断是否需要特殊处理
if(specialFieldsList.contains(formQueryParams.getField())){
getSpecialFunction(formQueryParams);
}
//根据选择的过滤方法选择合适的lambda函数
getFunction(formQueryParams, queryWrapper, beforeFormQueryParams);
}
List<BillingStatement> billingStatementList = billingStatementDomainService.comprehensiveList(queryWrapper);
List<Map<String,Object>> resultList = new ArrayList<>();
if(formQueryParamsListAll.size()>0){
//按照formQueryParamsList查询条件分组,获取每个分组的统计数据
List<String> groupList = new ArrayList<>();
for (int i = 0; i < formQueryParamsListAll.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsListAll.get(i);
//拼接字段编码和输入框值
groupList.add(convertToCamelCase(formQueryParams.getField()));
}
Map<Map<String,Object>, List<BillingStatement>> billingStatementPOSMap = billingStatementList.stream()
.collect(Collectors.groupingBy(p-> {
Map<String,Object> groupMap = new HashMap<>();
for (int i = 0; i < groupList.size(); i++) {
String field = groupList.get(i);
Object value = ReflectUtil.getFieldValue(p, field);
groupMap.put(field,value);
}
return groupMap;
}));
billingStatementPOSMap.forEach((k,v)->{
if(v !=null && v.size()>0){
//将map中的key和value单独做处理
handleMapKey(k,v);
Map<String, Object> comprehensiveFormPO = new HashMap<>(k);
//统计所需参数
long receivableFlow = v.stream().filter(item -> item.getAccountExpenseType()==1).count();
BigDecimal receivableAmount = v.stream().filter(item -> item.getAccountExpenseType()==1).map(BillingStatement::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal payableAmount = v.stream().filter(item -> item.getAccountExpenseType()==2).map(BillingStatement::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
comprehensiveFormPO.put("receivableAmount",String.valueOf(receivableAmount));
comprehensiveFormPO.put("receivableFlow",String.valueOf(receivableFlow));
comprehensiveFormPO.put("payableAmount",String.valueOf(payableAmount));
comprehensiveFormPO.put("payableFlow",String.valueOf(payableAmount));
comprehensiveFormPO.put("profit",String.valueOf(receivableAmount.subtract(payableAmount)));
resultList.add(comprehensiveFormPO);
}
});
}
return resultList;
}
/**
* 处理map中的数据 (综合分析报表)
* @param k key
* @param v 参数集合
*/
private void handleMapKey(Map<String, Object> k, List<BillingStatement> v) {
Map<String, Object> newMap = new HashMap<>(k);
//遍历集合,将每个字段单独处理
for (Map.Entry<String, Object> entry : newMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
switch (key){
case "settlementCustomersCode":
String settlementCustomersName = v.stream().filter(item -> item.getSettlementCustomersCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getSettlementEntity).orElse(null);
k.put("settlement_customers_code",settlementCustomersName == null ? value : settlementCustomersName);
break;
case "accountExpenseType":
k.put("account_expense_type",ObjectUtil.equals(value,1) ? "应收" : "应付");
break;
case "serviceItemsCode":
String serviceItemsName = v.stream().filter(item -> item.getServiceItemsCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getServiceItemsName).orElse(null);
k.put("service_items_code",serviceItemsName == null ? value : serviceItemsName);
break;
case "secondSubjectCode":
String secondSubjectName = v.stream().filter(item -> item.getSecondSubjectCode().equals(String.valueOf(value)) || item.getFirstSubjectCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getSecondSubjectName).orElse(null);
k.put("second_subject_code",secondSubjectName == null ? value : secondSubjectName);
break;
case "billingState":
if(ObjectUtil.equals(value,1)){
k.put("billing_state","待审核");
}else if(ObjectUtil.equals(value,2)){
k.put("billing_state","已审核");
}else if(ObjectUtil.equals(value,3)){
k.put("billing_state","已出账");
}else if(ObjectUtil.equals(value,4)){
k.put("billing_state","已驳回");
}else if(ObjectUtil.equals(value,5)){
k.put("billing_state","已作废");
}
break;
case "redFlushState":
k.put("red_flush_state",ObjectUtil.equals(value,1) ? "未红冲" : "已红冲");
break;
case "settlementWay":
k.put("settlement_way",ObjectUtil.equals(value,1) ? "现金" : "油卡");
break;
case "belongModuleCode":
String belongModuleCode = v.stream().filter(item -> item.getBelongModuleCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getBelongModule).orElse(null);
k.put("belong_module_code",belongModuleCode == null ? value : belongModuleCode);
break;
case "documentTypeCode":
String documentTypeCode = v.stream().filter(item -> item.getDocumentTypeCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getDocumentType).orElse(null);
k.put("document_type_code",documentTypeCode == null ? value : documentTypeCode);
break;
case "projectCode":
String projectCode = v.stream().filter(item -> item.getProjectCode().equals(String.valueOf(value))).findAny().map(BillingStatement::getProjectName).orElse(null);
k.put("project_code",projectCode == null ? value : projectCode);
break;
case "contractType":
k.put("contract_type",ObjectUtil.equals(value,1) ? "仓储" : "运输");
break;
case "organizationId":
String organizationId = v.stream().filter(item -> item.getOrganizationId()==Long.parseLong(value.toString())).findAny().map(BillingStatement::getOrganizationName).orElse(null);
k.put("organization_id",organizationId == null ? value : organizationId);
break;
default:
break;
}
}
}
/**
* 处理map中的数据 (账单分析报表)
* @param k key
* @param v 参数集合
*/
private void handleMapKeyTwo(Map<String, Object> k, List<BillManage> v) {
Map<String, Object> newMap = new HashMap<>(k);
for (Map.Entry<String, Object> entry : newMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
switch (key){
case "settlementCustomersCode":
String settlementCustomersName = v.stream().filter(item -> item.getSettlementCustomersCode().equals(String.valueOf(value))).findAny().map(BillManage::getSettlementEntity).orElse(null);
k.put("settlement_customers_code",settlementCustomersName == null ? value : settlementCustomersName);
break;
case "belongModuleCode":
String belongModuleCode = v.stream().filter(item -> item.getBelongModuleCode().equals(String.valueOf(value))).findAny().map(BillManage::getBelongModule).orElse(null);
k.put("belong_module_code",belongModuleCode == null ? value : belongModuleCode);
break;
case "organizationId":
String organizationId = v.stream().filter(item -> item.getOrganizationId()==Long.parseLong(value.toString())).findAny().map(BillManage::getOrganizationName).orElse(null);
k.put("organization_id",organizationId == null ? value : organizationId);
break;
case "billType":
k.put("bill_type",ObjectUtil.equals(value,1) ? "应收" : "应付");
break;
case "billState":
if(ObjectUtil.equals(value,1)){
k.put("bill_state","未确认");
}else if(ObjectUtil.equals(value,2)){
k.put("bill_state","对账中");
}else if(ObjectUtil.equals(value,3)){
k.put("bill_state","未收/付款");
}else if(ObjectUtil.equals(value,4)){
k.put("bill_state","部分收/付款");
}else if(ObjectUtil.equals(value,5)){
k.put("bill_state","已收/付款");
}else if(ObjectUtil.equals(value,6)){
k.put("bill_state","已作废");
}else if(ObjectUtil.equals(value,7)){
k.put("bill_state","已退款");
}
break;
case "reconciliationStatus":
if(ObjectUtil.equals(value,1)){
k.put("reconciliation_status","暂未确认");
}else if(ObjectUtil.equals(value,2)){
k.put("reconciliation_status","申请调账");
}else if(ObjectUtil.equals(value,3)){
k.put("reconciliation_status","财务调账");
}else if(ObjectUtil.equals(value,4)){
k.put("reconciliation_status","核对无误");
}
break;
default:
break;
}
}
}
/**
* 处理map中的数据 (结算分析报表)
* @param k key
* @param v 参数集合
*/
private void handleMapKeyThree(Map<String, Object> k, List<ReceiptManage> v) {
Map<String, Object> newMap = new HashMap<>(k);
for (Map.Entry<String, Object> entry : newMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
switch (key){
case "settlementCustomersCode":
String settlementCustomersName = v.stream().filter(item -> item.getSettlementCustomersCode().equals(String.valueOf(value))).findAny().map(ReceiptManage::getSettlementEntity).orElse(null);
k.put("settlement_customers_code",settlementCustomersName == null ? value : settlementCustomersName);
break;
case "organizationId":
String organizationId = v.stream().filter(item -> item.getOrganizationId()==Long.parseLong(value.toString())).findAny().map(ReceiptManage::getOrganizationName).orElse(null);
k.put("organization_id",organizationId == null ? value : organizationId);
break;
case "settlementWay":
k.put("settlement_way",ObjectUtil.equals(value,1) ? "现金" : "油卡");
break;
default:
break;
}
}
}
/**
* 处理map中的数据 (结算分析报表)
* @param k key
* @param v 参数集合
*/
private void handleMapKeyFour(Map<String, Object> k, List<PaymentOrder> v) {
Map<String, Object> newMap = new HashMap<>(k);
for (Map.Entry<String, Object> entry : newMap.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
switch (key){
case "settlementCustomersCode":
String settlementCustomersName = v.stream().filter(item -> item.getSettlementCustomersCode().equals(String.valueOf(value))).findAny().map(PaymentOrder::getSettlementEntity).orElse(null);
k.put("settlement_customers_code",settlementCustomersName == null ? value : settlementCustomersName);
break;
case "organizationId":
String organizationId = v.stream().filter(item -> item.getOrganizationId()==Long.parseLong(value.toString())).findAny().map(PaymentOrder::getOrganizationName).orElse(null);
k.put("organization_id",organizationId == null ? value : organizationId);
break;
case "settlementWay":
k.put("settlement_way",ObjectUtil.equals(value,1) ? "现金" : "油卡");
break;
default:
break;
}
}
}
/**
* 字段名转驼峰
*/
public static String convertToCamelCase(String underscoreName) {
StringBuilder result = new StringBuilder();
String[] words = underscoreName.split("_");
for (int i = 0; i < words.length; i++) {
String word = words[i];
if (i == 0) {
result.append(word);
} else {
result.append(Character.toUpperCase(word.charAt(0)));
if (word.length() > 1) {
result.append(word.substring(1));
}
}
}
return result.toString();
}
/**
* 特殊字段处理
* @param formQueryParams 查询条件
*/
private void getSpecialFunction(FormQueryParams formQueryParams) {
Date date = DateUtil.parse(formQueryParams.getInputBoxText(), "yyyy-MM-dd");
switch (formQueryParams.getField()){
case "form_years":
formQueryParams.setField("YEAR(create_time)");
//处理inputBoxText中的值,只取年份
formQueryParams.setInputBoxText(DateUtil.format(date, "yyyy"));
break;
case "form_months":
formQueryParams.setField("MONTH(create_time)");
formQueryParams.setInputBoxText(DateUtil.format(date, "MM"));
break;
case "form_days":
formQueryParams.setField("DAY(create_time)");
formQueryParams.setInputBoxText(DateUtil.format(date, "dd"));
break;
case "form_week":
formQueryParams.setField("WEEK(create_time)");
//获取日期date是第几周
WeekFields weekFields = WeekFields.of(Locale.getDefault());
LocalDate localDate = date.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
int weekNumber = localDate.get(weekFields.weekOfWeekBasedYear());
formQueryParams.setInputBoxText(String.valueOf(weekNumber));
break;
default:
break;
}
}
public List<Map<String, Object>> billAnalysisList(ReportFormDO reportFormDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(StringUtils.isEmpty(reportFormDO.getQueryParamJson())){
throw new ServiceException("查询参数不能为空");
}
//解析传来的参数
String queryParamJson = reportFormDO.getQueryParamJson();
//转成FormQueryParams集合
List<FormQueryParams> formQueryParamsListAll = JSON.parseArray(queryParamJson, FormQueryParams.class);
//根据传来的查询参数,拼接查询SQL
if(formQueryParamsListAll==null || formQueryParamsListAll.size()==0){
throw new ServiceException("查询参数不能为空");
}
List<FormQueryParams> formQueryParamsList = formQueryParamsListAll.stream().filter(formQueryParams -> StringUtils.isNotEmpty(formQueryParams.getInputBoxText())).collect(Collectors.toList());
QueryWrapper<BillManage> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
FormQueryParams beforeFormQueryParams = null;
if(i > 0){
//小于最后一个,则修改可判断状态
beforeFormQueryParams = formQueryParamsList.get(i-1);
}
//根据选择的过滤方法选择合适的lambda函数
getFunction(formQueryParams, queryWrapper, beforeFormQueryParams);
}
List<BillManage> billingStatementList = billManageDomainService.billAnalysisList(queryWrapper);
List<Map<String,Object>> resultList = new ArrayList<>();
if(formQueryParamsListAll.size()>0){
List<String> groupList = new ArrayList<>();
for (int i = 0; i < formQueryParamsListAll.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsListAll.get(i);
groupList.add(convertToCamelCase(formQueryParams.getField()));
}
Map<Map<String,Object>, List<BillManage>> billManageMap = billingStatementList.stream()
.collect(Collectors.groupingBy(p-> {
Map<String,Object> groupMap = new HashMap<>();
for (int i = 0; i < groupList.size(); i++) {
String field = groupList.get(i);
Object value = ReflectUtil.getFieldValue(p, field);
groupMap.put(field,value);
}
return groupMap;
}));
billManageMap.forEach((k,v)->{
if(v !=null && v.size()>0){
handleMapKeyTwo(k,v);
Map<String,Object> billAnalysisFormPO = new HashMap<>(k);
//统计所需参数
BigDecimal billTotalAmount = v.stream().map(BillManage::getBillTotalAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billDiscountAmount = v.stream().map(BillManage::getBillDiscountAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal settlementDiscountsAmount = v.stream().map(BillManage::getSettlementDiscountsAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billAmountSettlement = v.stream().map(BillManage::getBillAmountSettlement).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal billAmountUnsettled = v.stream().map(BillManage::getBillAmountUnsettled).reduce(BigDecimal.ZERO, BigDecimal::add);
//账单总额
billAnalysisFormPO.put("billTotalAmount",String.valueOf(billTotalAmount));
//账单优惠
billAnalysisFormPO.put("billDiscountAmount",String.valueOf(billDiscountAmount));
//结算优惠
billAnalysisFormPO.put("settlementDiscountsAmount",String.valueOf(settlementDiscountsAmount));
//已结算
billAnalysisFormPO.put("billAmountSettlement",String.valueOf(billAmountSettlement));
//未结算
billAnalysisFormPO.put("billAmountUnsettled",String.valueOf(billAmountUnsettled));
resultList.add(billAnalysisFormPO);
}
});
}
return resultList;
}
public List<Map<String, Object>> settlementAnalysisList(ReportFormDO reportFormDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(StringUtils.isEmpty(reportFormDO.getQueryParamJson())){
throw new ServiceException("查询参数不能为空");
}
//解析传来的参数
String queryParamJson = reportFormDO.getQueryParamJson();
//转成FormQueryParams集合
List<FormQueryParams> formQueryParamsList = JSON.parseArray(queryParamJson, FormQueryParams.class);
//根据传来的查询参数,拼接查询SQL
if(formQueryParamsList==null || formQueryParamsList.size()==0){
throw new ServiceException("查询参数不能为空");
}
List<Map<String,Object>> resultList = new ArrayList<>();
if(reportFormDO.getAccountExpenseType()==1){
//收款单
QueryWrapper<ReceiptManage> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
FormQueryParams beforeFormQueryParams = null;
if(i > 0){
//小于最后一个,则修改可判断状态
beforeFormQueryParams = formQueryParamsList.get(i-1);
}
//根据选择的过滤方法选择合适的lambda函数
getFunction(formQueryParams, queryWrapper, beforeFormQueryParams);
}
List<ReceiptManage> receiptManageList = receiptManageDomainService.settlementAnalysisList(queryWrapper);
if(receiptManageList != null && receiptManageList.size()>0){
//按照formQueryParamsList查询条件分组,获取每个分组的统计数据
List<String> groupList = new ArrayList<>();
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
groupList.add(convertToCamelCase(formQueryParams.getField()));
}
Map<Map<String,Object>, List<ReceiptManage>> receiptManageMap = receiptManageList.stream()
.collect(Collectors.groupingBy(p-> {
Map<String,Object> groupMap = new HashMap<>();
for (int i = 0; i < groupList.size(); i++) {
String field = groupList.get(i);
Object value = ReflectUtil.getFieldValue(p, field);
groupMap.put(field,value);
}
return groupMap;
}));
receiptManageMap.forEach((k,v)->{
if(v !=null && v.size()>0){
handleMapKeyThree(k,v);
//解析key,转成Map,并将map赋值到comprehensiveFormPO
Map<String,Object> receiptOrderPO = new HashMap<>(k);
Set<Long> orderIdSet = v.stream().map(ReceiptManage::getReceiptManageId).collect(Collectors.toSet());
//查询收款单详情
List<ReceiptDetail> receiptDetailList = receiptDetailDomainService.queryListByIdSet(orderIdSet);
//统计所需参数,收款次数,收款金额,退款次数,退款金额
BigDecimal receiptAmount = receiptDetailList.stream().map(ReceiptDetail::getCollectedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
long receiptCount = receiptDetailList.stream().map(ReceiptDetail::getCollectedAmount).count();
long refundCount = v.stream().filter(item -> item.getPaymentStatus()==2).count();
BigDecimal refundAmount = v.stream().map(ReceiptManage::getRefundAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
receiptOrderPO.put("receiptAmount",String.valueOf(receiptAmount));
receiptOrderPO.put("receiptCount",String.valueOf(receiptCount));
receiptOrderPO.put("refundCount",String.valueOf(refundCount));
receiptOrderPO.put("refundAmount",String.valueOf(refundAmount));
resultList.add(receiptOrderPO);
}
});
}
}
else {
//付款单
QueryWrapper<PaymentOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("top_organization_id", loginUser.getUserPo().getTopOrganizationId());
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
FormQueryParams beforeFormQueryParams = null;
if(i > 0){
//小于最后一个,则修改可判断状态
beforeFormQueryParams = formQueryParamsList.get(i-1);
}
//根据选择的过滤方法选择合适的lambda函数
getFunction(formQueryParams, queryWrapper, beforeFormQueryParams);
}
List<PaymentOrder> paymentOrderList = paymentOrderDomainService.settlementAnalysisList(queryWrapper);
if(paymentOrderList !=null && paymentOrderList.size()>0){
//按照formQueryParamsList查询条件分组,获取每个分组的统计数据
List<String> groupList = new ArrayList<>();
for (int i = 0; i < formQueryParamsList.size(); i++) {
FormQueryParams formQueryParams = formQueryParamsList.get(i);
groupList.add(convertToCamelCase(formQueryParams.getField()));
}
Map<Map<String,Object>, List<PaymentOrder>> billManageMap = paymentOrderList.stream()
.collect(Collectors.groupingBy(p-> {
Map<String,Object> groupMap = new HashMap<>();
for (int i = 0; i < groupList.size(); i++) {
String field = groupList.get(i);
Object value = ReflectUtil.getFieldValue(p, field);
groupMap.put(field,value);
}
return groupMap;
}));
billManageMap.forEach((k,v)->{
if(v !=null && v.size()>0){
handleMapKeyFour(k,v);
//解析key,转成Map,并将map赋值到comprehensiveFormPO
Map<String,Object> paymentOrderPO = new HashMap<>(k);
Set<Long> orderIdSet = v.stream().map(PaymentOrder::getPaymentOrderId).collect(Collectors.toSet());
//查询付款单详情
List<PaymentOrderDetails> paymentOrderDetailsList = paymentOrderDetailsDomainService.queryListByIdSet(orderIdSet);
//统计所需参数,付款次数,付款金额
long paymentTimes = paymentOrderDetailsList.stream().map(PaymentOrderDetails::getPaymentOrderId).distinct().count();
BigDecimal paymentAmount = paymentOrderDetailsList.stream().map(PaymentOrderDetails::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
paymentOrderPO.put("paymentTimes",String.valueOf(paymentTimes));
paymentOrderPO.put("paymentAmount",String.valueOf(paymentAmount));
resultList.add(paymentOrderPO);
}
});
}
}
return resultList;
}
/**
* 根据选择的过滤方法选择合适的lambda函数
* @param formQueryParams 查询条件
* @param queryWrapper 拼接查询条件
* @param beforeFormQueryParams 上一组参数
*/
private void getFunction(FormQueryParams formQueryParams, QueryWrapper<?> queryWrapper,FormQueryParams beforeFormQueryParams) {
if(StringUtils.isNotEmpty(formQueryParams.getInputBoxText())){
switch (formQueryParams.getFilterMethod()) {
case 1:
//等于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2){
queryWrapper.or().eq(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.eq(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 2:
//不等于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2){
queryWrapper.or().ne(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.ne(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 3:
//大于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2){
queryWrapper.or().gt(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.gt(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 4:
//大于等于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().ge(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.ge(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 5:
//小于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().lt(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.lt(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 6:
//小于等于
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().le(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.le(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 7:
//包含
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().like(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.like(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 8:
//不包含
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().notLike(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.notLike(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 9:
//在列表
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().in(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.in(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
case 10:
//不在列表
if(beforeFormQueryParams != null && beforeFormQueryParams.getQueryRelation()==2) {
queryWrapper.or().notIn(formQueryParams.getField(), formQueryParams.getInputBoxText());
}else {
queryWrapper.notIn(formQueryParams.getField(), formQueryParams.getInputBoxText());
}
break;
default:
throw new ServiceException("过滤方法错误");
}
}
}
}
@@ -0,0 +1,313 @@
package com.mhd.bms.application.server.settlementCustomers;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
import com.mhd.bms.domain.settlementCustomers.repository.todo.SettlementCustomersDO;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.interfaces.dto.settlementCustomers.SettlementCustomersDTO;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.domain.po.UserDriverPo;
import com.mhd.common.core.domain.po.UserPo;
import com.mhd.common.core.domain.po.UserShipperPo;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.UserServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 结算对象ApplicationService
*
* @author gen
* @date 2024-06-17
*/
@Service
@Slf4j
public class SettlementCustomersApplicationService {
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private UserServiceFeign userServiceFeign;
/**
* 分页查询结算对象列表
*/
public List<SettlementCustomersPO> queryList(SettlementCustomersDO settlementCustomersDO) {
setTopOrganizationIdLogin(settlementCustomersDO);
return settlementCustomersDomainService.queryList(settlementCustomersDO);
}
/**
* 查询结算对象键值对
*/
public List<SettlementCustomersPO> getSettlementObjectList(SettlementCustomersDO settlementCustomersDO){
setTopOrganizationIdLogin(settlementCustomersDO);
return settlementCustomersDomainService.getSettlementObjects();
}
private void setTopOrganizationIdLogin(SettlementCustomersDO settlementCustomersDO){
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
settlementCustomersDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
}
/**
* 新增结算对象
*/
public Boolean insert(SettlementCustomersDO settlementCustomersDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//校验编码唯一性
checkCode(settlementCustomersDO);
//处理数据字典
handleDict(settlementCustomersDO);
//2024年6月24日改动,手动新增结算对象不与基础数据做关联
settlementCustomersDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
settlementCustomersDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
settlementCustomersDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return settlementCustomersDomainService.insert(settlementCustomersDO);
}
/**
* 校验编码唯一性
* @param settlementCustomersDO
*/
private void checkCode(SettlementCustomersDO settlementCustomersDO) {
if(!StringUtils.isNotEmpty(settlementCustomersDO.getSettlementCustomersCode())) {
throw new ServiceException("结算编码不能为空");
}
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(settlementCustomersDO.getSettlementCustomersCode());
if(settlementCustomers != null){
throw new ServiceException("结算编码已存在");
}
}
/**
* 处理数据字典
*/
private void handleDict(SettlementCustomersDO settlementCustomersDO) {
if(StringUtils.isNotEmpty(settlementCustomersDO.getSettlementMethodCode())){
//查询数据字典
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.SETTLEWAY.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
sysDictDataVoList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if(sysDictDataVoList.size()>0){
SysDictDataVo sysDictDataVo = sysDictDataVoList.stream().filter(info-> ObjectUtil.equal(info.getDictValue(),settlementCustomersDO.getSettlementMethodCode())).findAny().orElse(null);
if(null != sysDictDataVo){
settlementCustomersDO.setSettlementMethod(sysDictDataVo.getDictLabel());
}
}
}
if(StringUtils.isNotEmpty(settlementCustomersDO.getCustomerTypeCode())){
//查询数据字典
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.CUSTOMER_TYPE.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
sysDictDataVoList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if(sysDictDataVoList.size()>0){
SysDictDataVo sysDictDataVo = sysDictDataVoList.stream().filter(info-> ObjectUtil.equal(info.getDictValue(),settlementCustomersDO.getCustomerTypeCode())).findAny().orElse(null);
if(null != sysDictDataVo){
settlementCustomersDO.setCustomerType(sysDictDataVo.getDictLabel());
}
}
}
if(StringUtils.isNotEmpty(settlementCustomersDO.getProjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getProjectByCode(settlementCustomersDO.getProjectCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("项目信息未找到");
}
settlementCustomersDO.setProjectName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("projectName"));
}
}
/**
* 修改结算对象
*/
public Boolean update(SettlementCustomersDO settlementCustomersDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if (StringUtils.isNotEmpty(settlementCustomersDO.getSettlementCustomersCode())) {
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(settlementCustomersDO.getSettlementCustomersCode());
if(settlementCustomers != null && !ObjectUtil.equal(settlementCustomers.getSettlementCustomersId(),settlementCustomersDO.getSettlementCustomersId())){
throw new ServiceException("结算编码已存在");
}
}
//处理数据字典
handleDict(settlementCustomersDO);
return settlementCustomersDomainService.update(settlementCustomersDO);
}
/**
* 批量删除结算对象
*/
public boolean delete(Long[] settlementCustomersIds) {
return settlementCustomersDomainService.delete(settlementCustomersIds);
}
/**
* 获取结算对象详细信息
*/
public SettlementCustomersPO getInfo(Long settlementCustomersId)
{
return settlementCustomersDomainService.getInfo(settlementCustomersId);
}
/**
* 批量删除
* @param settlementCustomersDTO
* @return
*/
public Boolean deleteByIds(SettlementCustomersDTO settlementCustomersDTO) {
if(!StringUtils.isNotEmpty(settlementCustomersDTO.getSettlementCustomersIds())){
throw new ServiceException("结算对象id不能为空");
}
Set<String> idSet = Stream.of(settlementCustomersDTO.getSettlementCustomersIds().split(",")).collect(Collectors.toSet());
Long[] settlementCustomersIds = idSet.stream().map(Long::valueOf).toArray(Long[]::new);
return settlementCustomersDomainService.delete(settlementCustomersIds);
}
/**
* 同步结算对象
*/
public void syncSettlementCustomers() {
/*
查询当前租户下所有的托运人、承运人、货主
对比用户id及主体角色,过滤出未同步的结算对象数据,
新增结算对象,结算方式默认月结,结算方向根据角色区分,承运商是收款方,客户是付款方
首先采用同步请求方式,如果后续数据量过大,更换消息队列或者异步新增
*/
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
SettlementCustomersDO settlementCustomersDO = new SettlementCustomersDO();
settlementCustomersDO.setMainRole(2);
settlementCustomersDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
List<SettlementCustomersPO> settlementCustomersList = settlementCustomersDomainService.queryList(settlementCustomersDO);
//TODO 查询货主信息
// List<SettlementCustomersPO> saveSettingCustomersList = settlementCustomersList
//查询托运人信息,并过滤,同步
settlementCustomersDO.setMainRole(2);
List<SettlementCustomersPO> shipperList = settlementCustomersDomainService.queryList(settlementCustomersDO);
AjaxResult ajaxResult = userServiceFeign.userShipperListAll();
List<UserShipperPo> userShipperPoList = new ArrayList<>();
if ("200".equals(String.valueOf(ajaxResult.get("code"))) && ObjectUtil.isNotNull(ajaxResult.get("data"))) {
userShipperPoList = JSONUtil.toList(JSONObject.toJSONString(ajaxResult.get("data")), UserShipperPo.class);
}
if(userShipperPoList != null && userShipperPoList.size()>0){
//使用stream流过滤出 userShipperPoList中有但是shipperList中没有的集合
List<UserShipperPo> shipperListNew = userShipperPoList.stream().filter(userShipperPo -> {
return shipperList.stream().noneMatch(shipper -> ObjectUtil.equal(shipper.getSettlementEntityId(),userShipperPo.getUserId()));
}).collect(Collectors.toList());
if(shipperListNew.size()>0){
shipperListNew.forEach(userShipperPo -> {
SettlementCustomersDO saveEntity = new SettlementCustomersDO();
saveEntity.setSettlementCustomersCode(OrderSequence.getOrderCode());
saveEntity.setSettlementEntityId(userShipperPo.getUserId());
saveEntity.setSettlementEntity(userShipperPo.getUserName());
saveEntity.setSettlementMethodCode("monthly_settle");
saveEntity(saveEntity);
});
}
}
//查询承运人信息,并过滤,同步
settlementCustomersDO.setMainRole(1);
List<SettlementCustomersPO> driverList = settlementCustomersDomainService.queryList(settlementCustomersDO);
AjaxResult ajaxResultDriver = userServiceFeign.userDriverListAll();
List<UserDriverPo> userDriverPoList = new ArrayList<>();
if ("200".equals(String.valueOf(ajaxResultDriver.get("code"))) && ObjectUtil.isNotNull(ajaxResultDriver.get("data"))) {
userDriverPoList = JSONUtil.toList(JSONObject.toJSONString(ajaxResultDriver.get("data")), UserDriverPo.class);
}
if(userDriverPoList != null && userDriverPoList.size()>0){
//使用stream流过滤出 userDriverPoList中有但是driverList中没有的集合
List<UserDriverPo> driverListNew = userDriverPoList.stream().filter(item -> {
return driverList.stream().noneMatch(driver -> ObjectUtil.equal(driver.getSettlementEntityId(),item.getUserId()));
}).collect(Collectors.toList());
if(driverListNew.size()>0){
driverListNew.forEach(userDriverPo -> {
SettlementCustomersDO saveEntity = new SettlementCustomersDO();
saveEntity.setSettlementCustomersCode(OrderSequence.getOrderCode());
saveEntity.setSettlementEntityId(userDriverPo.getUserId());
saveEntity.setSettlementEntity(userDriverPo.getUserName());
saveEntity.setSettlementMethodCode("monthly_settle");
saveEntity(saveEntity);
});
}
}
}
/**
* 保存结算客户信息
*/
public Boolean saveEntity(SettlementCustomersDO settlementCustomersDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
//处理数据字典
handleDict(settlementCustomersDO);
settlementCustomersDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
settlementCustomersDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
settlementCustomersDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return settlementCustomersDomainService.insert(settlementCustomersDO);
}
/**
* 根据code查询结算对象
* @param settlementCustomersCode
* @return
*/
public SettlementCustomersPO getInfoByCode(String settlementCustomersCode) {
SettlementCustomersPO settlementCustomersPO = new SettlementCustomersPO();
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(settlementCustomersCode);
if(null != settlementCustomers){
BeanUtils.copyProperties(settlementCustomers,settlementCustomersPO);
return settlementCustomersPO;
}
return null;
}
}
@@ -0,0 +1,180 @@
package com.mhd.bms.application.server.taskFlowRecords;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.domain.taskFlowRecords.repository.po.TaskFlowRecordsPO;
import com.mhd.bms.domain.taskFlowRecords.repository.todo.TaskFlowRecordsDO;
import com.mhd.bms.domain.taskFlowRecords.service.TaskFlowRecordsDomainService;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.interfaces.dto.taskFlowRecords.TaskFlowRecordsDTO;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 任务流水记录ApplicationService
*
* @author gen
* @date 2024-06-20
*/
@Service
@Slf4j
public class TaskFlowRecordsApplicationService {
@Autowired
private TaskFlowRecordsDomainService taskFlowRecordsDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private DocumentTypeDomainService documentTypeDomainService;
/**
* 分页查询任务流水记录列表
*/
public List<TaskFlowRecordsPO> queryList(TaskFlowRecordsDO taskFlowRecordsDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null){
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
if (topOrganizationId != null && topOrganizationId != 1){
taskFlowRecordsDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
}
}
return taskFlowRecordsDomainService.queryList(taskFlowRecordsDO);
}
/**
* 新增任务流水记录
*/
public Boolean insert(TaskFlowRecordsDO taskFlowRecordsDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//填充数据字典即跨服务调用获取参数
handleDict(taskFlowRecordsDO);
taskFlowRecordsDO.setTaskFlow(OrderSequence.getOrderCode("JFRW"));
taskFlowRecordsDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
taskFlowRecordsDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
taskFlowRecordsDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return taskFlowRecordsDomainService.insert(taskFlowRecordsDO);
}
/**
* 填充数据字典
*/
private void handleDict(TaskFlowRecordsDO taskFlowRecordsDO) {
//查询来源模块数据字典
if(StringUtils.isNotEmpty(taskFlowRecordsDO.getBelongModuleCode())){
List<SysDictDataVo> modulesTypeList = null;
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.MODULES.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
modulesTypeList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
}
if (modulesTypeList != null && modulesTypeList.size() > 0){
for (SysDictDataVo sysDictDataVo : modulesTypeList) {
if (taskFlowRecordsDO.getBelongModuleCode().equals(sysDictDataVo.getDictValue())){
taskFlowRecordsDO.setBelongModule(sysDictDataVo.getDictLabel());
break;
}
}
}
}
//查询费用科目
if(StringUtils.isNotEmpty(taskFlowRecordsDO.getSecondSubjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getSubInfoByCode(taskFlowRecordsDO.getSecondSubjectCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
ExpenseAccountPO expenseAccountPO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ExpenseAccountPO.class);
if(null == expenseAccountPO){
throw new ServiceException("费用科目信息未找到");
}
taskFlowRecordsDO.setServiceItemsCode(expenseAccountPO.getServiceItemsCode());
taskFlowRecordsDO.setServiceItemsName(expenseAccountPO.getServiceItemsName());
if(expenseAccountPO.getFirstSubjectFlag()==1){
//如果是一级科目
taskFlowRecordsDO.setFirstSubjectName(expenseAccountPO.getSubjectName());
taskFlowRecordsDO.setFirstSubjectCode(expenseAccountPO.getSubjectCode());
taskFlowRecordsDO.setSecondSubjectCode("");
taskFlowRecordsDO.setSecondSubjectName("");
}else {
//不是一级科目
taskFlowRecordsDO.setFirstSubjectName(expenseAccountPO.getUpperSubject());
taskFlowRecordsDO.setFirstSubjectCode(expenseAccountPO.getUpperSubjectCode());
taskFlowRecordsDO.setSecondSubjectCode(expenseAccountPO.getSubjectCode());
taskFlowRecordsDO.setSecondSubjectName(expenseAccountPO.getSubjectName());
}
}
}
//根据单据类型id查询单据类型数据,并赋值
if(taskFlowRecordsDO.getDocumentTypeId() != null){
DocumentTypePO documentTypePO = documentTypeDomainService.getInfo(taskFlowRecordsDO.getDocumentTypeId());
if(null != documentTypePO){
taskFlowRecordsDO.setDocumentType(documentTypePO.getDocumentType());
taskFlowRecordsDO.setDocumentTypeCode(documentTypePO.getDocumentTypeCode());
}
}
//TODO 查询计费规则
}
/**
* 修改任务流水记录
*/
public Boolean update(TaskFlowRecordsDO taskFlowRecordsDO) {
return taskFlowRecordsDomainService.update(taskFlowRecordsDO);
}
/**
* 批量删除任务流水记录
*/
public boolean delete(Long[] taskFlowRecordsIds) {
return taskFlowRecordsDomainService.delete(taskFlowRecordsIds);
}
/**
* 获取任务流水记录详细信息
*/
public TaskFlowRecordsPO getInfo(Long taskFlowRecordsId)
{
return taskFlowRecordsDomainService.getInfo(taskFlowRecordsId);
}
/**
* 批量删除任务流水记录
* @param taskFlowRecordsDTO
* @return
*/
public boolean deleteByIds(TaskFlowRecordsDTO taskFlowRecordsDTO) {
if(!StringUtils.isNotEmpty(taskFlowRecordsDTO.getTaskFlowRecordsIds())){
throw new ServiceException("任务流水id不能为空");
}
Set<String> idSet = Stream.of(taskFlowRecordsDTO.getTaskFlowRecordsIds().split(",")).collect(Collectors.toSet());
Long[] taskFlowRecordsIds = idSet.stream().map(Long::valueOf).toArray(Long[]::new);
return taskFlowRecordsDomainService.delete(taskFlowRecordsIds);
}
}
@@ -0,0 +1,78 @@
package com.mhd.bms.domain.billManage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 账单流水明细对象 bill_detail
*
* @author gen
* @date 2024-07-02
*/
@Data
public class BillDetail extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单流水明细id")
@TableId(type = IdType.AUTO)
private Long billDetailId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("计费流水id")
@Excel(name = "计费流水id")
private Long billingStatementId;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("费用总额")
@Excel(name = "费用总额")
private BigDecimal billingTotalAmount;
@ApiModelProperty("账单优惠金额")
@Excel(name = "账单优惠金额")
private BigDecimal billingDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billingAmount;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billingExpectedAmount;
}
@@ -0,0 +1,186 @@
package com.mhd.bms.domain.billManage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 账单管理对象 bill_manage
*
* @author gen
* @date 2024-07-02
*/
@Data
public class BillManage extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单管理id")
@TableId(type = IdType.AUTO)
private Long billManageId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
private Integer billState;
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
@Excel(name = "账单流程节点", readConverterExp = "1=-发起对账,2-客户确认,3-财务审核,4-收款/付款")
private Integer billStep;
@ApiModelProperty("系统来源")
@Excel(name = "系统来源")
private String belongModule;
@ApiModelProperty("系统来源code")
@Excel(name = "系统来源code")
private String belongModuleCode;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("账单总金额")
@Excel(name = "账单总金额")
private BigDecimal billTotalAmount;
@ApiModelProperty("优惠金额")
@Excel(name = "优惠金额")
private BigDecimal billDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("已收/付金额")
@Excel(name = "已收/付金额")
private BigDecimal billAmountSettlement;
@ApiModelProperty("未收/付金额")
@Excel(name = "未收/付金额")
private BigDecimal billAmountUnsettled;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billExpectedAmount;
@ApiModelProperty("对账状态(1-暂未确认,2-申请调账,3-财务调账,4-核对无误)")
@Excel(name = "对账状态", readConverterExp = "1=-暂未确认,2-申请调账,3-财务调账,4-核对无误")
private Integer reconciliationStatus;
@ApiModelProperty("对账意见描述")
@Excel(name = "对账意见描述")
private String reconciliationOpinion;
@ApiModelProperty("客户凭证地址")
@Excel(name = "客户凭证地址")
private String voucherAddress;
@ApiModelProperty("财务审核结果(1-同意,2-拒绝)")
@Excel(name = "财务审核结果(1-同意,2-拒绝)")
private Integer financialReviewFlag;
@ApiModelProperty("审核意见描述")
@Excel(name = "审核意见描述")
private String financialReviewOpinion;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("收款/付款时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "收款/付款时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date settlementTime;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String billRemark;
@ApiModelProperty("折扣百分比")
@Excel(name = "折扣百分比")
private BigDecimal billDiscount;
@ApiModelProperty("折扣上限金额")
@Excel(name = "折扣上限金额")
private BigDecimal billDiscountLimit;
@ApiModelProperty("费用计算精度code")
@Excel(name = "费用计算精度code")
private String costAccuracyCode;
@ApiModelProperty("费用计算精度name")
@Excel(name = "费用计算精度name")
private String costAccuracyName;
@ApiModelProperty("尾数计算code")
@Excel(name = "尾数计算code")
private String tailCalculationCode;
@ApiModelProperty("尾数计算name")
@Excel(name = "尾数计算name")
private String tailCalculationName;
@ApiModelProperty("账单金额精度code")
@Excel(name = "账单金额精度code")
private String amountAccuracyCode;
@ApiModelProperty("账单金额精度name")
@Excel(name = "账单金额精度name")
private String amountAccuracyName;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("结算方式")
private String settlementMethod;
@ApiModelProperty("结算方式编码")
private String settlementMethodCode;
@ApiModelProperty("实收金额")
private BigDecimal actualReceivedAmount;
@ApiModelProperty("结算单优惠金额")
private BigDecimal settlementDiscountsAmount;
}
@@ -0,0 +1,41 @@
package com.mhd.bms.domain.billManage.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
import java.util.List;
/**
* 账单流水明细Service接口
*
* @author gen
* @date 2024-07-02
*/
public interface IBillDetailService extends IService<BillDetail>
{
/**
* 新增账单流水明细
*/
public Boolean insert(BillDetailDO billDetailDO);
/**
* 修改账单流水明细
*/
public Boolean update(BillDetailDO billDetailDO);
/**
* 批量删除账单流水明细
*/
public Boolean delete(Long[] billDetailIds);
/**
* 查询账单流水明细
*/
public BillDetailPO getInfo(Long billDetailId);
List<BillDetailPO> getDetailsByBillManageId(Long billManageId);
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.billManage.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
import java.util.List;
/**
* 账单管理Service接口
*
* @author gen
* @date 2024-07-02
*/
public interface IBillManageService extends IService<BillManage>
{
/**
* 分页查询账单管理列表
*/
public List<BillManagePO> queryList(BillManageDO billManageDO);
/**
* 新增账单管理
*/
public Boolean insert(BillManageDO billManageDO);
/**
* 修改账单管理
*/
public Boolean update(BillManageDO billManageDO);
/**
* 批量删除账单管理
*/
public Boolean delete(Long[] billManageIds);
/**
* 查询账单管理
*/
public BillManagePO getInfo(Long billManageId);
}
@@ -0,0 +1,20 @@
package com.mhd.bms.domain.billManage.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 账单流水明细Mapper接口
*
* @author gen
* @date 2024-07-02
*/
public interface BillDetailMapper extends BaseMapper<BillDetail>
{
List<BillDetailPO> getDetailsByBillManageId(@Param("billManageId") Long billManageId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.billManage.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
import org.apache.ibatis.annotations.Param;
/**
* 账单管理Mapper接口
*
* @author gen
* @date 2024-07-02
*/
public interface BillManageMapper extends BaseMapper<BillManage>
{
/**
* 查询账单管理列表
*/
public List<BillManagePO> queryList(@Param("billManageDO") BillManageDO billManageDO);
}
@@ -0,0 +1,78 @@
package com.mhd.bms.domain.billManage.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService;
import com.mhd.bms.domain.billManage.repository.mapper.BillDetailMapper;
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 账单流水明细Service业务层处理
*
* @author gen
* @date 2024-07-02
*/
@Service
public class BillDetailImpl extends ServiceImpl<BillDetailMapper, BillDetail> implements IBillDetailService {
@Autowired
private BillDetailMapper billDetailMapper;
/**
* 新增账单流水明细
*/
@Override
public Boolean insert(BillDetailDO billDetailDO) {
BillDetail billDetail = new BillDetail();
BeanUtils.copyProperties(billDetailDO,billDetail);
return this.save(billDetail);
}
/**
* 修改账单流水明细
*/
@Override
public Boolean update(BillDetailDO billDetailDO) {
BillDetail billDetail = new BillDetail();
BeanUtils.copyProperties(billDetailDO,billDetail);
return this.updateById(billDetail);
}
/**
* 批量删除账单流水明细
*/
@Override
public Boolean delete(Long[] billDetailIds ) {
List<BillDetail> list = new ArrayList<>();
for (Long id : billDetailIds) {
BillDetail billDetail = new BillDetail();
billDetail.setBillDetailId(id);
billDetail.setDelFlag(2);
list.add(billDetail);
}
return this.updateBatchById(list);
}
/**
* 修改账单流水明细
*/
@Override
public BillDetailPO getInfo(Long billDetailId) {
BillDetail billDetail = this.getById(billDetailId);
BillDetailPO billDetailPO = new BillDetailPO();
BeanUtils.copyProperties(billDetail,billDetailPO);
return billDetailPO;
}
@Override
public List<BillDetailPO> getDetailsByBillManageId(Long billManageId) {
return billDetailMapper.getDetailsByBillManageId(billManageId);
}
}
@@ -0,0 +1,81 @@
package com.mhd.bms.domain.billManage.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.facade.IBillManageService;
import com.mhd.bms.domain.billManage.repository.mapper.BillManageMapper;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 账单管理Service业务层处理
*
* @author gen
* @date 2024-07-02
*/
@Service
public class BillManageImpl extends ServiceImpl<BillManageMapper, BillManage> implements IBillManageService{
@Autowired
private BillManageMapper billManageMapper;
/**
* 查询账单管理列表
*/
@Override
public List<BillManagePO> queryList(BillManageDO billManageDO)
{
return billManageMapper.queryList(billManageDO);
}
/**
* 新增账单管理
*/
@Override
public Boolean insert(BillManageDO billManageDO) {
BillManage billManage = new BillManage();
BeanUtils.copyProperties(billManageDO,billManage);
return this.save(billManage);
}
/**
* 修改账单管理
*/
@Override
public Boolean update(BillManageDO billManageDO) {
BillManage billManage = new BillManage();
BeanUtils.copyProperties(billManageDO,billManage);
return this.updateById(billManage);
}
/**
* 批量删除账单管理
*/
@Override
public Boolean delete(Long[] billManageIds ) {
List<BillManage> list = new ArrayList<>();
for (Long id : billManageIds) {
BillManage billManage = new BillManage();
billManage.setBillManageId(id);
billManage.setDelFlag(2);
list.add(billManage);
}
return this.updateBatchById(list);
}
/**
* 修改账单管理
*/
@Override
public BillManagePO getInfo(Long billManageId) {
BillManage billManage = this.getById(billManageId);
BillManagePO billManagePO = new BillManagePO();
BeanUtils.copyProperties(billManage,billManagePO);
return billManagePO;
}
}
@@ -0,0 +1,124 @@
package com.mhd.bms.domain.billManage.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 账单流水明细对象 bill_detail
*
* @author gen
* @date 2024-07-02
*/
@Data
@ApiModel(value = "账单流水明细对象", description = "账单流水明细响应对象")
public class BillDetailPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单流水明细id")
private Long billDetailId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("计费流水id")
@Excel(name = "计费流水id")
private Long billingStatementId;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("费用总额")
@Excel(name = "费用总额")
private BigDecimal billingTotalAmount;
@ApiModelProperty("账单优惠金额")
@Excel(name = "账单优惠金额")
private BigDecimal billingDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billingAmount;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billingExpectedAmount;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("业务日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
}
@@ -0,0 +1,197 @@
package com.mhd.bms.domain.billManage.repository.po;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.List;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 账单管理对象 bill_manage
*
* @author gen
* @date 2024-07-02
*/
@Data
@ApiModel(value = "账单管理对象", description = "账单管理响应对象")
public class BillManagePO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单管理id")
private Long billManageId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
private Integer billState;
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
@Excel(name = "账单流程节点", readConverterExp = "1=-发起对账,2-客户确认,3-财务审核,4-收款/付款")
private Integer billStep;
@ApiModelProperty("系统来源")
@Excel(name = "系统来源")
private String belongModule;
@ApiModelProperty("系统来源code")
@Excel(name = "系统来源code")
private String belongModuleCode;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("账单总金额")
@Excel(name = "账单总金额")
private BigDecimal billTotalAmount;
@ApiModelProperty("优惠金额")
@Excel(name = "优惠金额")
private BigDecimal billDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("已收/付金额")
@Excel(name = "已收/付金额")
private BigDecimal billAmountSettlement;
@ApiModelProperty("未收/付金额")
@Excel(name = "未收/付金额")
private BigDecimal billAmountUnsettled;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billExpectedAmount;
@ApiModelProperty("对账状态(1-暂未确认,2-申请调账,3-财务调账,4-核对无误)")
@Excel(name = "对账状态", readConverterExp = "1=-暂未确认,2-申请调账,3-财务调账,4-核对无误")
private Integer reconciliationStatus;
@ApiModelProperty("对账意见描述")
@Excel(name = "对账意见描述")
private String reconciliationOpinion;
@ApiModelProperty("客户凭证地址")
@Excel(name = "客户凭证地址")
private String voucherAddress;
@ApiModelProperty("财务审核结果(1-同意,2-拒绝)")
@Excel(name = "财务审核结果(1-同意,2-拒绝)")
private Integer financialReviewFlag;
@ApiModelProperty("审核意见描述")
@Excel(name = "审核意见描述")
private String financialReviewOpinion;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("收款/付款时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "收款/付款时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date settlementTime;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String billRemark;
@ApiModelProperty("折扣百分比")
@Excel(name = "折扣百分比")
private BigDecimal billDiscount;
@ApiModelProperty("折扣上限金额")
@Excel(name = "折扣上限金额")
private BigDecimal billDiscountLimit;
@ApiModelProperty("费用计算精度code")
@Excel(name = "费用计算精度code")
private String costAccuracyCode;
@ApiModelProperty("费用计算精度name")
@Excel(name = "费用计算精度name")
private String costAccuracyName;
@ApiModelProperty("尾数计算code")
@Excel(name = "尾数计算code")
private String tailCalculationCode;
@ApiModelProperty("尾数计算name")
@Excel(name = "尾数计算name")
private String tailCalculationName;
@ApiModelProperty("账单金额精度code")
@Excel(name = "账单金额精度code")
private String amountAccuracyCode;
@ApiModelProperty("账单金额精度name")
@Excel(name = "账单金额精度name")
private String amountAccuracyName;
@ApiModelProperty("账单详情明细列表")
private List<BillDetailPO> billDetailPOList;
@ApiModelProperty("账单流水明细表")
private List<BillingStatementPO> billingStatementPOList;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("结算方式")
private String settlementMethod;
@ApiModelProperty("结算方式编码")
private String settlementMethodCode;
@ApiModelProperty("实收金额")
private BigDecimal actualReceivedAmount;
@ApiModelProperty("结算单优惠金额")
private BigDecimal settlementDiscountsAmount;
@ApiModelProperty("流水ids")
private String billingStatementIds;
}
@@ -0,0 +1,81 @@
package com.mhd.bms.domain.billManage.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 账单流水明细对象 bill_detail
*
* @author gen
* @date 2024-07-02
*/
@Data
public class BillDetailDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单流水明细id")
private Long billDetailId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("计费流水id")
@Excel(name = "计费流水id")
private Long billingStatementId;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("费用总额")
@Excel(name = "费用总额")
private BigDecimal billingTotalAmount;
@ApiModelProperty("账单优惠金额")
@Excel(name = "账单优惠金额")
private BigDecimal billingDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billingAmount;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billingExpectedAmount;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,208 @@
package com.mhd.bms.domain.billManage.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
import java.util.Set;
/**
* 账单管理对象 bill_manage
*
* @author gen
* @date 2024-07-02
*/
@Data
public class BillManageDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单管理id")
private Long billManageId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单编号")
@Excel(name = "账单编号")
private String billNumber;
@ApiModelProperty("账单类型(1-应收,2-应付)")
@Excel(name = "账单类型", readConverterExp = "1=-应收,2-应付")
private Integer billType;
@ApiModelProperty("账单状态(1-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款)")
@Excel(name = "账单状态", readConverterExp = "1=-未确认,2-对账中,3-未收款/付款,4-部分收款/付款,5-已收款/付款,6-已作废,7-已退款")
private Integer billState;
@ApiModelProperty("账单流程节点(1-发起对账,2-客户确认,3-财务审核,4-收款/付款)")
@Excel(name = "账单流程节点", readConverterExp = "1=-发起对账,2-客户确认,3-财务审核,4-收款/付款")
private Integer billStep;
@ApiModelProperty("系统来源")
@Excel(name = "系统来源")
private String belongModule;
@ApiModelProperty("系统来源code")
@Excel(name = "系统来源code")
private String belongModuleCode;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("账单总金额")
@Excel(name = "账单总金额")
private BigDecimal billTotalAmount;
@ApiModelProperty("优惠金额")
@Excel(name = "优惠金额")
private BigDecimal billDiscountAmount;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("已收/付金额")
@Excel(name = "已收/付金额")
private BigDecimal billAmountSettlement;
@ApiModelProperty("未收/付金额")
@Excel(name = "未收/付金额")
private BigDecimal billAmountUnsettled;
@ApiModelProperty("期望金额")
@Excel(name = "期望金额")
private BigDecimal billExpectedAmount;
@ApiModelProperty("对账状态(1-暂未确认,2-申请调账,3-财务调账,4-核对无误)")
@Excel(name = "对账状态", readConverterExp = "1=-暂未确认,2-申请调账,3-财务调账,4-核对无误")
private Integer reconciliationStatus;
@ApiModelProperty("对账意见描述")
@Excel(name = "对账意见描述")
private String reconciliationOpinion;
@ApiModelProperty("客户凭证地址")
@Excel(name = "客户凭证地址")
private String voucherAddress;
@ApiModelProperty("财务审核结果(1-同意,2-拒绝)")
@Excel(name = "财务审核结果(1-同意,2-拒绝)")
private Integer financialReviewFlag;
@ApiModelProperty("审核意见描述")
@Excel(name = "审核意见描述")
private String financialReviewOpinion;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("收款/付款时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "收款/付款时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date settlementTime;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String billRemark;
@ApiModelProperty("折扣百分比")
@Excel(name = "折扣百分比")
private BigDecimal billDiscount;
@ApiModelProperty("折扣上限金额")
@Excel(name = "折扣上限金额")
private BigDecimal billDiscountLimit;
@ApiModelProperty("费用计算精度code")
@Excel(name = "费用计算精度code")
private String costAccuracyCode;
@ApiModelProperty("费用计算精度name")
@Excel(name = "费用计算精度name")
private String costAccuracyName;
@ApiModelProperty("尾数计算code")
@Excel(name = "尾数计算code")
private String tailCalculationCode;
@ApiModelProperty("尾数计算name")
@Excel(name = "尾数计算name")
private String tailCalculationName;
@ApiModelProperty("账单金额精度code")
@Excel(name = "账单金额精度code")
private String amountAccuracyCode;
@ApiModelProperty("账单金额精度name")
@Excel(name = "账单金额精度name")
private String amountAccuracyName;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "修改时间查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "修改时间查询条件结束日期")
private String updateTimeEnd;
@ApiModelProperty("查询条件类型(1-未结清,2-已结清,3-已作废)")
private Integer queryParam;
@ApiModelProperty(name = "账单管理id集合")
private Set<String> billManageIdSet;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("结算方式")
private String settlementMethod;
@ApiModelProperty("结算方式编码")
private String settlementMethodCode;
@ApiModelProperty("实收金额")
private BigDecimal actualReceivedAmount;
@ApiModelProperty("结算单优惠金额")
private BigDecimal settlementDiscountsAmount;
}
@@ -0,0 +1,155 @@
package com.mhd.bms.domain.billManage.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.repository.facade.IBillDetailService;
import com.mhd.bms.domain.billManage.repository.po.BillDetailPO;
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
import com.mhd.bms.interfaces.dto.billManage.BillDetailDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
* 账单流水明细
*
* @author gen
* @date 2024-07-02
*/
@Service
@Slf4j
public class BillDetailDomainService {
@Autowired
private IBillDetailService billDetailService;
/**
* 新增账单流水明细
*/
public Boolean insert(BillDetailDO billDetailDO) {
return billDetailService.insert(billDetailDO);
}
/**
* 修改账单流水明细
*/
public Boolean update(BillDetailDO billDetailDO) {
return billDetailService.update(billDetailDO);
}
/**
* 批量删除账单流水明细
*/
public Boolean delete(Long[] billDetailIds) {
return billDetailService.delete(billDetailIds);
}
/**
* 获取账单流水明细详细信息
*/
public BillDetailPO getInfo(Long billDetailId)
{
return billDetailService.getInfo(billDetailId);
}
public Boolean insertBatch(List<BillDetail> billDetailList) {
return billDetailService.saveBatch(billDetailList);
}
public List<BillDetail> queryByLambda(LambdaQueryWrapper<BillDetail> queryWrapper) {
return billDetailService.list(queryWrapper);
}
/**
* 根据账单管理id删除账单明细
*/
public Boolean deletByManageIds(Set<String> billManageIds) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
LambdaUpdateWrapper<BillDetail> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillDetail::getBillManageId, billManageIds);
updateWrapper.set(BillDetail::getDelFlag, 2);
updateWrapper.set(BillDetail::getUpdateBy, loginUser.getUserPo().getUserId());
updateWrapper.set(BillDetail::getUpdateTime, new Date());
updateWrapper.set(BillDetail::getUpdateByName, loginUser.getUserPo().getUserName());
return billDetailService.update(updateWrapper);
}
/**
* 根据账单管理,查询账单详情
*/
public List<BillDetailPO> getDetailsByBillManageId(Long billManageId) {
return billDetailService.getDetailsByBillManageId(billManageId);
}
/**
* 根据账单管理id删除账单明细
* @param billManageId
* @return
*/
public Boolean removeByBillManageId(Long billManageId) {
LambdaQueryWrapper<BillDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BillDetail::getBillManageId, billManageId);
queryWrapper.eq(BillDetail::getDelFlag, 1);
return billDetailService.remove(queryWrapper);
}
/**
* 批量保存明细
* @param billDetailDTOList
* @return
*/
public Boolean saveBatch(List<BillDetailDTO> billDetailDTOList) {
List<BillDetail> billDetailList = new ArrayList<>();
billDetailDTOList.forEach(billDetailDTO -> {
BillDetail billDetail = new BillDetail();
BeanUtils.copyProperties(billDetailDTO, billDetail);
//校验相加是否合理
if((billDetail.getBillingDiscountAmount().add(billDetail.getBillingAmount())).compareTo(billDetail.getBillingTotalAmount()) != 0){
throw new ServiceException("账单明细"+ billDetailDTO.getBillingFlow() +"费用异常,请重试");
}
billDetailList.add(billDetail);
});
return billDetailService.saveBatch(billDetailList);
}
/**
* 修改详情金额
*/
public Boolean changeAmount(List<BillDetailDTO> billDetailDTOList) {
List<BillDetail> billDetailList = new ArrayList<>();
billDetailDTOList.forEach(billDetailDTO -> {
BillDetail billDetail = new BillDetail();
billDetail.setBillingExpectedAmount(billDetailDTO.getBillingExpectedAmount());
billDetail.setBillingTotalAmount(billDetailDTO.getBillingTotalAmount());
billDetail.setBillingAmount(billDetailDTO.getBillingAmount());
billDetail.setBillingDiscountAmount(billDetailDTO.getBillingDiscountAmount());
//校验相加是否合理
if((billDetail.getBillingDiscountAmount().add(billDetail.getBillingAmount())).compareTo(billDetail.getBillingTotalAmount()) != 0){
throw new ServiceException("账单明细"+ billDetailDTO.getBillingFlow() +"费用异常,请重试");
}
billDetail.setBillDetailId(billDetailDTO.getBillDetailId());
billDetailList.add(billDetail);
});
return billDetailService.updateBatchById(billDetailList);
}
}
@@ -0,0 +1,506 @@
package com.mhd.bms.domain.billManage.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.billManage.entity.BillDetail;
import com.mhd.bms.domain.billManage.entity.BillManage;
import com.mhd.bms.domain.billManage.repository.facade.IBillManageService;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.repository.todo.BillDetailDO;
import com.mhd.bms.domain.billManage.repository.todo.BillManageDO;
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import com.mhd.bms.domain.billOperationLog.service.BillOperationLogDomainService;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import com.mhd.bms.domain.billingStatement.service.BillingStatementDomainService;
import com.mhd.bms.domain.paymentOrder.repository.todo.PaymentOrderDO;
import com.mhd.bms.domain.receiptManage.entity.ReceiptDetail;
import com.mhd.bms.domain.receiptManage.repository.todo.ReceiptManageDO;
import com.mhd.bms.domain.settlementCustomers.repository.po.SettlementCustomersPO;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.infrastructure.constant.BillLogsConstants;
import com.mhd.bms.interfaces.assembler.billManage.BillManageAssembler;
import com.mhd.bms.interfaces.dto.billManage.BillManageDTO;
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
import com.mhd.bms.interfaces.dto.paymentOrder.PaymentOrderDetailsDTO;
import com.mhd.bms.interfaces.dto.receiptManage.ReceiptDetailDTO;
import com.mhd.common.core.domain.po.SysDictDataVo;
import com.mhd.common.core.enums.DictCode;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.OrderSequence;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* 账单管理
*
* @author gen
* @date 2024-07-02
*/
@Service
@Slf4j
public class BillManageDomainService {
@Autowired
private IBillManageService billManageService;
@Autowired
private BillingStatementDomainService billingStatementDomainService;
@Autowired
private BillDetailDomainService billDetailDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private BillOperationLogDomainService billOperationLogDomainService;
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
/**
* 分页查询账单管理列表
*/
public List<BillManagePO> queryList(BillManageDO billManageDO) {
return billManageService.queryList(billManageDO);
}
/**
* 新增账单管理
*/
public Boolean insert(BillManageDO billManageDO) {
return billManageService.insert(billManageDO);
}
/**
* 修改账单管理
*/
public Boolean update(BillManageDO billManageDO) {
return billManageService.update(billManageDO);
}
/**
* 批量删除账单管理
*/
public Boolean delete(Long[] billManageIds) {
return billManageService.delete(billManageIds);
}
/**
* 获取账单管理详细信息
*/
public BillManagePO getInfo(Long billManageId)
{
return billManageService.getInfo(billManageId);
}
/**
* 保存账单
*/
public Boolean saveBill(List<BillingStatementPO> billingStatementPOS,String billingRemark,Date billCreateTime) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillManage billManage = new BillManage();
billManage.setCreateBy(loginUser.getUserPo().getUserId());
billManage.setCreateByName(loginUser.getUserPo().getUserName());
billManage.setCreateTime(billCreateTime==null ? new Date():billCreateTime);
billManage.setDelFlag(1);
billManage.setBillNumber(OrderSequence.getOrderCode("ZD"));
billManage.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billManage.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billManage.setOrganizationName(loginUser.getUserPo().getOrganizationName());
billManage.setBillType(billingStatementPOS.get(0).getAccountExpenseType());
billManage.setBelongModule(billingStatementPOS.get(0).getBelongModule());
billManage.setBelongModuleCode(billingStatementPOS.get(0).getBelongModuleCode());
billManage.setSettlementCustomersId(billingStatementPOS.get(0).getSettlementCustomersId());
billManage.setSettlementEntity(billingStatementPOS.get(0).getSettlementEntity());
billManage.setSettlementCustomersCode(billingStatementPOS.get(0).getSettlementCustomersCode());
billManage.setBillRemark(billingRemark);
//查询结算对象信息
SettlementCustomersPO settlementCustomersPO = settlementCustomersDomainService.getInfo(billingStatementPOS.get(0).getSettlementCustomersId());
if(null == settlementCustomersPO){
throw new ServiceException("结算对象信息未找到");
}
billManage.setSettlementMethod(settlementCustomersPO.getSettlementMethod());
billManage.setSettlementMethodCode(settlementCustomersPO.getSettlementMethodCode());
// if(settlementCustomersPO.getMainRole()==1){
// billManage.setBillType(1);
// }else {
// billManage.setBillType(2);
// }
//计算所有流水列表中的最早周期开始时间和晚周期结束时间
List<Date> cycleBeginTimeSet = billingStatementPOS.stream().map(BillingStatementPO::getCycleBeginTime).collect(Collectors.toList());
List<Date> cycleEndTimeSet = billingStatementPOS.stream().map(BillingStatementPO::getCycleEndTime).collect(Collectors.toList());
cycleBeginTimeSet.removeIf(Objects::isNull);
cycleEndTimeSet.removeIf(Objects::isNull);
if(cycleBeginTimeSet.size()>0){
billManage.setCycleBeginTime(Collections.min(cycleBeginTimeSet));
}
if(cycleEndTimeSet.size()>0){
billManage.setCycleEndTime(Collections.max(cycleEndTimeSet));
}
//将所有的流水金额相加
billManage.setBillTotalAmount(billingStatementPOS.stream().map(BillingStatementPO::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
billManage.setBillAmount(billManage.getBillTotalAmount());
billManage.setBillAmountUnsettled(billManage.getBillTotalAmount());
boolean flag = billManageService.save(billManage);
List<BillDetail> billDetailList = new ArrayList<>();
for (BillingStatementPO billingStatementPO : billingStatementPOS) {
//生成对账单详情
BillDetail billDetail = new BillDetail();
billDetail.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billDetail.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billDetail.setOrganizationName(loginUser.getUserPo().getOrganizationName());
billDetail.setCreateBy(billManage.getCreateBy());
billDetail.setCreateByName(billManage.getCreateByName());
billDetail.setCreateTime(billManage.getCreateTime());
billDetail.setBillManageId(billManage.getBillManageId());
billDetail.setBillNumber(billManage.getBillNumber());
billDetail.setBillingStatementId(billingStatementPO.getBillingStatementId());
billDetail.setBillingFlow(billingStatementPO.getBillingFlow());
billDetail.setBillingTotalAmount(billingStatementPO.getBillingAmount());
billDetail.setBillingAmount(billingStatementPO.getBillingAmount());
billDetail.setBillType(billingStatementPO.getAccountExpenseType());
billDetailList.add(billDetail);
}
boolean flagTwo = billDetailDomainService.insertBatch(billDetailList);
//保存账单操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageId(billManage.getBillManageId());
billOperationLogDO.setOperationInfo(StringUtils.format(BillLogsConstants.create_bill_text, billManage.getBillNumber(), billManage.getBillTotalAmount()));
billOperationLogDO.setOperationType(1);
boolean three = billOperationLogDomainService.saveBillOperationLog(billOperationLogDO);
return flag && flagTwo && three;
}
/**
* 保存账单
* @param billingStatementDTO
* @return
*/
public Boolean save(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//根据前端传的流水id,查询计费流水信息列表
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
BillingStatementDO billingStatementDO = new BillingStatementDO();
billingStatementDO.setBillingStatementIdSet(billingSet);
List<BillingStatementPO> billingStatementPOS = billingStatementDomainService.queryList(billingStatementDO);
if(billingStatementPOS==null || billingStatementPOS.size()==0){
throw new ServiceException("所选流水信息未找到");
}
return saveBill(billingStatementPOS,billingStatementDTO.getBillingRemark(),billingStatementDTO.getBillCreateTime());
}
public List<BillManage> queryListLambda(LambdaQueryWrapper<BillManage> queryWrapper) {
return billManageService.list(queryWrapper);
}
/**
* 作废账单
*/
public Boolean nullifyByIds(Set<String> billManageIds) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
LambdaUpdateWrapper<BillManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillManage::getBillManageId,billManageIds)
.set(BillManage::getBillState,6)
.set(BillManage::getUpdateBy,loginUser.getUserPo().getUserId())
.set(BillManage::getUpdateByName,loginUser.getUserPo().getUserName())
.set(BillManage::getUpdateTime,new Date());
//调整账单操作日志
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageIdSet(billManageIds);
billOperationLogDO.setOperationInfo(BillLogsConstants.nullify_bill_text);
billOperationLogDO.setOperationType(8);
boolean three = billOperationLogDomainService.saveBillOperationLogBatch(billOperationLogDO);
boolean flag = billManageService.update(updateWrapper);
return flag && three;
}
/**
* 发起对账
*/
public Boolean reconciliation(BillManageDO billManageDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
LambdaUpdateWrapper<BillManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillManage::getBillManageId,billManageDO.getBillManageIdSet())
.set(BillManage::getBillStep,2)
.set(BillManage::getBillState,2)
.set(BillManage::getReconciliationStatus,1)
.set(BillManage::getUpdateBy,loginUser.getUserPo().getUserId())
.set(BillManage::getUpdateByName,loginUser.getUserPo().getUserName())
.set(BillManage::getUpdateTime,new Date());
boolean flag = billManageService.update(updateWrapper);
//保存账单操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageIdSet(billManageDO.getBillManageIdSet());
billOperationLogDO.setOperationInfo(BillLogsConstants.initiate_bill_text);
billOperationLogDO.setOperationType(4);
boolean three = billOperationLogDomainService.saveBillOperationLogBatch(billOperationLogDO);
return flag && three;
}
/**
* 确认账单
*/
public Boolean confirmBilling(BillManageDO billManageDO) {
//直接修改状态到未收款3状态
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
LambdaUpdateWrapper<BillManage> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillManage::getBillManageId,billManageDO.getBillManageIdSet())
.set(BillManage::getBillStep,4)
.set(BillManage::getBillState,3)
.set(BillManage::getUpdateBy,loginUser.getUserPo().getUserId())
.set(BillManage::getUpdateByName,loginUser.getUserPo().getUserName())
.set(BillManage::getUpdateTime,new Date());
boolean flag = billManageService.update(updateWrapper);
//保存账单操作记录
BillOperationLogDO billOperationLogDO = new BillOperationLogDO();
billOperationLogDO.setBillManageIdSet(billManageDO.getBillManageIdSet());
billOperationLogDO.setOperationInfo(BillLogsConstants.confirm_bill_text);
billOperationLogDO.setOperationType(3);
boolean three = billOperationLogDomainService.saveBillOperationLogBatch(billOperationLogDO);
return flag && three;
}
/**
* 处理数据
*/
public void handlData(BillManageDO billManageDO) {
if(StringUtils.isNotEmpty(billManageDO.getAmountAccuracyCode())){
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.AMOUNT_ACCURACY.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
sysDictDataVoList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
if(sysDictDataVoList != null && sysDictDataVoList.size()>0){
sysDictDataVoList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), billManageDO.getAmountAccuracyCode())).findAny().ifPresent(sysDictDataVo -> billManageDO.setAmountAccuracyName(sysDictDataVo.getDictLabel()));
}
}
}
if(StringUtils.isNotEmpty(billManageDO.getCostAccuracyCode())){
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.COST_ACCURACY.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
sysDictDataVoList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
if(sysDictDataVoList != null && sysDictDataVoList.size()>0){
sysDictDataVoList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), billManageDO.getCostAccuracyCode())).findAny().ifPresent(sysDictDataVo -> billManageDO.setCostAccuracyName(sysDictDataVo.getDictLabel()));
}
}
}
if(StringUtils.isNotEmpty(billManageDO.getTailCalculationCode())){
List<SysDictDataVo> sysDictDataVoList = new ArrayList<>();
AjaxResult ajaxResult = systemServiceFeign.selectListByDictType(DictCode.TAIL_CALCULATION.getCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
sysDictDataVoList = JSON.parseArray(JSONObject.toJSONString(ajaxResult.get("data")), SysDictDataVo.class);
if(sysDictDataVoList != null && sysDictDataVoList.size()>0){
sysDictDataVoList.stream().filter(info -> ObjectUtil.equal(info.getDictValue(), billManageDO.getTailCalculationCode())).findAny().ifPresent(sysDictDataVo -> billManageDO.setTailCalculationName(sysDictDataVo.getDictLabel()));
}
}
}
}
/**
* 更新账单信息(收款)
*/
public Boolean updateBillSettlementInfo(ReceiptManageDO receiptManageDO) {
Set<String> bills = Stream.of(receiptManageDO.getBillManageIds().split(",")).collect(Collectors.toSet());
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillManage::getBillManageId,bills);
List<BillManage> billManageList = queryListLambda(queryWrapper);
if(billManageList ==null || billManageList.size()==0){
throw new ServiceException("账单信息未找到");
}
List<ReceiptDetailDTO> receiptDetailPOList = receiptManageDO.getReceiptDetailDTOList();
List<BillManage> billManageListSave = new ArrayList<>();
List<BillOperationLog> billOperationLogSave = new ArrayList<>();
billManageList.forEach(billManage -> {
BillManage billManageSave = new BillManage();
billManageSave.setBillManageId(billManage.getBillManageId());
//计算已收,未收金额,账单已收金额 = 结算单明细收款金额 + 收款优惠金额
BigDecimal collectedDiscount = receiptDetailPOList.stream().filter(receiptDetailPO -> ObjectUtil.equal(receiptDetailPO.getBillManageId(),billManage.getBillManageId())).map(ReceiptDetailDTO::getCollectedDiscount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal collectedAmount = receiptDetailPOList.stream().filter(receiptDetailPO -> ObjectUtil.equal(receiptDetailPO.getBillManageId(),billManage.getBillManageId())).map(ReceiptDetailDTO::getCollectedAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
BigDecimal all = collectedAmount.add(collectedDiscount);
billManageSave.setBillAmountSettlement(billManage.getBillAmountSettlement().add(all));
//计算账单未收,账单金额 - 已收金额
billManageSave.setBillAmountUnsettled(billManage.getBillAmount().subtract(billManageSave.getBillAmountSettlement()));
//计算实收金额
billManageSave.setActualReceivedAmount(billManage.getActualReceivedAmount().add(collectedAmount));
//计算结算单优惠金额
billManageSave.setSettlementDiscountsAmount(billManage.getSettlementDiscountsAmount().add(collectedDiscount));
//如果未收金额为0 ,则更新状态到已收款,如果未收金额不为0 ,则更新状态到部分收款
if(billManageSave.getBillAmountUnsettled().compareTo(BigDecimal.ZERO)==0){
billManageSave.setBillState(5);
}else {
billManageSave.setBillState(4);
}
billManageListSave.add(billManageSave);
//保存账单操作记录
BillOperationLog billOperationLog = new BillOperationLog();
billOperationLog.setBillManageId(billManage.getBillManageId());
billOperationLog.setOperationInfo(StringUtils.format(BillLogsConstants.collection_bill_text,receiptManageDO.getCollectionNum(),all,collectedAmount,collectedDiscount));
billOperationLog.setOperationType(7);
billOperationLogSave.add(billOperationLog);
});
Boolean three = billOperationLogDomainService.insertBatch(billOperationLogSave);
Boolean flag = billManageService.updateBatchById(billManageListSave);
return flag && three;
}
/**
* 根据账单id查询账单信息
*/
public BillManagePO getDetailsById(Long billManageId) {
BillManagePO result = billManageService.getInfo(billManageId);
//查询账单关联流水列表
List<BillingStatementPO> billingStatementPOList = billingStatementDomainService.getDetailsByManageId(billManageId);
result.setBillingStatementPOList(billingStatementPOList);
return result;
}
/**
* 保存结算单退款后账单的操作状态
*/
public Boolean saveRefundLogs(List<ReceiptDetail> receiptDetails) {
List<Long> billManageIds = receiptDetails.stream().map(ReceiptDetail::getBillManageId).collect(Collectors.toList());
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillManage::getBillManageId,billManageIds);
List<BillManage> billManageList = billManageService.list(queryWrapper);
List<BillOperationLog> billOperationLogSave = new ArrayList<>();
for (ReceiptDetail receiptDetail : receiptDetails) {
BillManage billManage = billManageList.stream().filter(billManage1 -> ObjectUtil.equal(billManage1.getBillManageId(),receiptDetail.getBillManageId())).findAny().orElse(null);
if(null == billManage){
throw new ServiceException("结算单" + receiptDetail.getBillNumber() + "账单信息未找到,请重试");
}
//保存账单操作记录
BillOperationLog billOperationLog = new BillOperationLog();
billOperationLog.setBillManageId(billManage.getBillManageId());
billOperationLog.setOperationInfo(StringUtils.format(BillLogsConstants.refund_bill_text,receiptDetail.getCollectionNum(),receiptDetail.getCollectedAmount()));
billOperationLog.setOperationType(10);
billOperationLogSave.add(billOperationLog);
}
return billOperationLogDomainService.insertBatch(billOperationLogSave);
}
/**
* 更改账单状态(付款)
*/
public Boolean updateBillPaymentInfo(PaymentOrderDO paymentOrderDO) {
Set<String> bills = Stream.of(paymentOrderDO.getBillManageIds()).collect(Collectors.toSet());
LambdaQueryWrapper<BillManage> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillManage::getBillManageId,bills);
List<BillManage> billManageList = queryListLambda(queryWrapper);
if(billManageList ==null || billManageList.size()==0){
throw new ServiceException("账单信息未找到");
}
List<PaymentOrderDetailsDTO> paymentOrderDetailsDTOList = paymentOrderDO.getPaymentOrderDetailsDTOList();
List<BillManage> billManageListSave = new ArrayList<>();
List<BillOperationLog> billOperationLogSave = new ArrayList<>();
billManageList.forEach(billManage -> {
PaymentOrderDetailsDTO paymentOrderDetailsDTO = paymentOrderDetailsDTOList.stream().filter(paymentOrderDetailsDTO1 -> ObjectUtil.equal(paymentOrderDetailsDTO1.getBillManageId(),billManage.getBillManageId())).findAny().orElse(null);
if(null == paymentOrderDetailsDTO){
throw new ServiceException("账单信息未找到");
}
BillManage billManageSave = new BillManage();
billManageSave.setBillManageId(billManage.getBillManageId());
//计算付款金额
BigDecimal paymentAmount = paymentOrderDetailsDTO.getPaymentAmount();
BigDecimal all = billManage.getBillAmountSettlement().add(paymentAmount);
billManageSave.setBillAmountSettlement(all);
//计算账单未付,账单金额 - 已付金额
billManageSave.setBillAmountUnsettled(billManage.getBillAmount().subtract(billManageSave.getBillAmountSettlement()));
//如果未收金额为0 ,则更新状态到已收款,如果未收金额不为0 ,则更新状态到部分收款
if(billManageSave.getBillAmountUnsettled().compareTo(BigDecimal.ZERO)==0){
billManageSave.setBillState(5);
}else {
billManageSave.setBillState(4);
}
billManageListSave.add(billManageSave);
//保存账单操作记录
BillOperationLog billOperationLog = new BillOperationLog();
billOperationLog.setBillManageId(billManage.getBillManageId());
billOperationLog.setOperationInfo(StringUtils.format(BillLogsConstants.payment_bill_text,paymentOrderDetailsDTO.getPaymentOrderNum(),paymentAmount));
billOperationLog.setOperationType(11);
billOperationLogSave.add(billOperationLog);
});
Boolean three = billOperationLogDomainService.insertBatch(billOperationLogSave);
Boolean flag = billManageService.updateBatchById(billManageListSave);
return flag && three;
}
/**
* 批量更新账单
*/
public Boolean updateBatchById(List<BillManage> billManageList) {
return billManageService.updateBatchById(billManageList);
}
/**
* 批量生成账单,账单浏览
*/
public BillManagePO getBillBrowse(List<BillingStatementPO> value) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillManagePO billManagePO = new BillManagePO();
//将value中的id用逗号拼接成字符串
Set<Long> billingStatementIds = value.stream().map(BillingStatementPO::getBillingStatementId).collect(Collectors.toSet());
//转成字符串
String billingStatementIdsStr = billingStatementIds.stream().map(String::valueOf).collect(Collectors.joining(","));
billManagePO.setBillingStatementIds(billingStatementIdsStr);
billManagePO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billManagePO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billManagePO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
billManagePO.setBillType(value.get(0).getAccountExpenseType());
billManagePO.setBelongModule(value.get(0).getBelongModule());
billManagePO.setBelongModuleCode(value.get(0).getBelongModuleCode());
billManagePO.setSettlementCustomersId(value.get(0).getSettlementCustomersId());
billManagePO.setSettlementEntity(value.get(0).getSettlementEntity());
billManagePO.setSettlementCustomersCode(value.get(0).getSettlementCustomersCode());
//将所有的流水金额相加
billManagePO.setBillTotalAmount(value.stream().map(BillingStatementPO::getBillingAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
billManagePO.setBillAmount(billManagePO.getBillTotalAmount());
return billManagePO;
}
public List<BillManage> billAnalysisList(QueryWrapper<BillManage> queryWrapper) {
return billManageService.list(queryWrapper);
}
}
@@ -0,0 +1,54 @@
package com.mhd.bms.domain.billOperationLog.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 账单操作日志对象 bill_operation_log
*
* @author gen
* @date 2024-07-09
*/
@Data
public class BillOperationLog extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单操作日志id")
@TableId(type = IdType.AUTO)
private Long billOperationLogId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
private Integer operationType;
@ApiModelProperty("操作信息")
@Excel(name = "操作信息")
private String operationInfo;
}
@@ -0,0 +1,48 @@
package com.mhd.bms.domain.billOperationLog.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import java.util.List;
/**
* 账单操作日志Service接口
*
* @author gen
* @date 2024-07-09
*/
public interface IBillOperationLogService extends IService<BillOperationLog>
{
/**
* 分页查询账单操作日志列表
*/
public List<BillOperationLogPO> queryList(BillOperationLogDO billOperationLogDO);
/**
* 新增账单操作日志
*/
public Boolean insert(BillOperationLogDO billOperationLogDO);
/**
* 修改账单操作日志
*/
public Boolean update(BillOperationLogDO billOperationLogDO);
/**
* 批量删除账单操作日志
*/
public Boolean delete(Long[] billOperationLogIds);
/**
* 查询账单操作日志
*/
public BillOperationLogPO getInfo(Long billOperationLogId);
/**
* 查询账单操作日志记录表
*/
List<BillOperationLogPO> getDetailsById(Long billManageId);
}
@@ -0,0 +1,23 @@
package com.mhd.bms.domain.billOperationLog.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import org.apache.ibatis.annotations.Param;
/**
* 账单操作日志Mapper接口
*
* @author gen
* @date 2024-07-09
*/
public interface BillOperationLogMapper extends BaseMapper<BillOperationLog>
{
/**
* 查询账单操作日志列表
*/
public List<BillOperationLogPO> queryList(@Param("billOperationLogDO") BillOperationLogDO billOperationLogDO);
List<BillOperationLogPO> getDetailsById(@Param("billManageIds") Long billManageId);
}
@@ -0,0 +1,89 @@
package com.mhd.bms.domain.billOperationLog.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.facade.IBillOperationLogService;
import com.mhd.bms.domain.billOperationLog.repository.mapper.BillOperationLogMapper;
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 账单操作日志Service业务层处理
*
* @author gen
* @date 2024-07-09
*/
@Service
public class BillOperationLogImpl extends ServiceImpl<BillOperationLogMapper, BillOperationLog> implements IBillOperationLogService{
@Autowired
private BillOperationLogMapper billOperationLogMapper;
/**
* 查询账单操作日志列表
*/
@Override
public List<BillOperationLogPO> queryList(BillOperationLogDO billOperationLogDO)
{
return billOperationLogMapper.queryList(billOperationLogDO);
}
/**
* 新增账单操作日志
*/
@Override
public Boolean insert(BillOperationLogDO billOperationLogDO) {
BillOperationLog billOperationLog = new BillOperationLog();
BeanUtils.copyProperties(billOperationLogDO,billOperationLog);
return this.save(billOperationLog);
}
/**
* 修改账单操作日志
*/
@Override
public Boolean update(BillOperationLogDO billOperationLogDO) {
BillOperationLog billOperationLog = new BillOperationLog();
BeanUtils.copyProperties(billOperationLogDO,billOperationLog);
return this.updateById(billOperationLog);
}
/**
* 批量删除账单操作日志
*/
@Override
public Boolean delete(Long[] billOperationLogIds ) {
List<BillOperationLog> list = new ArrayList<>();
for (Long id : billOperationLogIds) {
BillOperationLog billOperationLog = new BillOperationLog();
billOperationLog.setBillOperationLogId(id);
billOperationLog.setDelFlag(2);
list.add(billOperationLog);
}
return this.updateBatchById(list);
}
/**
* 修改账单操作日志
*/
@Override
public BillOperationLogPO getInfo(Long billOperationLogId) {
BillOperationLog billOperationLog = this.getById(billOperationLogId);
BillOperationLogPO billOperationLogPO = new BillOperationLogPO();
BeanUtils.copyProperties(billOperationLog,billOperationLogPO);
return billOperationLogPO;
}
/**
* 查询账单操作日志记录表
*/
@Override
public List<BillOperationLogPO> getDetailsById(Long billManageId) {
return billOperationLogMapper.getDetailsById(billManageId);
}
}
@@ -0,0 +1,54 @@
package com.mhd.bms.domain.billOperationLog.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 账单操作日志对象 bill_operation_log
*
* @author gen
* @date 2024-07-09
*/
@Data
@ApiModel(value = "账单操作日志对象", description = "账单操作日志响应对象")
public class BillOperationLogPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单操作日志id")
private Long billOperationLogId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
private Integer operationType;
@ApiModelProperty("操作信息")
@Excel(name = "操作信息")
private String operationInfo;
}
@@ -0,0 +1,61 @@
package com.mhd.bms.domain.billOperationLog.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
import java.util.Set;
/**
* 账单操作日志对象 bill_operation_log
*
* @author gen
* @date 2024-07-09
*/
@Data
public class BillOperationLogDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("账单操作日志id")
private Long billOperationLogId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("账单管理id")
@Excel(name = "账单管理id")
private Long billManageId;
@ApiModelProperty("操作类型(1-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款)")
@Excel(name = "操作类型", readConverterExp = "1=-创建账单,2-调整账单,3-确认账单,4-发起对账,5-客户确认,6-财务审核,7-收款,8-作废账单,9-删除账单,10-退款,11-付款")
private Integer operationType;
@ApiModelProperty("操作信息")
@Excel(name = "操作信息")
private String operationInfo;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "账单管理id集合")
private Set<String> billManageIdSet;
}
@@ -0,0 +1,164 @@
package com.mhd.bms.domain.billOperationLog.service;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.billOperationLog.entity.BillOperationLog;
import com.mhd.bms.domain.billOperationLog.repository.facade.IBillOperationLogService;
import com.mhd.bms.domain.billOperationLog.repository.po.BillOperationLogPO;
import com.mhd.bms.domain.billOperationLog.repository.todo.BillOperationLogDO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 账单操作日志
*
* @author gen
* @date 2024-07-09
*/
@Service
@Slf4j
public class BillOperationLogDomainService {
@Autowired
private IBillOperationLogService billOperationLogService;
/**
* 分页查询账单操作日志列表
*/
public List<BillOperationLogPO> queryList(BillOperationLogDO billOperationLogDO) {
return billOperationLogService.queryList(billOperationLogDO);
}
/**
* 新增账单操作日志
*/
public Boolean insert(BillOperationLogDO billOperationLogDO) {
return billOperationLogService.insert(billOperationLogDO);
}
/**
* 修改账单操作日志
*/
public Boolean update(BillOperationLogDO billOperationLogDO) {
return billOperationLogService.update(billOperationLogDO);
}
/**
* 批量删除账单操作日志
*/
public Boolean delete(Long[] billOperationLogIds) {
return billOperationLogService.delete(billOperationLogIds);
}
/**
* 获取账单操作日志详细信息
*/
public BillOperationLogPO getInfo(Long billOperationLogId)
{
return billOperationLogService.getInfo(billOperationLogId);
}
/**
* 保存操作日志
*/
public Boolean saveBillOperationLog(BillOperationLogDO billOperationLogDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
String userName = loginUser.getUserPo().getUserName();
// 获取登录人id
Long userId = loginUser.getUserid();
billOperationLogDO.setCreateByName(userName);
billOperationLogDO.setUpdateByName(userName);
billOperationLogDO.setCreateTime(new Date());
billOperationLogDO.setUpdateTime(new Date());
billOperationLogDO.setDelFlag(1);
billOperationLogDO.setCreateBy(userId);
billOperationLogDO.setUpdateBy(userId);
billOperationLogDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billOperationLogDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billOperationLogDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return billOperationLogService.insert(billOperationLogDO);
}
/**
* 批量保存操作日志
*/
public Boolean saveBillOperationLogBatch(BillOperationLogDO billOperationLogDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(billOperationLogDO.getBillManageIdSet()==null || billOperationLogDO.getBillManageIdSet().size()==0){
throw new ServiceException("账单集合不能为空");
}
String userName = loginUser.getUserPo().getUserName();
// 获取登录人id
Long userId = loginUser.getUserid();
BillOperationLogDO common = new BillOperationLogDO();
common.setCreateByName(userName);
common.setUpdateByName(userName);
common.setCreateTime(new Date());
common.setUpdateTime(new Date());
common.setDelFlag(1);
common.setCreateBy(userId);
common.setUpdateBy(userId);
common.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
common.setOrganizationId(loginUser.getUserPo().getOrganizationId());
common.setOrganizationName(loginUser.getUserPo().getOrganizationName());
common.setOperationType(billOperationLogDO.getOperationType());
common.setOperationInfo(billOperationLogDO.getOperationInfo());
List<BillOperationLog> saveList = new ArrayList<>();
for (String billManageId : billOperationLogDO.getBillManageIdSet()) {
BillOperationLog save = new BillOperationLog();
BeanUtils.copyProperties(common, save);
save.setBillManageId(Long.valueOf(billManageId));
saveList.add(save);
}
return billOperationLogService.saveBatch(saveList);
}
/**
* 批量保存数据
* @param billOperationLogSave
* @return
*/
public Boolean insertBatch(List<BillOperationLog> billOperationLogSave) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
for (BillOperationLog billOperationLog : billOperationLogSave) {
billOperationLog.setCreateByName(loginUser.getUserPo().getUserName());
billOperationLog.setCreateTime(new Date());
billOperationLog.setCreateBy(loginUser.getUserid());
billOperationLog.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billOperationLog.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billOperationLog.setOrganizationName(loginUser.getUserPo().getOrganizationName());
}
return billOperationLogService.saveBatch(billOperationLogSave);
}
/**
* 查询账单操作日志记录表
*/
public List<BillOperationLogPO> getDetailsById(Long billManageId) {
return billOperationLogService.getDetailsById(billManageId);
}
}
@@ -0,0 +1,64 @@
package com.mhd.bms.domain.billingRules.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 计费参数对象 billing_params
*
* @author gen
* @date 2024-07-12
*/
@Data
public class BillingParams extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费参数id")
@TableId(type = IdType.AUTO)
private Long billingParamsId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("计费参数表名称")
@Excel(name = "计费参数表名称")
private String billingParamsName;
@ApiModelProperty("说明")
@Excel(name = "说明")
private String billingIllustrate;
@ApiModelProperty("计费参数json串")
@Excel(name = "计费参数json串")
private String billingParamsJson;
@ApiModelProperty("计费参数输出json串")
@Excel(name = "计费参数输出json串")
private String billingOutputJson;
@ApiModelProperty("预置规则json串")
@Excel(name = "预置规则json串")
private String preSetRules;
@ApiModelProperty("计费规则id")
private Long billingRulesId;
}
@@ -0,0 +1,94 @@
package com.mhd.bms.domain.billingRules.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 计费规则对象 billing_rules
*
* @author gen
* @date 2024-07-12
*/
@Data
public class BillingRules extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费规则id")
@TableId(type = IdType.AUTO)
private Long billingRulesId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("规则说明")
@Excel(name = "规则说明", readConverterExp = "规则说明")
private String billingRulesIllustrate;
@ApiModelProperty("状态(1-开启,2-关闭)")
@Excel(name = "状态", readConverterExp = "1=-开启,2-关闭")
private Integer billingRulesState;
@ApiModelProperty("计费公式")
@Excel(name = "计费公式")
private String billingFormula;
@ApiModelProperty("计费规则编码")
@Excel(name = "计费规则编码")
private String billingRulesCode;
@ApiModelProperty("计费规则名称")
@Excel(name = "计费规则名称", readConverterExp = "计费规则名称")
private String billingRulesName;
}
@@ -0,0 +1,48 @@
package com.mhd.bms.domain.billingRules.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billingRules.entity.BillingParams;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import java.util.List;
/**
* 计费参数Service接口
*
* @author gen
* @date 2024-07-12
*/
public interface IBillingParamsService extends IService<BillingParams>
{
/**
* 分页查询计费参数列表
*/
public List<BillingParamsPO> queryList(BillingParamsDO billingParamsDO);
/**
* 新增计费参数
*/
public Boolean insert(BillingParamsDO billingParamsDO);
/**
* 修改计费参数
*/
public Boolean update(BillingParamsDO billingParamsDO);
/**
* 批量删除计费参数
*/
public Boolean delete(Long[] billingParamsIds);
/**
* 查询计费参数
*/
public BillingParamsPO getInfo(Long billingParamsId);
/**
* 根据计费规则id查询计费参数
*/
List<BillingParamsPO> queryListByRulesId(Long billingRulesId);
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.billingRules.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billingRules.entity.BillingRules;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import java.util.List;
/**
* 计费规则Service接口
*
* @author gen
* @date 2024-07-12
*/
public interface IBillingRulesService extends IService<BillingRules>
{
/**
* 分页查询计费规则列表
*/
public List<BillingRulesPO> queryList(BillingRulesDO billingRulesDO);
/**
* 新增计费规则
*/
public Boolean insert(BillingRulesDO billingRulesDO);
/**
* 修改计费规则
*/
public Boolean update(BillingRulesDO billingRulesDO);
/**
* 批量删除计费规则
*/
public Boolean delete(Long[] billingRulesIds);
/**
* 查询计费规则
*/
public BillingRulesPO getInfo(Long billingRulesId);
}
@@ -0,0 +1,23 @@
package com.mhd.bms.domain.billingRules.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billingRules.entity.BillingParams;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import org.apache.ibatis.annotations.Param;
/**
* 计费参数Mapper接口
*
* @author gen
* @date 2024-07-12
*/
public interface BillingParamsMapper extends BaseMapper<BillingParams>
{
/**
* 查询计费参数列表
*/
public List<BillingParamsPO> queryList(BillingParamsDO billingParamsDO);
List<BillingParamsPO> queryListByRulesId(@Param("billingRulesId") Long billingRulesId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.billingRules.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billingRules.entity.BillingRules;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import org.apache.ibatis.annotations.Param;
/**
* 计费规则Mapper接口
*
* @author gen
* @date 2024-07-12
*/
public interface BillingRulesMapper extends BaseMapper<BillingRules>
{
/**
* 查询计费规则列表
*/
public List<BillingRulesPO> queryList(@Param("billingRulesDO") BillingRulesDO billingRulesDO);
}
@@ -0,0 +1,86 @@
package com.mhd.bms.domain.billingRules.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billingRules.entity.BillingParams;
import com.mhd.bms.domain.billingRules.repository.facade.IBillingParamsService;
import com.mhd.bms.domain.billingRules.repository.mapper.BillingParamsMapper;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 计费参数Service业务层处理
*
* @author gen
* @date 2024-07-12
*/
@Service
public class BillingParamsImpl extends ServiceImpl<BillingParamsMapper, BillingParams> implements IBillingParamsService {
@Autowired
private BillingParamsMapper billingParamsMapper;
/**
* 查询计费参数列表
*/
@Override
public List<BillingParamsPO> queryList(BillingParamsDO billingParamsDO)
{
return billingParamsMapper.queryList(billingParamsDO);
}
/**
* 新增计费参数
*/
@Override
public Boolean insert(BillingParamsDO billingParamsDO) {
BillingParams billingParams = new BillingParams();
BeanUtils.copyProperties(billingParamsDO,billingParams);
return this.save(billingParams);
}
/**
* 修改计费参数
*/
@Override
public Boolean update(BillingParamsDO billingParamsDO) {
BillingParams billingParams = new BillingParams();
BeanUtils.copyProperties(billingParamsDO,billingParams);
return this.updateById(billingParams);
}
/**
* 批量删除计费参数
*/
@Override
public Boolean delete(Long[] billingParamsIds ) {
List<BillingParams> list = new ArrayList<>();
for (Long id : billingParamsIds) {
BillingParams billingParams = new BillingParams();
billingParams.setBillingParamsId(id);
billingParams.setDelFlag(2);
list.add(billingParams);
}
return this.updateBatchById(list);
}
/**
* 修改计费参数
*/
@Override
public BillingParamsPO getInfo(Long billingParamsId) {
BillingParams billingParams = this.getById(billingParamsId);
BillingParamsPO billingParamsPO = new BillingParamsPO();
BeanUtils.copyProperties(billingParams,billingParamsPO);
return billingParamsPO;
}
@Override
public List<BillingParamsPO> queryListByRulesId(Long billingRulesId) {
return billingParamsMapper.queryListByRulesId(billingRulesId);
}
}
@@ -0,0 +1,83 @@
package com.mhd.bms.domain.billingRules.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billingRules.entity.BillingRules;
import com.mhd.bms.domain.billingRules.repository.facade.IBillingRulesService;
import com.mhd.bms.domain.billingRules.repository.mapper.BillingRulesMapper;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 计费规则Service业务层处理
*
* @author gen
* @date 2024-07-12
*/
@Service
public class BillingRulesImpl extends ServiceImpl<BillingRulesMapper, BillingRules> implements IBillingRulesService{
@Autowired
private BillingRulesMapper billingRulesMapper;
/**
* 查询计费规则列表
*/
@Override
public List<BillingRulesPO> queryList(BillingRulesDO billingRulesDO)
{
return billingRulesMapper.queryList(billingRulesDO);
}
/**
* 新增计费规则
*/
@Override
public Boolean insert(BillingRulesDO billingRulesDO) {
BillingRules billingRules = new BillingRules();
BeanUtils.copyProperties(billingRulesDO,billingRules);
boolean flag = this.save(billingRules);
billingRulesDO.setBillingRulesId(billingRules.getBillingRulesId());
return flag;
}
/**
* 修改计费规则
*/
@Override
public Boolean update(BillingRulesDO billingRulesDO) {
BillingRules billingRules = new BillingRules();
BeanUtils.copyProperties(billingRulesDO,billingRules);
return this.updateById(billingRules);
}
/**
* 批量删除计费规则
*/
@Override
public Boolean delete(Long[] billingRulesIds ) {
List<BillingRules> list = new ArrayList<>();
for (Long id : billingRulesIds) {
BillingRules billingRules = new BillingRules();
billingRules.setBillingRulesId(id);
billingRules.setDelFlag(2);
list.add(billingRules);
}
return this.updateBatchById(list);
}
/**
* 修改计费规则
*/
@Override
public BillingRulesPO getInfo(Long billingRulesId) {
BillingRules billingRules = this.getById(billingRulesId);
BillingRulesPO billingRulesPO = new BillingRulesPO();
BeanUtils.copyProperties(billingRules,billingRulesPO);
return billingRulesPO;
}
}
@@ -0,0 +1,91 @@
package com.mhd.bms.domain.billingRules.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 计费参数对象 billing_params
*
* @author gen
* @date 2024-07-12
*/
@Data
@ApiModel(value = "计费参数对象", description = "计费参数响应对象")
public class BillingParamsPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费参数id")
private Long billingParamsId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("计费参数表名称")
@Excel(name = "计费参数表名称")
private String billingParamsName;
@ApiModelProperty("说明")
@Excel(name = "说明")
private String billingIllustrate;
/**
* {
* "fields":"参与字段",
* "chargingId":"计费标识P1、P2",
* "ladderType":"阶梯类型(1-固定参数,2-无阶梯,3-到达阶梯,4-累进阶梯)",
* "ladderRule":"阶梯规则(1-左开右闭,2-左闭右开)",
* "ladderNum":"阶梯值",
* "sort":"排序"
* }
*/
@ApiModelProperty("计费参数json串")
@Excel(name = "计费参数json串")
private String billingParamsJson;
/**
*{
* "outFields":"输出字段",
* "outChargingId":"输出计费标识",
* "fieIdsType":"字段类型(1-整数,2-浮点数,3-时间)",
* "sort":"排序"
* }
*/
@ApiModelProperty("计费参数输出json串")
@Excel(name = "计费参数输出json串")
private String billingOutputJson;
/**
* {
* "fieIds1":"字段1",
* "fieIds2":"字段2",
* "fieIdsn":"字段N",
* "outFieIds1":"输出字段1",
* "outFieIds2":"输出字段2",
* "outFieIdsn":"输出字段n"
* }
*/
@ApiModelProperty("预置规则json串")
@Excel(name = "预置规则json串")
private String preSetRules;
@ApiModelProperty("计费规则id")
private Long billingRulesId;
}
@@ -0,0 +1,97 @@
package com.mhd.bms.domain.billingRules.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.List;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 计费规则对象 billing_rules
*
* @author gen
* @date 2024-07-12
*/
@Data
@ApiModel(value = "计费规则对象", description = "计费规则响应对象")
public class BillingRulesPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费规则id")
private Long billingRulesId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("规则说明")
@Excel(name = "规则说明", readConverterExp = "规则说明")
private String billingRulesIllustrate;
@ApiModelProperty("状态(1-开启,2-关闭)")
@Excel(name = "状态", readConverterExp = "1=-开启,2-关闭")
private Integer billingRulesState;
@ApiModelProperty("计费公式")
@Excel(name = "计费公式")
private String billingFormula;
@ApiModelProperty("计费规则编码")
@Excel(name = "计费规则编码")
private String billingRulesCode;
@ApiModelProperty("计费规则名称")
@Excel(name = "计费规则名称", readConverterExp = "计费规则名称")
private String billingRulesName;
@ApiModelProperty("计费参数明细列表")
private List<BillingParamsPO> billingParamsPOList;
}
@@ -0,0 +1,68 @@
package com.mhd.bms.domain.billingRules.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 计费参数对象 billing_params
*
* @author gen
* @date 2024-07-12
*/
@Data
public class BillingParamsDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费参数id")
private Long billingParamsId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("计费参数表名称")
@Excel(name = "计费参数表名称")
private String billingParamsName;
@ApiModelProperty("说明")
@Excel(name = "说明")
private String billingIllustrate;
@ApiModelProperty("计费参数json串")
@Excel(name = "计费参数json串")
private String billingParamsJson;
@ApiModelProperty("计费参数输出json串")
@Excel(name = "计费参数输出json串")
private String billingOutputJson;
@ApiModelProperty("预置规则json串")
@Excel(name = "预置规则json串")
private String preSetRules;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("计费规则id")
private Long billingRulesId;
}
@@ -0,0 +1,107 @@
package com.mhd.bms.domain.billingRules.repository.todo;
import com.mhd.bms.interfaces.dto.billingRules.BillingParamsDTO;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 计费规则对象 billing_rules
*
* @author gen
* @date 2024-07-12
*/
@Data
public class BillingRulesDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费规则id")
private Long billingRulesId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("规则说明")
@Excel(name = "规则说明", readConverterExp = "规则说明")
private String billingRulesIllustrate;
@ApiModelProperty("状态(1-开启,2-关闭)")
@Excel(name = "状态", readConverterExp = "1=-开启,2-关闭")
private Integer billingRulesState;
@ApiModelProperty("计费公式")
@Excel(name = "计费公式")
private String billingFormula;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "计费参数集合")
private List<BillingParamsDTO> billingParamsDTOList;
@ApiModelProperty("计费规则编码")
@Excel(name = "计费规则编码")
private String billingRulesCode;
@ApiModelProperty("计费规则名称")
@Excel(name = "计费规则名称", readConverterExp = "计费规则名称")
private String billingRulesName;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
}
@@ -0,0 +1,139 @@
package com.mhd.bms.domain.billingRules.service;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.billingRules.entity.BillingParams;
import com.mhd.bms.domain.billingRules.repository.facade.IBillingParamsService;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import com.mhd.bms.interfaces.dto.billingRules.BillingParamsDTO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 计费参数
*
* @author gen
* @date 2024-07-12
*/
@Service
@Slf4j
public class BillingParamsDomainService {
@Autowired
private IBillingParamsService billingParamsService;
/**
* 分页查询计费参数列表
*/
public List<BillingParamsPO> queryList(BillingParamsDO billingParamsDO) {
return billingParamsService.queryList(billingParamsDO);
}
/**
* 新增计费参数
*/
public Boolean insert(BillingParamsDO billingParamsDO) {
return billingParamsService.insert(billingParamsDO);
}
/**
* 修改计费参数
*/
public Boolean update(BillingParamsDO billingParamsDO) {
return billingParamsService.update(billingParamsDO);
}
/**
* 批量删除计费参数
*/
public Boolean delete(Long[] billingParamsIds) {
return billingParamsService.delete(billingParamsIds);
}
/**
* 获取计费参数详细信息
*/
public BillingParamsPO getInfo(Long billingParamsId)
{
return billingParamsService.getInfo(billingParamsId);
}
/**
* 保存计费参数
*/
public boolean saveBillParam(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
List<BillingParamsDTO> billingParamsDTOList = billingRulesDO.getBillingParamsDTOList();
List<BillingParams> billingParamsList = new ArrayList<>();
for (BillingParamsDTO billingParamsDTO : billingParamsDTOList) {
BillingParams billingParams = new BillingParams();
BeanUtils.copyProperties(billingParamsDTO,billingParams);
billingParams.setBillingRulesId(billingRulesDO.getBillingRulesId());
billingParams.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingParams.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingParams.setOrganizationName(loginUser.getUserPo().getOrganizationName());
billingParams.setCreateBy(loginUser.getUserPo().getUserId());
billingParams.setCreateByName(loginUser.getUserPo().getUserName());
billingParams.setCreateTime(new Date());
billingParamsList.add(billingParams);
}
return billingParamsService.saveBatch(billingParamsList);
}
/**
* 修改计费参数
*/
public boolean updateBillParam(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
List<BillingParamsDTO> billingParamsDTOList = billingRulesDO.getBillingParamsDTOList();
List<BillingParams> billingParamsList = new ArrayList<>();
for (BillingParamsDTO billingParamsDTO : billingParamsDTOList) {
BillingParams billingParams = new BillingParams();
BeanUtils.copyProperties(billingParamsDTO,billingParams);
billingParams.setBillingRulesId(billingRulesDO.getBillingRulesId());
if(billingParams.getBillingParamsId()==null){
billingParams.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingParams.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingParams.setOrganizationName(loginUser.getUserPo().getOrganizationName());
billingParams.setCreateBy(loginUser.getUserPo().getUserId());
billingParams.setCreateByName(loginUser.getUserPo().getUserName());
billingParams.setCreateTime(new Date());
}
billingParamsList.add(billingParams);
}
return billingParamsService.saveOrUpdateBatch(billingParamsList);
}
/**
* 根据计费规则id查询计费参数表信息
* @param billingRulesId
* @return
*/
public List<BillingParamsPO> getInfoByRuleId(Long billingRulesId) {
return billingParamsService.queryListByRulesId(billingRulesId);
}
}
@@ -0,0 +1,184 @@
package com.mhd.bms.domain.billingRules.service;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.billingRules.entity.BillingRules;
import com.mhd.bms.domain.billingRules.repository.facade.IBillingParamsService;
import com.mhd.bms.domain.billingRules.repository.facade.IBillingRulesService;
import com.mhd.bms.domain.billingRules.repository.po.BillingParamsPO;
import com.mhd.bms.domain.billingRules.repository.po.BillingRulesPO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingParamsDO;
import com.mhd.bms.domain.billingRules.repository.todo.BillingRulesDO;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.service.DocumentTypeDomainService;
import com.mhd.bms.infrastructure.feign.vo.ExpenseAccountPO;
import com.mhd.bms.interfaces.dto.billingRules.BillingRulesDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 计费规则
*
* @author gen
* @date 2024-07-12
*/
@Service
@Slf4j
public class BillingRulesDomainService {
@Autowired
private IBillingRulesService billingRulesService;
@Autowired
private DocumentTypeDomainService documentTypeDomainService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private IBillingParamsService billingParamsService;
/**
* 分页查询计费规则列表
*/
public List<BillingRulesPO> queryList(BillingRulesDO billingRulesDO) {
return billingRulesService.queryList(billingRulesDO);
}
/**
* 新增计费规则
*/
public Boolean insert(BillingRulesDO billingRulesDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
handleData(billingRulesDO);
billingRulesDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingRulesDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingRulesDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return billingRulesService.insert(billingRulesDO);
}
/**
* 处理数据
*/
private void handleData(BillingRulesDO billingRulesDO) {
//根据单据类型id查询单据类型数据,并赋值
if(StringUtils.isNotEmpty(billingRulesDO.getDocumentTypeCode())){
DocumentType documentType = documentTypeDomainService.queryByCode(billingRulesDO.getDocumentTypeCode());
if(null != documentType){
billingRulesDO.setDocumentType(documentType.getDocumentType());
billingRulesDO.setDocumentTypeCode(documentType.getDocumentTypeCode());
}
}
//根据费用类型id查询费用类型对象数据,并赋值
if(StringUtils.isNotEmpty(billingRulesDO.getServiceItemsCode())){
AjaxResult ajaxResult = systemServiceFeign.getServiceItemsByCode(billingRulesDO.getServiceItemsCode());
if(!"200".equals(String.valueOf(ajaxResult.get("code")))) {
throw new ServiceException("费用类型未找到");
}
billingRulesDO.setServiceItemsName(JSONObject.parseObject(JSONObject.toJSONString(ajaxResult.get("data"))).getString("serviceItemsName"));
}
//根据费用科目code查询费用信息,并赋值
if(StringUtils.isNotEmpty(billingRulesDO.getSecondSubjectCode())){
AjaxResult ajaxResult = systemServiceFeign.getSubInfoByCode(billingRulesDO.getSecondSubjectCode());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
ExpenseAccountPO expenseAccountPO = JSON.parseObject(com.alibaba.fastjson2.JSONObject.toJSONString(ajaxResult.get("data")), ExpenseAccountPO.class);
if(null == expenseAccountPO){
throw new ServiceException("费用科目信息未找到");
}
if(expenseAccountPO.getFirstSubjectFlag()==1){
//如果是一级科目
billingRulesDO.setFirstSubjectName(expenseAccountPO.getSubjectName());
billingRulesDO.setFirstSubjectCode(expenseAccountPO.getSubjectCode());
billingRulesDO.setSecondSubjectCode("");
}else {
//不是一级科目
billingRulesDO.setFirstSubjectName(expenseAccountPO.getUpperSubject());
billingRulesDO.setFirstSubjectCode(expenseAccountPO.getUpperSubjectCode());
billingRulesDO.setSecondSubjectCode(expenseAccountPO.getSubjectCode());
billingRulesDO.setSecondSubjectName(expenseAccountPO.getSubjectName());
}
}
}
}
/**
* 修改计费规则
*/
public Boolean update(BillingRulesDO billingRulesDO) {
return billingRulesService.update(billingRulesDO);
}
/**
* 批量删除计费规则
*/
public Boolean delete(Long[] billingRulesIds) {
return billingRulesService.delete(billingRulesIds);
}
/**
* 获取计费规则详细信息
*/
public BillingRulesPO getInfo(Long billingRulesId)
{
return billingRulesService.getInfo(billingRulesId);
}
public BillingRulesPO getInfoByCode(String billingRulesCode) {
BillingRulesPO billingRulesPO = new BillingRulesPO();
LambdaQueryWrapper<BillingRules> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BillingRules::getBillingRulesCode, billingRulesCode);
queryWrapper.eq(BillingRules::getDelFlag, 1);
BillingRules billingRules = billingRulesService.getOne(queryWrapper);
if(billingRules != null){
BeanUtils.copyProperties(billingRules, billingRulesPO);
return billingRulesPO;
}
return null;
}
/**
* 修改计费规则状态
*/
public Boolean changeStates(BillingRulesDTO billingRulesDTO) {
if(billingRulesDTO.getBillingRulesState() ==null || (billingRulesDTO.getBillingRulesState() != 1 && billingRulesDTO.getBillingRulesState() != 2)){
throw new ServiceException("操作类型错误");
}
LambdaUpdateWrapper<BillingRules> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BillingRules::getBillingRulesId,billingRulesDTO.getBillingRulesId());
updateWrapper.eq(BillingRules::getDelFlag,1);
updateWrapper.set(BillingRules::getBillingRulesState,billingRulesDTO.getBillingRulesState());
return billingRulesService.update(updateWrapper);
}
/**
* 根据id查询计费规则信息
*/
public BillingRulesPO getInfoById(Long billingRulesId) {
BillingRulesPO billingRulesPO = billingRulesService.getInfo(billingRulesId);
if(null == billingRulesPO){
throw new ServiceException("计费规则信息未找到");
}
//查询计费参数明细列表
List<BillingParamsPO> billingParamsPOList = billingParamsService.queryListByRulesId(billingRulesId);
billingRulesPO.setBillingParamsPOList(billingParamsPOList);
return billingRulesPO;
}
}
@@ -0,0 +1,192 @@
package com.mhd.bms.domain.billingStatement.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 计费流水对象 billing_statement
*
* @author gen
* @date 2024-06-26
*/
@Data
public class BillingStatement extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费流水id")
@TableId(type = IdType.AUTO)
private Long billingStatementId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("业务日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id", readConverterExp = "服=务项")
private Long serviceItemsManageId;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("流水金额")
@Excel(name = "流水金额")
private BigDecimal billingAmount;
@ApiModelProperty("收支类型(1-应收,2-应付)")
@Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付")
private Integer accountExpenseType;
@ApiModelProperty("流水备注")
@Excel(name = "流水备注")
private String billingRemark;
@ApiModelProperty("业务单号")
@Excel(name = "业务单号")
private String originalBusinessNum;
@ApiModelProperty("业务流水号")
@Excel(name = "业务流水号")
private String businessFlow;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id")
private Long projectManageId;
@ApiModelProperty("流水状态(1-待审核,2-已审核,3-已出账,4-已驳回,5-已作废)")
@Excel(name = "流水状态", readConverterExp = "1=-待审核,2-已审核,3-已出账,4-已驳回,5-已作废")
private Integer billingState;
@ApiModelProperty("红冲状态(1-未红冲,2-已红冲)")
@Excel(name = "红冲状态", readConverterExp = "1=-未红冲,2-已红冲")
private Integer redFlushState;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("红冲原因")
@Excel(name = "红冲原因")
private String redFlushRemark;
@ApiModelProperty("合同类型(1-仓储,2-运输)")
private Integer contractType;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("业务单据记录id")
private Long businessDocumentId;
}
@@ -0,0 +1,59 @@
package com.mhd.bms.domain.billingStatement.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementCollectPO;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementCollectDO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import java.util.List;
/**
* 计费流水Service接口
*
* @author gen
* @date 2024-06-26
*/
public interface IBillingStatementService extends IService<BillingStatement>
{
/**
* 分页查询计费流水列表
*/
public List<BillingStatementPO> queryList(BillingStatementDO billingStatementDO);
/**
* 查询出账汇总
*/
public List<BillingStatementCollectPO> queryCollectList(BillingStatementCollectDO billingStatementCollectDO);
/**
* 查询出账详情
*/
public List<BillingStatementPO> queryDetails(BillingStatementCollectDO bdo);
/**
* 新增计费流水
*/
public Boolean insert(BillingStatementDO billingStatementDO);
/**
* 修改计费流水
*/
public Boolean update(BillingStatementDO billingStatementDO);
/**
* 批量删除计费流水
*/
public Boolean delete(Long[] billingStatementIds);
/**
* 查询计费流水
*/
public BillingStatementPO getInfo(Long billingStatementId);
List<BillingStatementPO> queryPaymentOutList(BillingStatementDO billingStatementDO);
List<BillingStatementPO> getDetailsByManageId(Long billManageId);
}
@@ -0,0 +1,45 @@
package com.mhd.bms.domain.billingStatement.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementCollectPO;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementCollectDO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import org.apache.ibatis.annotations.Param;
/**
* 计费流水Mapper接口
*
* @author gen
* @date 2024-06-26
*/
public interface BillingStatementMapper extends BaseMapper<BillingStatement>
{
/**
* 查询计费流水列表
*/
public List<BillingStatementPO> queryList(@Param("billingStatementDO") BillingStatementDO billingStatementDO);
/**
* 查询出账汇总
*/
public List<BillingStatementCollectPO> queryCollectList(@Param("billingStatementCollectDO") BillingStatementCollectDO billingStatementCollectDO);
/**
* 查询出账详情
*/
public List<BillingStatementPO> queryDetails(@Param("bdo") BillingStatementCollectDO bdo);
/**
* 查询批量出账列表
*/
List<BillingStatementPO> queryPaymentOutList(@Param("billingStatementDO") BillingStatementDO billingStatementDO);
/**
* 根据账单id,查询流水明细列表
*/
List<BillingStatementPO> getDetailsByManageId(@Param("billManageId") Long billManageId);
}
@@ -0,0 +1,109 @@
package com.mhd.bms.domain.billingStatement.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.facade.IBillingStatementService;
import com.mhd.bms.domain.billingStatement.repository.mapper.BillingStatementMapper;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementCollectPO;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementCollectDO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 计费流水Service业务层处理
*
* @author gen
* @date 2024-06-26
*/
@Service
public class BillingStatementImpl extends ServiceImpl<BillingStatementMapper, BillingStatement> implements IBillingStatementService{
@Autowired
private BillingStatementMapper billingStatementMapper;
/**
* 查询计费流水列表
*/
@Override
public List<BillingStatementPO> queryList(BillingStatementDO billingStatementDO)
{
return billingStatementMapper.queryList(billingStatementDO);
}
@Override
public List<BillingStatementCollectPO> queryCollectList(BillingStatementCollectDO billingStatementCollectDO) {
return billingStatementMapper.queryCollectList(billingStatementCollectDO);
}
@Override
public List<BillingStatementPO> queryDetails(BillingStatementCollectDO bdo) {
return billingStatementMapper.queryDetails(bdo);
}
/**
* 新增计费流水
*/
@Override
public Boolean insert(BillingStatementDO billingStatementDO) {
BillingStatement billingStatement = new BillingStatement();
BeanUtils.copyProperties(billingStatementDO,billingStatement);
return this.save(billingStatement);
}
/**
* 修改计费流水
*/
@Override
public Boolean update(BillingStatementDO billingStatementDO) {
BillingStatement billingStatement = new BillingStatement();
BeanUtils.copyProperties(billingStatementDO,billingStatement);
return this.updateById(billingStatement);
}
/**
* 批量删除计费流水
*/
@Override
public Boolean delete(Long[] billingStatementIds ) {
List<BillingStatement> list = new ArrayList<>();
for (Long id : billingStatementIds) {
BillingStatement billingStatement = new BillingStatement();
billingStatement.setBillingStatementId(id);
billingStatement.setDelFlag(2);
list.add(billingStatement);
}
return this.updateBatchById(list);
}
/**
* 修改计费流水
*/
@Override
public BillingStatementPO getInfo(Long billingStatementId) {
BillingStatement billingStatement = this.getById(billingStatementId);
BillingStatementPO billingStatementPO = new BillingStatementPO();
BeanUtils.copyProperties(billingStatement,billingStatementPO);
return billingStatementPO;
}
/**
* 查询批量出账列表
*/
@Override
public List<BillingStatementPO> queryPaymentOutList(BillingStatementDO billingStatementDO) {
return billingStatementMapper.queryPaymentOutList(billingStatementDO);
}
/**
* 根据账单id,查询流水明细列表
*/
@Override
public List<BillingStatementPO> getDetailsByManageId(Long billManageId) {
return billingStatementMapper.getDetailsByManageId(billManageId);
}
}
@@ -0,0 +1,68 @@
package com.mhd.bms.domain.billingStatement.repository.po;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class BillingStatementCollectPO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费流水id")
private Long billingStatementId;
@ApiModelProperty("结算对象")
private String settlementEntity;
@ApiModelProperty("结算代码")
private String settlementCustomersCode;
@ApiModelProperty("费用总额")
private BigDecimal billAmountSum;
@ApiModelProperty("应收汇总")
private BigDecimal receivable;
@ApiModelProperty("应付汇总")
private BigDecimal feesPayable;
@ApiModelProperty("费用类型")
private Integer accountExpenseType;
@ApiModelProperty("流水数量")
private Integer countFee;
@ApiModelProperty("创建时间从")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date businessStartDate;
@ApiModelProperty("创建时间至")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date businessEndDate;
@ApiModelProperty("所属组织")
private String organizationName;
@ApiModelProperty("一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("出账状态")
private Integer billingState;
@ApiModelProperty("合同类型")
@Excel(name = "合同类型")
private String contractType;
@ApiModelProperty("流水状态拼接(统计使用)")
private String billingStateCount;
}
@@ -0,0 +1,199 @@
package com.mhd.bms.domain.billingStatement.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 计费流水对象 billing_statement
*
* @author gen
* @date 2024-06-26
*/
@Data
@ApiModel(value = "计费流水对象", description = "计费流水响应对象")
public class BillingStatementPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费流水id")
private Long billingStatementId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("业务日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id", readConverterExp = "服=务项")
private Long serviceItemsManageId;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("流水金额")
@Excel(name = "流水金额")
private BigDecimal billingAmount;
@ApiModelProperty("收支类型(1-应收,2-应付)")
@Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付")
private Integer accountExpenseType;
@ApiModelProperty("流水备注")
@Excel(name = "流水备注")
private String billingRemark;
@ApiModelProperty("业务单号")
@Excel(name = "业务单号")
private String originalBusinessNum;
@ApiModelProperty("业务流水号")
@Excel(name = "业务流水号")
private String businessFlow;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id")
private Long projectManageId;
@ApiModelProperty("流水状态(1-待审核,2-已审核,3-已出账,4-已驳回,5-已作废)")
@Excel(name = "流水状态", readConverterExp = "1=-待审核,2-已审核,3-已出账,4-已驳回,5-已作废")
private Integer billingState;
@ApiModelProperty("红冲状态(1-未红冲,2-已红冲)")
@Excel(name = "红冲状态", readConverterExp = "1=-未红冲,2-已红冲")
private Integer redFlushState;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("红冲原因")
@Excel(name = "红冲原因")
private String redFlushRemark;
@ApiModelProperty("合同类型(1-仓储,2-运输)")
private Integer contractType;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("业务单据记录id")
private Long businessDocumentId;
@ApiModelProperty("费用总额")
private BigDecimal billingTotalAmount;
@ApiModelProperty("账单优惠金额")
private BigDecimal billingDiscountAmount;
}
@@ -0,0 +1,58 @@
package com.mhd.bms.domain.billingStatement.repository.todo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mhd.common.core.annotation.Excel;
import com.mhd.common.core.web.domain.BaseVOEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.util.Date;
@Data
public class BillingStatementCollectDO extends BaseVOEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费流水id")
private Long billingStatementId;
@ApiModelProperty("结算对象")
private String settlementEntity;
@ApiModelProperty("结算代码")
private String settlementCustomersCode;
@ApiModelProperty("费用总额")
private BigDecimal billAmountSum;
@ApiModelProperty("费用类型")
private Integer accountExpenseType;
@ApiModelProperty("流水数量")
private Integer countFee;
@ApiModelProperty("创建时间从")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date businessStartDate;
@ApiModelProperty("创建时间至")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date businessEndDate;
@ApiModelProperty("所属组织")
private String organizationName;
@ApiModelProperty("一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("出账状态")
private Integer billingState;
@ApiModelProperty("合同类型")
@Excel(name = "合同类型")
private String contractType;
}
@@ -0,0 +1,224 @@
package com.mhd.bms.domain.billingStatement.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
import java.util.Set;
/**
* 计费流水对象 billing_statement
*
* @author gen
* @date 2024-06-26
*/
@Data
public class BillingStatementDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("计费流水id")
private Long billingStatementId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("业务日期")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "业务日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date businessDate;
@ApiModelProperty("周期开始时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleBeginTime;
@ApiModelProperty("周期结束时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "周期结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date cycleEndTime;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code", readConverterExp = "服=务项")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id", readConverterExp = "服=务项")
private Long serviceItemsManageId;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目", readConverterExp = "结=算项")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目", readConverterExp = "结=算项")
private String secondSubjectName;
@ApiModelProperty("流水金额")
@Excel(name = "流水金额")
private BigDecimal billingAmount;
@ApiModelProperty("收支类型(1-应收,2-应付)")
@Excel(name = "收支类型", readConverterExp = "1=-应收,2-应付")
private Integer accountExpenseType;
@ApiModelProperty("流水备注")
@Excel(name = "流水备注")
private String billingRemark;
@ApiModelProperty("业务单号")
@Excel(name = "业务单号")
private String originalBusinessNum;
@ApiModelProperty("业务流水号")
@Excel(name = "业务流水号")
private String businessFlow;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id")
private Long projectManageId;
@ApiModelProperty("流水状态(1-待审核,2-已审核,3-已出账,4-已驳回,5-已作废)")
@Excel(name = "流水状态", readConverterExp = "1=-待审核,2-已审核,3-已出账,4-已驳回,5-已作废")
private Integer billingState;
@ApiModelProperty("红冲状态(1-未红冲,2-已红冲)")
@Excel(name = "红冲状态", readConverterExp = "1=-未红冲,2-已红冲")
private Integer redFlushState;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("计费流水号")
@Excel(name = "计费流水号")
private String billingFlow;
@ApiModelProperty("红冲原因")
@Excel(name = "红冲原因")
private String redFlushRemark;
@ApiModelProperty("查询状态(1-未出账,2-已出账,3-其他)")
private Integer queryState;
@ApiModelProperty("合同类型(1-仓储,2-运输)")
private Integer contractType;
@ApiModelProperty(name = "计费周期查询条件开始日期")
private String businessDateStart;
@ApiModelProperty(name = "计费周期查询条件结束日期")
private String businessDateEnd;
@ApiModelProperty("计费流水ids")
private String billingStatementIds;
@ApiModelProperty("计费流水ids")
private Set<String> billingStatementIdSet;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "修改时间查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "修改时间查询条件结束日期")
private String updateTimeEnd;
@ApiModelProperty("账单管理id")
private Long billManageId;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("业务单据记录id")
private Long businessDocumentId;
}
@@ -0,0 +1,511 @@
package com.mhd.bms.domain.billingStatement.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.billManage.repository.facade.IBillManageService;
import com.mhd.bms.domain.billManage.repository.po.BillManagePO;
import com.mhd.bms.domain.billManage.service.BillManageDomainService;
import com.mhd.bms.domain.billingStatement.entity.BillingStatement;
import com.mhd.bms.domain.billingStatement.repository.facade.IBillingStatementService;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementCollectPO;
import com.mhd.bms.domain.billingStatement.repository.po.BillingStatementPO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementCollectDO;
import com.mhd.bms.domain.billingStatement.repository.todo.BillingStatementDO;
import com.mhd.bms.domain.businessDocument.repository.facade.IBusinessDocumentService;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import com.mhd.bms.domain.settlementCustomers.entity.SettlementCustomers;
import com.mhd.bms.domain.settlementCustomers.service.SettlementCustomersDomainService;
import com.mhd.bms.infrastructure.feign.vo.ContractManageDetailPO;
import com.mhd.bms.infrastructure.feign.vo.ContractManagePO;
import com.mhd.bms.interfaces.dto.billingStatement.BillingStatementDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.core.web.domain.AjaxResult;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.SystemServiceFeign;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.mhd.common.core.utils.PageUtils.startPage;
/**
* 计费流水
*
* @author gen
* @date 2024-06-26
*/
@Service
@Slf4j
public class BillingStatementDomainService {
@Autowired
private IBillingStatementService billingStatementService;
@Autowired
private SystemServiceFeign systemServiceFeign;
@Autowired
private BillManageDomainService billManageDomainService;
@Autowired
private IBillManageService billManageService;
@Autowired
private SettlementCustomersDomainService settlementCustomersDomainService;
@Autowired
private IBusinessDocumentService businessDocumentService;
/**
* 分页查询计费流水列表
*/
public List<BillingStatementPO> queryList(BillingStatementDO billingStatementDO) {
return billingStatementService.queryList(billingStatementDO);
}
/**
* 查询出账汇总
*/
public List<BillingStatementCollectPO> queryCollectList(BillingStatementCollectDO billingStatementCollectDO){
return billingStatementService.queryCollectList(billingStatementCollectDO);
}
/**
* 查询出账详情
*/
public List<BillingStatementPO> queryDetails(BillingStatementCollectDO bdo) {
return billingStatementService.queryDetails(bdo);
}
/**
* 新增计费流水
*/
public Boolean insert(BillingStatementDO billingStatementDO) {
return billingStatementService.insert(billingStatementDO);
}
/**
* 修改计费流水
*/
public Boolean update(BillingStatementDO billingStatementDO) {
return billingStatementService.update(billingStatementDO);
}
/**
* 批量删除计费流水
*/
public Boolean delete(Long[] billingStatementIds) {
return billingStatementService.delete(billingStatementIds);
}
/**
* 获取计费流水详细信息
*/
public BillingStatementPO getInfo(Long billingStatementId)
{
return billingStatementService.getInfo(billingStatementId);
}
/**
* 批量审核
*/
public Boolean reviewBilling(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
List<BillingStatement> billingStatements = new ArrayList<>();
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
for (String billingId : billingSet) {
Long billingStatementId = Long.valueOf(billingId);
BillingStatementPO billingStatementPO = billingStatementService.getInfo(billingStatementId);
if(null == billingStatementPO){
throw new ServiceException("流水不存在");
}
if(billingStatementPO.getBillingState()!=1){
throw new ServiceException("该计费流水状态不为待审核,不能进行审核");
}
if(billingStatementPO.getRedFlushState()==2){
throw new ServiceException("计费流水"+ billingStatementPO.getBillingFlow() +"已红冲,不能进行审核");
}
BillingStatement billingStatement = new BillingStatement();
billingStatement.setBillingStatementId(billingStatementId);
billingStatement.setReviewRemarks(billingStatementDTO.getReviewRemarks());
if(billingStatementDTO.getAuditOperation()==1){
//审核通过
billingStatement.setBillingState(2);
}else {
//审核不通过
billingStatement.setBillingState(4);
//计费流水审核不通过时,修改业务单据中的状态到已生效
BusinessDocumentDO businessDocumentDO = new BusinessDocumentDO();
businessDocumentDO.setBusinessDocumentId(billingStatementPO.getBusinessDocumentId());
businessDocumentDO.setBusinessState(2);
businessDocumentService.update(businessDocumentDO);
}
billingStatement.setUpdateTime(new Date());
billingStatement.setUpdateBy(loginUser.getUserPo().getUserId());
billingStatement.setUpdateByName(loginUser.getUserPo().getUserName());
billingStatements.add(billingStatement);
}
return billingStatementService.updateBatchById(billingStatements);
}
/**
* 批量红冲
*/
public Boolean redFlushBilling(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//只有手工录入流水才可以进行红冲操作
List<BillingStatement> billingStatements = new ArrayList<>();
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
for (String billingId : billingSet) {
Long billingStatementId = Long.valueOf(billingId);
BillingStatementPO billingStatementPO = billingStatementService.getInfo(billingStatementId);
if(null == billingStatementPO){
throw new ServiceException("流水不存在");
}
if(billingStatementPO.getDataSources()!=2){
throw new ServiceException("非手工录入流水,不可进行红冲操作");
}
//如果流水已出账,则不允许红冲
if(billingStatementPO.getBillingState()==3){
throw new ServiceException("计费流水"+ billingStatementPO.getBillingFlow() +"已出账,无法进行红冲操作");
}
BillingStatement billingStatement = new BillingStatement();
billingStatement.setBillingStatementId(billingStatementId);
billingStatement.setRedFlushRemark(billingStatementDTO.getRedFlushRemark());
billingStatement.setRedFlushState(2);
billingStatements.add(billingStatement);
}
return billingStatementService.updateBatchById(billingStatements);
}
/**
* 校验所选流水是否是唯一主体
* @param billingStatementIds
*/
public void checkUniqueEntity(String billingStatementIds) {
Set<String> billingSet = Stream.of(billingStatementIds.split(",")).collect(Collectors.toSet());
LambdaQueryWrapper<BillingStatement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillingStatement::getBillingStatementId,billingSet);
queryWrapper.eq(BillingStatement::getDelFlag,1);
List<BillingStatement> billingStatementList = billingStatementService.list(queryWrapper);
if(null == billingStatementList){
throw new ServiceException("所选流水信息未找到,请刷新后重试");
}
if(billingStatementList.size()!=billingSet.size()){
throw new ServiceException("所选流水信息未找到,请刷新后重试");
}
//判断流水状态如果不是已审核的状态则不能生成账单
long billingStateSet = billingStatementList.stream().filter(item -> item.getBillingState()!=2).count();
if(billingStateSet>0){
throw new ServiceException("所选流水状态不是已审核状态,请刷新后重试");
}
//判断流水状态是否已经红冲
long redFlushStateSet = billingStatementList.stream().filter(item -> item.getRedFlushState()==2).count();
if(redFlushStateSet > 0){
throw new ServiceException("所选流水状态不是未红冲状态,不能进行审核");
}
//校验结算对象是否一致
Set<Long> settlementCustomersIdSet = billingStatementList.stream().map(BillingStatement::getSettlementCustomersId).collect(Collectors.toSet());
if(settlementCustomersIdSet.size()!=1){
throw new ServiceException("所选流水结算对象不一致,请刷新后重试");
}
//校验来源系统是否一致
Set<String> belongModuleCodeSet = billingStatementList.stream().map(BillingStatement::getBelongModuleCode).collect(Collectors.toSet());
if(belongModuleCodeSet.size()!=1){
throw new ServiceException("所选流水来源系统不一致,请刷新后重试");
}
//校验收支类型是否一致
Set<Integer> accountExpenseTypeSet = billingStatementList.stream().map(BillingStatement::getAccountExpenseType).collect(Collectors.toSet());
if(accountExpenseTypeSet.size()!=1){
throw new ServiceException("所选流水收支类型不一致,请刷新后重试");
}
//校验组织是否一致
Set<Long> organizationIdSet = billingStatementList.stream().map(BillingStatement::getOrganizationId).collect(Collectors.toSet());
if(organizationIdSet.size()!=1){
throw new ServiceException("所选流水组织不一致,请刷新后重试");
}
}
/**
* 修改流水状态
* @param billingStatementDTO
*/
public Boolean updateBillingState(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
LambdaUpdateWrapper<BillingStatement> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillingStatement::getBillingStatementId,billingSet);
updateWrapper.set(BillingStatement::getBillingState,billingStatementDTO.getBillingState());
updateWrapper.set(BillingStatement::getUpdateBy,loginUser.getUserPo().getUserId());
updateWrapper.set(BillingStatement::getUpdateTime,new Date());
updateWrapper.set(BillingStatement::getUpdateByName,loginUser.getUserPo().getUserName());
return billingStatementService.update(updateWrapper);
}
public Boolean nullifyByIds(BillingStatementDTO billingStatementDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
//只有待审核状态的记录可以作废
List<BillingStatement> billingStatements = new ArrayList<>();
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
for (String billingId : billingSet) {
Long billingStatementId = Long.valueOf(billingId);
BillingStatementPO billingStatementPO = billingStatementService.getInfo(billingStatementId);
if(null == billingStatementPO){
throw new ServiceException("流水不存在");
}
if(billingStatementPO.getBillingState()!=1){
throw new ServiceException("非待审核状态,不可进行作废操作");
}
BillingStatement billingStatement = new BillingStatement();
billingStatement.setBillingStatementId(billingStatementId);
billingStatement.setBillingState(5);
billingStatements.add(billingStatement);
}
return billingStatementService.updateBatchById(billingStatements);
}
/**
* 查询批量出账列表
*/
public List<BillingStatementPO> queryPaymentOutList(BillingStatementDO billingStatementDO) {
//只查询流水状态为已审核的
billingStatementDO.setBillingState(2);
billingStatementDO.setRedFlushState(1);
return billingStatementService.queryPaymentOutList(billingStatementDO);
}
/**
* 校验是否可以生成账单
*/
public boolean checkGenerateBills(BillingStatementDTO billingStatementDTO) {
Set<String> billingStatementIds = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
LambdaQueryWrapper<BillingStatement> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BillingStatement::getBillingStatementId,billingStatementIds);
queryWrapper.eq(BillingStatement::getDelFlag,1);
List<BillingStatement> billingStatementList = billingStatementService.list(queryWrapper);
if(billingStatementList ==null || billingStatementList.size()==0){
return false;
}
//校验流水状态是否都是已审核状态,如果不是则返回false
Set<Integer> billingStateSet = billingStatementList.stream().map(BillingStatement::getBillingState).collect(Collectors.toSet());
if(billingStateSet.size()==1 && billingStateSet.contains(2)){
return true;
}
//校验红冲状态是否都是未红冲,如果不是返回false
Set<Integer> redFlushStateSet = billingStatementList.stream().map(BillingStatement::getRedFlushState).collect(Collectors.toSet());
if(redFlushStateSet.size()==1 && redFlushStateSet.contains(1)){
return true;
}
return false;
}
/**
* 批量生成账单
*/
public void batchGenerateBills(BillingStatementDTO billingStatementDTO) {
Set<String> billingSet = Stream.of(billingStatementDTO.getBillingStatementIds().split(",")).collect(Collectors.toSet());
BillingStatementDO billingStatementDO = new BillingStatementDO();
billingStatementDO.setBillingStatementIdSet(billingSet);
List<BillingStatementPO> billingStatementPOS = billingStatementService.queryList(billingStatementDO);
//判断流水状态如果不是已审核的状态则不能生成账单
long billingStateSet = billingStatementPOS.stream().filter(item -> item.getBillingState()!=2).count();
if(billingStateSet>0){
throw new ServiceException("所选流水状态含有非已审核状态,请刷新后重试");
}
//将billingStatementPOS集合按照组织表ID、结算对象code、收支类型、对接系统编码进行分组,将结算对象code作为key,四个条件有一个不同则视为不同的分组
Map<String, List<BillingStatementPO>> billingStatementPOSMap = billingStatementPOS.stream().collect(Collectors.groupingBy(billingStatementPO -> billingStatementPO.getOrganizationId()+"_"+billingStatementPO.getSettlementCustomersCode()+"_"+billingStatementPO.getAccountExpenseType()+"_"+billingStatementPO.getBelongModuleCode()));
//遍历集合分别生成账单
billingStatementPOSMap.forEach((key,value)->{
final String billingRemark = billingStatementDTO.getBillingRemark();
final Date billCreateTime = billingStatementDTO.getBillCreateTime();
if(value.size()>0){
//生成账单
billManageDomainService.saveBill(value,billingRemark,billCreateTime);
}
});
//修改流水状态
billingStatementDTO.setBillingState(3);
updateBillingState(billingStatementDTO);
}
/**
* 生成流水
*/
public Boolean generateFlow(BusinessDocumentPO businessDocumentPO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
BillingStatementDO billingStatementDO = new BillingStatementDO();
String[] ignroreFields = new String[]{"billingStatementId","dataSources","createBy","createByName","createTime","updateBy","updateByName","updateTime"};
BeanUtils.copyProperties(businessDocumentPO,billingStatementDO,ignroreFields);
billingStatementDO.setBusinessDocumentId(businessDocumentPO.getBusinessDocumentId());
billingStatementDO.setBusinessDate(businessDocumentPO.getCreateTime());
billingStatementDO.setBillingAmount(businessDocumentPO.getBillAmount());
billingStatementDO.setBillingState(1);
billingStatementDO.setDataSources(1);
billingStatementDO.setCreateBy(loginUser.getUserPo().getUserId());
billingStatementDO.setCreateByName(loginUser.getUserPo().getUserName());
billingStatementDO.setCreateTime(new Date());
billingStatementDO.setBillingFlow(businessDocumentPO.getBusinessFlow());
billingStatementDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
billingStatementDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
billingStatementDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
//处理数据
handleData(billingStatementDO);
return this.insert(billingStatementDO);
}
/**
* 处理生成收支流水数据
* @param billingStatementDO
*/
private void handleData(BillingStatementDO billingStatementDO) {
//查询合同信息,赋值合同周期信息
if(StringUtils.isNotEmpty(billingStatementDO.getContractNumber())){
AjaxResult ajaxResult = systemServiceFeign.getInfoByCode(billingStatementDO.getContractNumber());
if("200".equals(String.valueOf(ajaxResult.get("code")))){
ContractManagePO contractManagePO = JSON.parseObject(JSONObject.toJSONString(ajaxResult.get("data")), ContractManagePO.class);
if(null != contractManagePO){
//取值合同详情,对比费用科目,取值计费周期
if(contractManagePO.getContractManageDetailPOList()!=null && contractManagePO.getContractManageDetailPOList().size()>0){
List<ContractManageDetailPO> contractManageDetailPOList = contractManagePO.getContractManageDetailPOList();
String subjectCode = !StringUtils.isNotEmpty(billingStatementDO.getSecondSubjectCode()) ? billingStatementDO.getFirstSubjectCode() : billingStatementDO.getSecondSubjectCode();
Date cycleBeginTime = null;
Date cycleEndTime = null;
for (ContractManageDetailPO contractManageDetailPO : contractManageDetailPOList) {
String subjectCodeContract = !StringUtils.isNotEmpty(contractManageDetailPO.getSecondSubjectCode()) ? contractManageDetailPO.getFirstSubjectCode() : contractManageDetailPO.getSecondSubjectCode();
if(subjectCodeContract.equals(subjectCode)){
Date businessDate = billingStatementDO.getBusinessDate();
//根据不同类型获取计费周期
if(ObjectUtil.equal(contractManageDetailPO.getBillingAttributesCode(),"1") || ObjectUtil.equal(contractManageDetailPO.getBillingAttributesCode(),"4")){
//实时计费、按天计费,赋值为当天
cycleBeginTime = businessDate;
cycleEndTime = businessDate;
}else if(ObjectUtil.equal(contractManageDetailPO.getBillingAttributesCode(),"2")){
//按账期计费
cycleBeginTime = businessDate;
cycleEndTime = contractManagePO.getPaymentDate();
}else if(ObjectUtil.equal(contractManageDetailPO.getBillingAttributesCode(),"3")){
//按周计费,用businessDate往后推一周的日期
cycleBeginTime = businessDate;
cycleEndTime = DateUtil.offsetWeek(businessDate,1);
}
break;
}
}
billingStatementDO.setCycleBeginTime(cycleBeginTime);
billingStatementDO.setCycleEndTime(cycleEndTime);
}
billingStatementDO.setContractType(contractManagePO.getContractType());
}
}
}
//根据结算对象获取收支类型
if(StringUtils.isNotEmpty(billingStatementDO.getSettlementCustomersCode())){
SettlementCustomers settlementCustomers = settlementCustomersDomainService.queryByCode(billingStatementDO.getSettlementCustomersCode());
if(null != settlementCustomers){
if(settlementCustomers.getMainRole()==1){
billingStatementDO.setAccountExpenseType(1);
}else {
billingStatementDO.setAccountExpenseType(2);
}
}
}
}
/**
* 账单作废,流水状态回滚
* @param billingStatementIds
* @return
*/
public Boolean billNullify(Set<Long> billingStatementIds) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
LambdaUpdateWrapper<BillingStatement> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BillingStatement::getBillingStatementId, billingStatementIds)
.set(BillingStatement::getBillingState, 2)
.set(BillingStatement::getUpdateBy, loginUser.getUserPo().getUserId())
.set(BillingStatement::getUpdateByName, loginUser.getUserPo().getUserName())
.set(BillingStatement::getUpdateTime, new Date());
return billingStatementService.update(updateWrapper);
}
public Long insertAndReturnId(BillingStatementDO billingStatementDO) {
BillingStatement billingStatement = new BillingStatement();
BeanUtils.copyProperties(billingStatementDO,billingStatement);
billingStatementService.save(billingStatement);
return billingStatement.getBillingStatementId();
}
/**
* 应收账单-添加明细
*/
public List<BillingStatementPO> getBillDetailsList(BillingStatementDO billingStatementDO) {
//查询当前账单的五大信息:组织信息、结算对象、来源系统、收支类型、账单周期
BillManagePO billManagePO = billManageDomainService.getInfo(billingStatementDO.getBillManageId());
if(null == billManagePO){
throw new ServiceException("账单信息未找到");
}
billingStatementDO.setSettlementCustomersCode(billManagePO.getSettlementCustomersCode());
billingStatementDO.setBelongModuleCode(billManagePO.getBelongModuleCode());
billingStatementDO.setAccountExpenseType(billManagePO.getBillType());
billingStatementDO.setCycleBeginTime(billManagePO.getCycleBeginTime());
billingStatementDO.setCycleEndTime(billManagePO.getCycleEndTime());
billingStatementDO.setBillingState(2);
startPage();
return billingStatementService.queryList(billingStatementDO);
}
/**
* 根据账单id,查询流水明细列表
* @param billManageId
* @return
*/
public List<BillingStatementPO> getDetailsByManageId(Long billManageId) {
return billingStatementService.getDetailsByManageId(billManageId);
}
/**
* 流水综合报表
*/
public List<BillingStatement> comprehensiveList(QueryWrapper<BillingStatement> queryWrapper) {
return billingStatementService.list(queryWrapper);
}
}
@@ -0,0 +1,173 @@
package com.mhd.bms.domain.businessDocument.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 业务单据对象 business_document
*
* @author gen
* @date 2024-06-21
*/
@Data
public class BusinessDocument extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("业务单据记录id")
@TableId(type = IdType.AUTO)
private Long businessDocumentId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("业务流水")
@Excel(name = "业务流水")
private String businessFlow;
@ApiModelProperty("状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
@Excel(name = "状态", readConverterExp = "状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
private Integer businessState;
@ApiModelProperty("来源模块")
@Excel(name = "来源模块")
private String belongModule;
@ApiModelProperty("来源模块code")
@Excel(name = "来源模块code")
private String belongModuleCode;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("原始业务单号")
@Excel(name = "原始业务单号")
private String originalBusinessNum;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("预计费金额")
@Excel(name = "预计费金额")
private BigDecimal estimatedCost;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目(结算项)")
@Excel(name = "一级费用科目")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目(结算项)")
@Excel(name = "二级费用科目")
private String secondSubjectName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("计费时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计费时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date billingTime;
@ApiModelProperty("单据表单json数据")
@Excel(name = "单据表单json数据")
private String documentFormJson;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id", readConverterExp = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id", readConverterExp = "项目管理id")
private Long projectManageId;
@ApiModelProperty("原始流水号")
@Excel(name = "原始流水号")
private String originalSerialNumber;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code(服务项)")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id(服务项)")
private Long serviceItemsManageId;
@ApiModelProperty("单据备注")
@Excel(name = "单据备注")
private String remark;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
}
@@ -0,0 +1,45 @@
package com.mhd.bms.domain.businessDocument.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import java.util.List;
/**
* 业务单据Service接口
*
* @author gen
* @date 2024-06-21
*/
public interface IBusinessDocumentService extends IService<BusinessDocument>
{
/**
* 分页查询业务单据列表
*/
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO);
/**
* 新增业务单据
*/
public Boolean insert(BusinessDocumentDO businessDocumentDO);
/**
* 修改业务单据
*/
public Boolean update(BusinessDocumentDO businessDocumentDO);
/**
* 批量删除业务单据
*/
public Boolean delete(Long[] businessDocumentIds);
/**
* 查询业务单据
*/
public BusinessDocumentPO getInfo(Long businessDocumentId);
BusinessDocumentPO queryByOriginalBusinessNumAndSubjectCode(String originalBusinessNum, String secondSubjectCode);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.businessDocument.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import org.apache.ibatis.annotations.Param;
/**
* 业务单据Mapper接口
*
* @author gen
* @date 2024-06-21
*/
public interface BusinessDocumentMapper extends BaseMapper<BusinessDocument>
{
/**
* 查询业务单据列表
*/
public List<BusinessDocumentPO> queryList(@Param("businessDocumentDO") BusinessDocumentDO businessDocumentDO);
}
@@ -0,0 +1,96 @@
package com.mhd.bms.domain.businessDocument.repository.persistence;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.facade.IBusinessDocumentService;
import com.mhd.bms.domain.businessDocument.repository.mapper.BusinessDocumentMapper;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 业务单据Service业务层处理
*
* @author gen
* @date 2024-06-21
*/
@Service
public class BusinessDocumentImpl extends ServiceImpl<BusinessDocumentMapper, BusinessDocument> implements IBusinessDocumentService{
@Autowired
private BusinessDocumentMapper businessDocumentMapper;
/**
* 查询业务单据列表
*/
@Override
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO)
{
return businessDocumentMapper.queryList(businessDocumentDO);
}
/**
* 新增业务单据
*/
@Override
public Boolean insert(BusinessDocumentDO businessDocumentDO) {
BusinessDocument businessDocument = new BusinessDocument();
BeanUtils.copyProperties(businessDocumentDO,businessDocument);
return this.save(businessDocument);
}
/**
* 修改业务单据
*/
@Override
public Boolean update(BusinessDocumentDO businessDocumentDO) {
BusinessDocument businessDocument = new BusinessDocument();
BeanUtils.copyProperties(businessDocumentDO,businessDocument);
return this.updateById(businessDocument);
}
/**
* 批量删除业务单据
*/
@Override
public Boolean delete(Long[] businessDocumentIds ) {
List<BusinessDocument> list = new ArrayList<>();
for (Long id : businessDocumentIds) {
BusinessDocument businessDocument = new BusinessDocument();
businessDocument.setBusinessDocumentId(id);
businessDocument.setDelFlag(2);
list.add(businessDocument);
}
return this.updateBatchById(list);
}
/**
* 修改业务单据
*/
@Override
public BusinessDocumentPO getInfo(Long businessDocumentId) {
BusinessDocument businessDocument = this.getById(businessDocumentId);
BusinessDocumentPO businessDocumentPO = new BusinessDocumentPO();
BeanUtils.copyProperties(businessDocument,businessDocumentPO);
return businessDocumentPO;
}
/**
* 根据原始业务单号和费用科目code查询
*/
@Override
public BusinessDocumentPO queryByOriginalBusinessNumAndSubjectCode(String originalBusinessNum, String secondSubjectCode) {
BusinessDocumentPO businessDocumentPO = new BusinessDocumentPO();
LambdaQueryWrapper<BusinessDocument> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(BusinessDocument::getOriginalBusinessNum,originalBusinessNum);
lambdaQueryWrapper.eq(BusinessDocument::getSecondSubjectCode,secondSubjectCode).or().eq(BusinessDocument::getFirstSubjectCode,secondSubjectCode);
BusinessDocument businessDocument = this.getOne(lambdaQueryWrapper);
BeanUtils.copyProperties(businessDocument,businessDocumentPO);
return businessDocumentPO;
}
}
@@ -0,0 +1,177 @@
package com.mhd.bms.domain.businessDocument.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 业务单据对象 business_document
*
* @author gen
* @date 2024-06-21
*/
@Data
@ApiModel(value = "业务单据对象", description = "业务单据响应对象")
public class BusinessDocumentPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("业务单据记录id")
private Long businessDocumentId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("业务流水")
@Excel(name = "业务流水")
private String businessFlow;
@ApiModelProperty("状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
@Excel(name = "状态", readConverterExp = "状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
private Integer businessState;
@ApiModelProperty("来源模块")
@Excel(name = "来源模块")
private String belongModule;
@ApiModelProperty("来源模块code")
@Excel(name = "来源模块code")
private String belongModuleCode;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("原始业务单号")
@Excel(name = "原始业务单号")
private String originalBusinessNum;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("预计费金额")
@Excel(name = "预计费金额")
private BigDecimal estimatedCost;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目")
@Excel(name = "一级费用科目")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目")
@Excel(name = "二级费用科目")
private String secondSubjectName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("计费时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计费时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date billingTime;
@ApiModelProperty("单据表单json数据")
@Excel(name = "单据表单json数据")
private String documentFormJson;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id", readConverterExp = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id", readConverterExp = "项目管理id")
private Long projectManageId;
@ApiModelProperty("原始流水号")
@Excel(name = "原始流水号")
private String originalSerialNumber;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code(服务项)")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id(服务项)")
private String serviceItemsManageId;
@ApiModelProperty("单据备注")
@Excel(name = "单据备注")
private String remark;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty("重算金额")
private BigDecimal recalculateCost;
@ApiModelProperty("重算失败原因")
private String recalculateCostFailRemark;
}
@@ -0,0 +1,197 @@
package com.mhd.bms.domain.businessDocument.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import javax.validation.constraints.NotNull;
import java.util.List;
import java.util.Set;
/**
* 业务单据对象 business_document
*
* @author gen
* @date 2024-06-21
*/
@Data
public class BusinessDocumentDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("业务单据记录id")
private Long businessDocumentId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("业务流水")
@Excel(name = "业务流水")
private String businessFlow;
@ApiModelProperty("状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
@Excel(name = "状态", readConverterExp = "状态(1-未生效,2-已生效,3-已计费,4-已驳回,5-已作废")
private Integer businessState;
@ApiModelProperty("来源模块")
@Excel(name = "来源模块")
private String belongModule;
@ApiModelProperty("来源模块code")
@Excel(name = "来源模块code")
private String belongModuleCode;
@ApiModelProperty("数据来源(1-系统生成,2-手工录入)")
@Excel(name = "数据来源", readConverterExp = "1=-系统生成,2-手工录入")
private Integer dataSources;
@ApiModelProperty("单据类型id")
@Excel(name = "单据类型id")
private Long documentTypeId;
@ApiModelProperty("单据类型code")
@Excel(name = "单据类型code")
private String documentTypeCode;
@ApiModelProperty("单据类型")
@Excel(name = "单据类型")
private String documentType;
@ApiModelProperty("原始业务单号")
@Excel(name = "原始业务单号")
private String originalBusinessNum;
@ApiModelProperty("项目编码")
@Excel(name = "项目编码")
private String projectCode;
@ApiModelProperty("项目名称")
@Excel(name = "项目名称")
private String projectName;
@ApiModelProperty("合同编号")
@Excel(name = "合同编号")
private String contractNumber;
@ApiModelProperty("合同名称")
@Excel(name = "合同名称")
private String contractName;
@ApiModelProperty("账单金额")
@Excel(name = "账单金额")
private BigDecimal billAmount;
@ApiModelProperty("预计费金额")
@Excel(name = "预计费金额")
private BigDecimal estimatedCost;
@ApiModelProperty("一级费用科目code")
@Excel(name = "一级费用科目code")
private String firstSubjectCode;
@ApiModelProperty("一级费用科目")
@Excel(name = "一级费用科目")
private String firstSubjectName;
@ApiModelProperty("二级费用科目code")
@Excel(name = "二级费用科目code")
private String secondSubjectCode;
@ApiModelProperty("二级费用科目")
@Excel(name = "二级费用科目")
private String secondSubjectName;
@ApiModelProperty("结算对象id")
@Excel(name = "结算对象id")
private Long settlementCustomersId;
@ApiModelProperty("结算对象code")
@Excel(name = "结算对象code")
private String settlementCustomersCode;
@ApiModelProperty("结算对象")
@Excel(name = "结算对象")
private String settlementEntity;
@ApiModelProperty("计费时间")
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "计费时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date billingTime;
@ApiModelProperty("单据表单json数据")
@Excel(name = "单据表单json数据")
private String documentFormJson;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
@ApiModelProperty(name = "修改时间查询条件开始日期")
private String updateTimeStart;
@ApiModelProperty(name = "修改时间查询条件结束日期")
private String updateTimeEnd;
@ApiModelProperty("业务单据记录ids")
private String businessDocumentIds;
@ApiModelProperty("合同管理id")
@Excel(name = "合同管理id", readConverterExp = "合同管理id")
private Long contractManageId;
@ApiModelProperty("项目管理id")
@Excel(name = "项目管理id", readConverterExp = "项目管理id")
private Long projectManageId;
@ApiModelProperty("原始流水号")
@Excel(name = "原始流水号")
private String originalSerialNumber;
@ApiModelProperty("费用类型code(服务项)")
@Excel(name = "费用类型code(服务项)")
private String serviceItemsCode;
@ApiModelProperty("费用类型")
@Excel(name = "费用类型")
private String serviceItemsName;
@ApiModelProperty("费用类型id(服务项)")
@Excel(name = "费用类型id(服务项)")
private Long serviceItemsManageId;
@ApiModelProperty("单据备注")
@Excel(name = "单据备注")
private String remark;
@ApiModelProperty("审核备注")
@Excel(name = "审核备注")
private String reviewRemarks;
@ApiModelProperty("结算方式(1-现金,2-油卡)")
private Integer settlementWay;
@ApiModelProperty(name = "业务单据记录id集合")
private Set<String> businessDocumentIdSet;
@ApiModelProperty("结算主体id")
private Long settlementEntityId;
}
@@ -0,0 +1,196 @@
package com.mhd.bms.domain.businessDocument.service;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.mhd.bms.domain.businessDocument.entity.BusinessDocument;
import com.mhd.bms.domain.businessDocument.repository.facade.IBusinessDocumentService;
import com.mhd.bms.domain.businessDocument.repository.po.BusinessDocumentPO;
import com.mhd.bms.domain.businessDocument.repository.todo.BusinessDocumentDO;
import com.mhd.bms.interfaces.dto.businessDocument.BusinessDocumentDTO;
import com.mhd.common.core.exception.ServiceException;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.core.utils.StringUtils;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 业务单据
*
* @author gen
* @date 2024-06-21
*/
@Service
@Slf4j
public class BusinessDocumentDomainService {
@Autowired
private IBusinessDocumentService businessDocumentService;
/**
* 分页查询业务单据列表
*/
public List<BusinessDocumentPO> queryList(BusinessDocumentDO businessDocumentDO) {
return businessDocumentService.queryList(businessDocumentDO);
}
/**
* 新增业务单据
*/
public Boolean insert(BusinessDocumentDO businessDocumentDO) {
return businessDocumentService.insert(businessDocumentDO);
}
/**
* 修改业务单据
*/
public Boolean update(BusinessDocumentDO businessDocumentDO) {
return businessDocumentService.update(businessDocumentDO);
}
/**
* 批量删除业务单据
*/
public Boolean delete(Long[] businessDocumentIds) {
return businessDocumentService.delete(businessDocumentIds);
}
/**
* 获取业务单据详细信息
*/
public BusinessDocumentPO getInfo(Long businessDocumentId)
{
return businessDocumentService.getInfo(businessDocumentId);
}
/**
* 根据id删除业务单据信息
*/
public Boolean deleteByIds(List<Long> businessDocumentIdLongList) {
if(businessDocumentIdLongList != null && businessDocumentIdLongList.size() > 0){
LambdaUpdateWrapper<BusinessDocument> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(BusinessDocument::getDelFlag,2);
updateWrapper.in(BusinessDocument::getBusinessDocumentId,businessDocumentIdLongList);
return businessDocumentService.update(updateWrapper);
}
return false;
}
/**
* 根据id作废业务单据信息
*/
public Boolean nullifyByIds(List<Long> businessDocumentIdLongList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(businessDocumentIdLongList != null && businessDocumentIdLongList.size() > 0){
LambdaUpdateWrapper<BusinessDocument> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(BusinessDocument::getBusinessState,5);
updateWrapper.set(BusinessDocument::getUpdateBy,loginUser.getUserPo().getUserId());
updateWrapper.set(BusinessDocument::getUpdateTime,new Date());
updateWrapper.set(BusinessDocument::getUpdateByName,loginUser.getUserPo().getUserName());
updateWrapper.in(BusinessDocument::getBusinessDocumentId,businessDocumentIdLongList);
return businessDocumentService.update(updateWrapper);
}
return false;
}
/**
* 根据id生效业务单据信息
*/
public Boolean takeEffectByIds(List<Long> businessDocumentIdLongList) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(businessDocumentIdLongList != null && businessDocumentIdLongList.size() > 0){
LambdaUpdateWrapper<BusinessDocument> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(BusinessDocument::getBusinessState,2);
updateWrapper.set(BusinessDocument::getUpdateBy,loginUser.getUserPo().getUserId());
updateWrapper.set(BusinessDocument::getUpdateTime,new Date());
updateWrapper.set(BusinessDocument::getUpdateByName,loginUser.getUserPo().getUserName());
updateWrapper.in(BusinessDocument::getBusinessDocumentId,businessDocumentIdLongList);
return businessDocumentService.update(updateWrapper);
}
return false;
}
/**
* 审核业务单据
*/
public Boolean auditByIds(List<Long> businessDocumentIdLongList, BusinessDocumentDTO businessDocumentDTO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
if(businessDocumentIdLongList != null && businessDocumentIdLongList.size() > 0){
LambdaUpdateWrapper<BusinessDocument> updateWrapper = new LambdaUpdateWrapper<>();
if(businessDocumentDTO.getAuditOperation() == 1){
//同意
updateWrapper.set(BusinessDocument::getBusinessState,3);
}else {
//驳回
updateWrapper.set(BusinessDocument::getBusinessState,4);
}
updateWrapper.set(BusinessDocument::getReviewRemarks,businessDocumentDTO.getReviewRemarks());
updateWrapper.set(BusinessDocument::getUpdateBy,loginUser.getUserPo().getUserId());
updateWrapper.set(BusinessDocument::getUpdateTime,new Date());
updateWrapper.set(BusinessDocument::getUpdateByName,loginUser.getUserPo().getUserName());
updateWrapper.in(BusinessDocument::getBusinessDocumentId,businessDocumentIdLongList);
return businessDocumentService.update(updateWrapper);
}
return false;
}
public Boolean saveBatch(List<BusinessDocument> businessDocumentList) {
if(null != businessDocumentList && businessDocumentList.size() > 0){
return businessDocumentService.saveBatch(businessDocumentList);
}
return false;
}
/**
* 根据原始业务单号和科目编码查询
*/
public BusinessDocumentPO queryByOriginalBusinessNumAndSubjectCode(BusinessDocumentDO businessDocumentDO) {
if(StringUtils.isNotEmpty(businessDocumentDO.getOriginalBusinessNum())){
throw new ServiceException("原始单号不能为空");
}
if(StringUtils.isNotEmpty(businessDocumentDO.getSecondSubjectCode())){
throw new ServiceException("费用科目不能为空");
}
return businessDocumentService.queryByOriginalBusinessNumAndSubjectCode(businessDocumentDO.getOriginalBusinessNum(),businessDocumentDO.getSecondSubjectCode());
}
/**
* 保存或修改业务单据
* @param businessDocumentDO
*/
public Boolean saveOrUpdate(BusinessDocumentDO businessDocumentDO) {
BusinessDocument businessDocument = new BusinessDocument();
BeanUtils.copyProperties(businessDocumentDO,businessDocument);
return businessDocumentService.saveOrUpdate(businessDocument);
}
/**
* 批量保存业务单据
* @param businessDocumentList
* @return
*/
public Boolean saveOrUpdateBatch(List<BusinessDocument> businessDocumentList) {
return businessDocumentService.saveOrUpdateBatch(businessDocumentList);
}
}
@@ -0,0 +1,58 @@
package com.mhd.bms.domain.conditionalMapping.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 条件映射管理对象 conditional_mapping
*
* @author gen
* @date 2024-08-07
*/
@Data
public class ConditionalMapping extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("条件映射表id")
@TableId(type = IdType.AUTO)
private Long conditionalMappingId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("源内容")
@Excel(name = "源内容")
private String sourceContent;
@ApiModelProperty("映射后")
@Excel(name = "映射后")
private String afterMapping;
@ApiModelProperty("映射类型(1-关键字,2-条件,3-结果)")
@Excel(name = "映射类型", readConverterExp = "1=-关键字,2-条件,3-结果")
private Integer mappingType;
@ApiModelProperty("映射语句")
@Excel(name = "映射语句")
private String mappedStatement;
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.conditionalMapping.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.conditionalMapping.entity.ConditionalMapping;
import com.mhd.bms.domain.conditionalMapping.repository.po.ConditionalMappingPO;
import com.mhd.bms.domain.conditionalMapping.repository.todo.ConditionalMappingDO;
import java.util.List;
/**
* 条件映射管理Service接口
*
* @author gen
* @date 2024-08-07
*/
public interface IConditionalMappingService extends IService<ConditionalMapping>
{
/**
* 分页查询条件映射管理列表
*/
public List<ConditionalMappingPO> queryList(ConditionalMappingDO conditionalMappingDO);
/**
* 新增条件映射管理
*/
public Boolean insert(ConditionalMappingDO conditionalMappingDO);
/**
* 修改条件映射管理
*/
public Boolean update(ConditionalMappingDO conditionalMappingDO);
/**
* 批量删除条件映射管理
*/
public Boolean delete(Long[] conditionalMappingIds);
/**
* 查询条件映射管理
*/
public ConditionalMappingPO getInfo(Long conditionalMappingId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.conditionalMapping.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.conditionalMapping.entity.ConditionalMapping;
import com.mhd.bms.domain.conditionalMapping.repository.po.ConditionalMappingPO;
import com.mhd.bms.domain.conditionalMapping.repository.todo.ConditionalMappingDO;
import org.apache.ibatis.annotations.Param;
/**
* 条件映射管理Mapper接口
*
* @author gen
* @date 2024-08-07
*/
public interface ConditionalMappingMapper extends BaseMapper<ConditionalMapping>
{
/**
* 查询条件映射管理列表
*/
public List<ConditionalMappingPO> queryList(@Param("conditionalMappingDO") ConditionalMappingDO conditionalMappingDO);
}
@@ -0,0 +1,81 @@
package com.mhd.bms.domain.conditionalMapping.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.conditionalMapping.entity.ConditionalMapping;
import com.mhd.bms.domain.conditionalMapping.repository.facade.IConditionalMappingService;
import com.mhd.bms.domain.conditionalMapping.repository.mapper.ConditionalMappingMapper;
import com.mhd.bms.domain.conditionalMapping.repository.po.ConditionalMappingPO;
import com.mhd.bms.domain.conditionalMapping.repository.todo.ConditionalMappingDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 条件映射管理Service业务层处理
*
* @author gen
* @date 2024-08-07
*/
@Service
public class ConditionalMappingImpl extends ServiceImpl<ConditionalMappingMapper, ConditionalMapping> implements IConditionalMappingService{
@Autowired
private ConditionalMappingMapper conditionalMappingMapper;
/**
* 查询条件映射管理列表
*/
@Override
public List<ConditionalMappingPO> queryList(ConditionalMappingDO conditionalMappingDO)
{
return conditionalMappingMapper.queryList(conditionalMappingDO);
}
/**
* 新增条件映射管理
*/
@Override
public Boolean insert(ConditionalMappingDO conditionalMappingDO) {
ConditionalMapping conditionalMapping = new ConditionalMapping();
BeanUtils.copyProperties(conditionalMappingDO,conditionalMapping);
return this.save(conditionalMapping);
}
/**
* 修改条件映射管理
*/
@Override
public Boolean update(ConditionalMappingDO conditionalMappingDO) {
ConditionalMapping conditionalMapping = new ConditionalMapping();
BeanUtils.copyProperties(conditionalMappingDO,conditionalMapping);
return this.updateById(conditionalMapping);
}
/**
* 批量删除条件映射管理
*/
@Override
public Boolean delete(Long[] conditionalMappingIds ) {
List<ConditionalMapping> list = new ArrayList<>();
for (Long id : conditionalMappingIds) {
ConditionalMapping conditionalMapping = new ConditionalMapping();
conditionalMapping.setConditionalMappingId(id);
conditionalMapping.setDelFlag(2);
list.add(conditionalMapping);
}
return this.updateBatchById(list);
}
/**
* 修改条件映射管理
*/
@Override
public ConditionalMappingPO getInfo(Long conditionalMappingId) {
ConditionalMapping conditionalMapping = this.getById(conditionalMappingId);
ConditionalMappingPO conditionalMappingPO = new ConditionalMappingPO();
BeanUtils.copyProperties(conditionalMapping,conditionalMappingPO);
return conditionalMappingPO;
}
}
@@ -0,0 +1,58 @@
package com.mhd.bms.domain.conditionalMapping.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 条件映射管理对象 conditional_mapping
*
* @author gen
* @date 2024-08-07
*/
@Data
@ApiModel(value = "条件映射管理对象", description = "条件映射管理响应对象")
public class ConditionalMappingPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("条件映射表id")
private Long conditionalMappingId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("源内容")
@Excel(name = "源内容")
private String sourceContent;
@ApiModelProperty("映射后")
@Excel(name = "映射后")
private String afterMapping;
@ApiModelProperty("映射类型(1-关键字,2-条件,3-结果)")
@Excel(name = "映射类型", readConverterExp = "1=-关键字,2-条件,3-结果")
private Integer mappingType;
@ApiModelProperty("映射语句")
@Excel(name = "映射语句")
private String mappedStatement;
}
@@ -0,0 +1,61 @@
package com.mhd.bms.domain.conditionalMapping.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 条件映射管理对象 conditional_mapping
*
* @author gen
* @date 2024-08-07
*/
@Data
public class ConditionalMappingDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("条件映射表id")
private Long conditionalMappingId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("源内容")
@Excel(name = "源内容")
private String sourceContent;
@ApiModelProperty("映射后")
@Excel(name = "映射后")
private String afterMapping;
@ApiModelProperty("映射类型(1-关键字,2-条件,3-结果)")
@Excel(name = "映射类型", readConverterExp = "1=-关键字,2-条件,3-结果")
private Integer mappingType;
@ApiModelProperty("映射语句")
@Excel(name = "映射语句")
private String mappedStatement;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
}
@@ -0,0 +1,64 @@
package com.mhd.bms.domain.conditionalMapping.service;
import com.mhd.bms.domain.conditionalMapping.repository.facade.IConditionalMappingService;
import com.mhd.bms.domain.conditionalMapping.repository.po.ConditionalMappingPO;
import com.mhd.bms.domain.conditionalMapping.repository.todo.ConditionalMappingDO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 条件映射管理
*
* @author gen
* @date 2024-08-07
*/
@Service
@Slf4j
public class ConditionalMappingDomainService {
@Autowired
private IConditionalMappingService conditionalMappingService;
/**
* 分页查询条件映射管理列表
*/
public List<ConditionalMappingPO> queryList(ConditionalMappingDO conditionalMappingDO) {
return conditionalMappingService.queryList(conditionalMappingDO);
}
/**
* 新增条件映射管理
*/
public Boolean insert(ConditionalMappingDO conditionalMappingDO) {
return conditionalMappingService.insert(conditionalMappingDO);
}
/**
* 修改条件映射管理
*/
public Boolean update(ConditionalMappingDO conditionalMappingDO) {
return conditionalMappingService.update(conditionalMappingDO);
}
/**
* 批量删除条件映射管理
*/
public Boolean delete(Long[] conditionalMappingIds) {
return conditionalMappingService.delete(conditionalMappingIds);
}
/**
* 获取条件映射管理详细信息
*/
public ConditionalMappingPO getInfo(Long conditionalMappingId)
{
return conditionalMappingService.getInfo(conditionalMappingId);
}
}
@@ -0,0 +1,27 @@
package com.mhd.bms.domain.costCalculation.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 计费参数输出json实体
*/
@Data
public class BillingOutputEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("输出字段")
private String outFields;
@ApiModelProperty("输出计费标识 P1 、P2等")
private String outChargingId;
@ApiModelProperty("字段类型(1-整数,2-浮点数,3-时间)")
private Integer fieldsType;
@ApiModelProperty("排序")
private Integer sort;
}
@@ -0,0 +1,38 @@
package com.mhd.bms.domain.costCalculation.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
/**
* 计费参数json实体
*/
@Data
public class BillingParamsEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty("字段名称")
private String fields;
@ApiModelProperty("计费标识P1、P2")
private String chargingId;
@ApiModelProperty("阶梯类型(1-固定参数,2-无阶梯,3-到达阶梯,4-累进阶梯)")
private Integer ladderType;
@ApiModelProperty("1-左开右闭,2-左闭右开")
private Integer ladderRule;
@ApiModelProperty("阶梯值")
private String ladderNum;
@ApiModelProperty("标志值")
private String flagValue;
@ApiModelProperty("排序")
private Integer sort;
}
@@ -0,0 +1,34 @@
package com.mhd.bms.domain.costCalculation.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.math.BigDecimal;
/**
* 计费结果返回实体
*/
@Data
public class BillingCostPo {
private static final long serialVersionUID = 1L;
@ApiModelProperty("原始单号")
private String originalBusinessNum;
@ApiModelProperty("单据类型编码")
private String documentTypeCode;
@ApiModelProperty("费用科目(一级或二级)")
private String subjectCode;
@ApiModelProperty("合同编号")
private String contractNumber;
@ApiModelProperty("预计金额")
private BigDecimal computationalCost;
}
@@ -0,0 +1,31 @@
package com.mhd.bms.domain.documentType.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 单据类型表单json实体
*/
@Data
public class DocumentFromEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("字段名称")
private String field;
@ApiModelProperty("字段描述")
private String title;
@ApiModelProperty("是否显示 1是 2否")
private Integer disabled;
@ApiModelProperty("是否必填:1是 2否")
private Integer notNull;
@ApiModelProperty("数据类型 下拉框,日期,日期时间,数字,文本")
private String type;
}
@@ -0,0 +1,70 @@
package com.mhd.bms.domain.documentType.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 单据类型对象 document_type
*
* @author gen
* @date 2024-06-18
*/
@Data
public class DocumentType extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("单据类型id")
@TableId(type = IdType.AUTO)
private Long documentTypeId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty("参数json数组")
@Excel(name = "参数json数组")
private String formJson;
@ApiModelProperty("启用状态(1-启用,2-关闭)")
@Excel(name = "启用状态", readConverterExp = "1=-启用,2-关闭")
private Integer enablingStatus;
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.documentType.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.repository.todo.DocumentTypeDO;
import java.util.List;
/**
* 单据类型Service接口
*
* @author gen
* @date 2024-06-18
*/
public interface IDocumentTypeService extends IService<DocumentType>
{
/**
* 分页查询单据类型列表
*/
public List<DocumentTypePO> queryList(DocumentTypeDO documentTypeDO);
/**
* 新增单据类型
*/
public Boolean insert(DocumentTypeDO documentTypeDO);
/**
* 修改单据类型
*/
public Boolean update(DocumentTypeDO documentTypeDO);
/**
* 批量删除单据类型
*/
public Boolean delete(Long[] documentTypeIds);
/**
* 查询单据类型
*/
public DocumentTypePO getInfo(Long documentTypeId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.documentType.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.repository.todo.DocumentTypeDO;
import org.apache.ibatis.annotations.Param;
/**
* 单据类型Mapper接口
*
* @author gen
* @date 2024-06-18
*/
public interface DocumentTypeMapper extends BaseMapper<DocumentType>
{
/**
* 查询单据类型列表
*/
public List<DocumentTypePO> queryList(@Param("documentTypeDO") DocumentTypeDO documentTypeDO);
}
@@ -0,0 +1,81 @@
package com.mhd.bms.domain.documentType.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.facade.IDocumentTypeService;
import com.mhd.bms.domain.documentType.repository.mapper.DocumentTypeMapper;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.repository.todo.DocumentTypeDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 单据类型Service业务层处理
*
* @author gen
* @date 2024-06-18
*/
@Service
public class DocumentTypeImpl extends ServiceImpl<DocumentTypeMapper, DocumentType> implements IDocumentTypeService{
@Autowired
private DocumentTypeMapper documentTypeMapper;
/**
* 查询单据类型列表
*/
@Override
public List<DocumentTypePO> queryList(DocumentTypeDO documentTypeDO)
{
return documentTypeMapper.queryList(documentTypeDO);
}
/**
* 新增单据类型
*/
@Override
public Boolean insert(DocumentTypeDO documentTypeDO) {
DocumentType documentType = new DocumentType();
BeanUtils.copyProperties(documentTypeDO,documentType);
return this.save(documentType);
}
/**
* 修改单据类型
*/
@Override
public Boolean update(DocumentTypeDO documentTypeDO) {
DocumentType documentType = new DocumentType();
BeanUtils.copyProperties(documentTypeDO,documentType);
return this.updateById(documentType);
}
/**
* 批量删除单据类型
*/
@Override
public Boolean delete(Long[] documentTypeIds ) {
List<DocumentType> list = new ArrayList<>();
for (Long id : documentTypeIds) {
DocumentType documentType = new DocumentType();
documentType.setDocumentTypeId(id);
documentType.setDelFlag(2);
list.add(documentType);
}
return this.updateBatchById(list);
}
/**
* 修改单据类型
*/
@Override
public DocumentTypePO getInfo(Long documentTypeId) {
DocumentType documentType = this.getById(documentTypeId);
DocumentTypePO documentTypePO = new DocumentTypePO();
BeanUtils.copyProperties(documentType,documentTypePO);
return documentTypePO;
}
}
@@ -0,0 +1,70 @@
package com.mhd.bms.domain.documentType.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 单据类型对象 document_type
*
* @author gen
* @date 2024-06-18
*/
@Data
@ApiModel(value = "单据类型对象", description = "单据类型响应对象")
public class DocumentTypePO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("单据类型id")
private Long documentTypeId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty("参数json数组")
@Excel(name = "参数json数组")
private String formJson;
@ApiModelProperty("启用状态(1-启用,2-关闭)")
@Excel(name = "启用状态", readConverterExp = "1=-启用,2-关闭")
private Integer enablingStatus;
}
@@ -0,0 +1,84 @@
package com.mhd.bms.domain.documentType.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
import java.util.Set;
/**
* 单据类型对象 document_type
*
* @author gen
* @date 2024-06-18
*/
@Data
public class DocumentTypeDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("单据类型id")
private Long documentTypeId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("类型名称")
@Excel(name = "类型名称")
private String documentType;
@ApiModelProperty("类型编码")
@Excel(name = "类型编码")
private String documentTypeCode;
@ApiModelProperty("对接系统编码")
@Excel(name = "对接系统编码")
private String belongModuleCode;
@ApiModelProperty("对接系统")
@Excel(name = "对接系统")
private String belongModule;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty("参数json数组")
@Excel(name = "参数json数组")
private String formJson;
@ApiModelProperty("启用状态(1-启用,2-关闭)")
@Excel(name = "启用状态", readConverterExp = "1=-启用,2-关闭")
private Integer enablingStatus;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "单据Code集合")
private Set<String> documentTypeCodeSet;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty(name = "创建时间查询条件开始日期")
private String createTimeStart;
@ApiModelProperty(name = "创建时间查询条件结束日期")
private String createTimeEnd;
}
@@ -0,0 +1,74 @@
package com.mhd.bms.domain.documentType.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mhd.bms.domain.documentType.entity.DocumentType;
import com.mhd.bms.domain.documentType.repository.facade.IDocumentTypeService;
import com.mhd.bms.domain.documentType.repository.po.DocumentTypePO;
import com.mhd.bms.domain.documentType.repository.todo.DocumentTypeDO;
import com.mhd.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 单据类型
*
* @author gen
* @date 2024-06-18
*/
@Service
@Slf4j
public class DocumentTypeDomainService {
@Autowired
private IDocumentTypeService documentTypeService;
/**
* 分页查询单据类型列表
*/
public List<DocumentTypePO> queryList(DocumentTypeDO documentTypeDO) {
return documentTypeService.queryList(documentTypeDO);
}
/**
* 新增单据类型
*/
public Boolean insert(DocumentTypeDO documentTypeDO) {
return documentTypeService.insert(documentTypeDO);
}
/**
* 修改单据类型
*/
public Boolean update(DocumentTypeDO documentTypeDO) {
return documentTypeService.update(documentTypeDO);
}
/**
* 批量删除单据类型
*/
public Boolean delete(Long[] documentTypeIds) {
return documentTypeService.delete(documentTypeIds);
}
/**
* 获取单据类型详细信息
*/
public DocumentTypePO getInfo(Long documentTypeId)
{
return documentTypeService.getInfo(documentTypeId);
}
public DocumentType queryByCode(String documentTypeCode) {
LambdaQueryWrapper<DocumentType> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DocumentType::getDocumentTypeCode, documentTypeCode);
queryWrapper.eq(DocumentType::getTopOrganizationId, SecurityUtils.getLoginUser().getUserPo().getTopOrganizationId());
queryWrapper.eq(DocumentType::getDelFlag ,1);
return documentTypeService.getOne(queryWrapper);
}
}
@@ -0,0 +1,58 @@
package com.mhd.bms.domain.mappingMethod.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 方法映射对象 mapping_method
*
* @author gen
* @date 2024-07-12
*/
@Data
public class MappingMethod extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("方法映射表id")
@TableId(type = IdType.AUTO)
private Long mappingMethodId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("方法名称")
@Excel(name = "方法名称")
private String methodName;
@ApiModelProperty("映射方法")
@Excel(name = "映射方法")
private String mappingMethod;
@ApiModelProperty("类型(1-内置方法,2-逻辑语句)")
@Excel(name = "类型", readConverterExp = "1=-内置方法,2-逻辑语句")
private Integer mappingType;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.mappingMethod.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.mappingMethod.entity.MappingMethod;
import com.mhd.bms.domain.mappingMethod.repository.po.MappingMethodPO;
import com.mhd.bms.domain.mappingMethod.repository.todo.MappingMethodDO;
import java.util.List;
/**
* 方法映射Service接口
*
* @author gen
* @date 2024-07-12
*/
public interface IMappingMethodService extends IService<MappingMethod>
{
/**
* 分页查询方法映射列表
*/
public List<MappingMethodPO> queryList(MappingMethodDO mappingMethodDO);
/**
* 新增方法映射
*/
public Boolean insert(MappingMethodDO mappingMethodDO);
/**
* 修改方法映射
*/
public Boolean update(MappingMethodDO mappingMethodDO);
/**
* 批量删除方法映射
*/
public Boolean delete(Long[] mappingMethodIds);
/**
* 查询方法映射
*/
public MappingMethodPO getInfo(Long mappingMethodId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.mappingMethod.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.mappingMethod.entity.MappingMethod;
import com.mhd.bms.domain.mappingMethod.repository.po.MappingMethodPO;
import com.mhd.bms.domain.mappingMethod.repository.todo.MappingMethodDO;
import org.apache.ibatis.annotations.Param;
/**
* 方法映射Mapper接口
*
* @author gen
* @date 2024-07-12
*/
public interface MappingMethodMapper extends BaseMapper<MappingMethod>
{
/**
* 查询方法映射列表
*/
public List<MappingMethodPO> queryList(@Param("mappingMethodDO") MappingMethodDO mappingMethodDO);
}
@@ -0,0 +1,81 @@
package com.mhd.bms.domain.mappingMethod.repository.persistence;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mhd.bms.domain.mappingMethod.entity.MappingMethod;
import com.mhd.bms.domain.mappingMethod.repository.facade.IMappingMethodService;
import com.mhd.bms.domain.mappingMethod.repository.mapper.MappingMethodMapper;
import com.mhd.bms.domain.mappingMethod.repository.po.MappingMethodPO;
import com.mhd.bms.domain.mappingMethod.repository.todo.MappingMethodDO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* 方法映射Service业务层处理
*
* @author gen
* @date 2024-07-12
*/
@Service
public class MappingMethodImpl extends ServiceImpl<MappingMethodMapper, MappingMethod> implements IMappingMethodService{
@Autowired
private MappingMethodMapper mappingMethodMapper;
/**
* 查询方法映射列表
*/
@Override
public List<MappingMethodPO> queryList(MappingMethodDO mappingMethodDO)
{
return mappingMethodMapper.queryList(mappingMethodDO);
}
/**
* 新增方法映射
*/
@Override
public Boolean insert(MappingMethodDO mappingMethodDO) {
MappingMethod mappingMethod = new MappingMethod();
BeanUtils.copyProperties(mappingMethodDO,mappingMethod);
return this.save(mappingMethod);
}
/**
* 修改方法映射
*/
@Override
public Boolean update(MappingMethodDO mappingMethodDO) {
MappingMethod mappingMethod = new MappingMethod();
BeanUtils.copyProperties(mappingMethodDO,mappingMethod);
return this.updateById(mappingMethod);
}
/**
* 批量删除方法映射
*/
@Override
public Boolean delete(Long[] mappingMethodIds ) {
List<MappingMethod> list = new ArrayList<>();
for (Long id : mappingMethodIds) {
MappingMethod mappingMethod = new MappingMethod();
mappingMethod.setMappingMethodId(id);
mappingMethod.setDelFlag(2);
list.add(mappingMethod);
}
return this.updateBatchById(list);
}
/**
* 修改方法映射
*/
@Override
public MappingMethodPO getInfo(Long mappingMethodId) {
MappingMethod mappingMethod = this.getById(mappingMethodId);
MappingMethodPO mappingMethodPO = new MappingMethodPO();
BeanUtils.copyProperties(mappingMethod,mappingMethodPO);
return mappingMethodPO;
}
}
@@ -0,0 +1,58 @@
package com.mhd.bms.domain.mappingMethod.repository.po;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import com.mhd.common.core.web.domain.BaseVOEntity;
/**
* 方法映射对象 mapping_method
*
* @author gen
* @date 2024-07-12
*/
@Data
@ApiModel(value = "方法映射对象", description = "方法映射响应对象")
public class MappingMethodPO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("方法映射表id")
private Long mappingMethodId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("方法名称")
@Excel(name = "方法名称")
private String methodName;
@ApiModelProperty("映射方法")
@Excel(name = "映射方法")
private String mappingMethod;
@ApiModelProperty("类型(1-内置方法,2-逻辑语句)")
@Excel(name = "类型", readConverterExp = "1=-内置方法,2-逻辑语句")
private Integer mappingType;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
}
@@ -0,0 +1,64 @@
package com.mhd.bms.domain.mappingMethod.repository.todo;
import com.mhd.common.core.annotation.Excel;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.util.List;
/**
* 方法映射对象 mapping_method
*
* @author gen
* @date 2024-07-12
*/
@Data
public class MappingMethodDO extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("方法映射表id")
private Long mappingMethodId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("方法名称")
@Excel(name = "方法名称")
private String methodName;
@ApiModelProperty("映射方法")
@Excel(name = "映射方法")
private String mappingMethod;
@ApiModelProperty("类型(1-内置方法,2-逻辑语句)")
@Excel(name = "类型", readConverterExp = "1=-内置方法,2-逻辑语句")
private Integer mappingType;
@ApiModelProperty("备注")
@Excel(name = "备注")
private String remark;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("方法映射表ids")
private String mappingMethodIds;
}
@@ -0,0 +1,76 @@
package com.mhd.bms.domain.mappingMethod.service;
import cn.hutool.core.util.ObjectUtil;
import com.mhd.bms.domain.mappingMethod.repository.facade.IMappingMethodService;
import com.mhd.bms.domain.mappingMethod.repository.po.MappingMethodPO;
import com.mhd.bms.domain.mappingMethod.repository.todo.MappingMethodDO;
import com.mhd.common.core.exception.digitalLogisticsException.DigitalLogisticsException;
import com.mhd.common.core.exception.digitalLogisticsException.UserError;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List;
/**
* 方法映射
*
* @author gen
* @date 2024-07-12
*/
@Service
@Slf4j
public class MappingMethodDomainService {
@Autowired
private IMappingMethodService mappingMethodService;
/**
* 分页查询方法映射列表
*/
public List<MappingMethodPO> queryList(MappingMethodDO mappingMethodDO) {
return mappingMethodService.queryList(mappingMethodDO);
}
/**
* 新增方法映射
*/
public Boolean insert(MappingMethodDO mappingMethodDO) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
mappingMethodDO.setTopOrganizationId(loginUser.getUserPo().getTopOrganizationId());
mappingMethodDO.setOrganizationId(loginUser.getUserPo().getOrganizationId());
mappingMethodDO.setOrganizationName(loginUser.getUserPo().getOrganizationName());
return mappingMethodService.insert(mappingMethodDO);
}
/**
* 修改方法映射
*/
public Boolean update(MappingMethodDO mappingMethodDO) {
return mappingMethodService.update(mappingMethodDO);
}
/**
* 批量删除方法映射
*/
public Boolean delete(Long[] mappingMethodIds) {
return mappingMethodService.delete(mappingMethodIds);
}
/**
* 获取方法映射详细信息
*/
public MappingMethodPO getInfo(Long mappingMethodId)
{
return mappingMethodService.getInfo(mappingMethodId);
}
}
@@ -0,0 +1,50 @@
package com.mhd.bms.domain.paymentManage.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mhd.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import com.mhd.common.core.web.domain.BaseVOEntity;
import java.math.BigDecimal;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
/**
* 支付管理对象 payment_manage
*
* @author gen
* @date 2024-07-09
*/
@Data
public class PaymentManage extends BaseVOEntity{
private static final long serialVersionUID = 1L;
@ApiModelProperty("支付管理id")
@TableId(type = IdType.AUTO)
private Long paymentManageId;
@ApiModelProperty("一级组织表ID")
@Excel(name = "一级组织表ID")
private Long topOrganizationId;
@ApiModelProperty("组织表ID")
@Excel(name = "组织表ID")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("支付方式编码")
@Excel(name = "支付方式编码")
private String paymentMethodCode;
@ApiModelProperty("支付方式名称")
@Excel(name = "支付方式名称")
private String paymentMethod;
}
@@ -0,0 +1,43 @@
package com.mhd.bms.domain.paymentManage.repository.facade;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mhd.bms.domain.paymentManage.entity.PaymentManage;
import com.mhd.bms.domain.paymentManage.repository.po.PaymentManagePO;
import com.mhd.bms.domain.paymentManage.repository.todo.PaymentManageDO;
import java.util.List;
/**
* 支付管理Service接口
*
* @author gen
* @date 2024-07-09
*/
public interface IPaymentManageService extends IService<PaymentManage>
{
/**
* 分页查询支付管理列表
*/
public List<PaymentManagePO> queryList(PaymentManageDO paymentManageDO);
/**
* 新增支付管理
*/
public Boolean insert(PaymentManageDO paymentManageDO);
/**
* 修改支付管理
*/
public Boolean update(PaymentManageDO paymentManageDO);
/**
* 批量删除支付管理
*/
public Boolean delete(Long[] paymentManageIds);
/**
* 查询支付管理
*/
public PaymentManagePO getInfo(Long paymentManageId);
}
@@ -0,0 +1,22 @@
package com.mhd.bms.domain.paymentManage.repository.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mhd.bms.domain.paymentManage.entity.PaymentManage;
import com.mhd.bms.domain.paymentManage.repository.po.PaymentManagePO;
import com.mhd.bms.domain.paymentManage.repository.todo.PaymentManageDO;
import org.apache.ibatis.annotations.Param;
/**
* 支付管理Mapper接口
*
* @author gen
* @date 2024-07-09
*/
public interface PaymentManageMapper extends BaseMapper<PaymentManage>
{
/**
* 查询支付管理列表
*/
public List<PaymentManagePO> queryList(PaymentManageDO paymentManageDO);
}

Some files were not shown because too many files have changed in this diff Show More