ソースを参照

应收 应付 利润 总账修改 学校修改公式

lazhaoqian 3 年 前
コミット
3de24bd9e5

+ 0 - 10
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/vo/AccVO.java

@@ -33,14 +33,4 @@ import io.swagger.annotations.ApiModel;
 @ApiModel(value = "AccVO对象", description = "财务账单")
 public class AccVO extends Acc {
 	private static final long serialVersionUID = 1L;
-	/**
-	 * 制单日期日期开始
-	 */
-	@ApiModelProperty(value = "制单日期日期开始")
-	private String createTimeStart;
-	/**
-	 * 制单日期日期结束
-	 */
-	@ApiModelProperty(value = "制单日期日期结束")
-	private String createTimeEnd;
 }

+ 7 - 2
blade-service-api/trade-finance-api/src/main/java/org/springblade/finance/vojo/Acc.java

@@ -291,7 +291,7 @@ public class Acc implements Serializable {
 
 	@ApiModelProperty(value = "类型: 1.采购or销售主表货款申请 2. 采购or销售-费用明细申请")
 	@TableField("Src_type")
-	private int srcType;
+	private Integer srcType;
 
 	private String tradeType;
 
@@ -328,5 +328,10 @@ public class Acc implements Serializable {
 	@ApiModelProperty(value = "订单日期结束")
 	@TableField(exist = false)
 	private String accDateEnd;
-
+	/**
+	 * 未付金额
+	 */
+	@ApiModelProperty(value = "未付金额")
+	@TableField(exist = false)
+	private BigDecimal outstandingAmount;
 }

+ 2 - 2
blade-service/blade-school/src/main/java/org/springblade/school/service/impl/SalaryItemServiceImpl.java

@@ -2424,7 +2424,7 @@ public class SalaryItemServiceImpl extends ServiceImpl<SalaryItemMapper, SalaryI
 	public void countSalary(SalaryItem salaryItem){
 		//1. 基础工资 = +M153(校龄工资)+N153(增资)+O153(学历工资)+Q153(职级工资)+L153(履约奖)+R153(工资基数)
 		//2. 工作量工资 = 月份工作量工资+代课工作量工资+双休日工作量工资+工作量工资1+…+工作量工资5 --虚拟工作量工资标准-虚拟双休日工作量工资标准
-		//3.日常考核工资 =日常考核工资-虚拟日常考核标准
+		//3.日常考核工资
 		//4.绩效工资=学期绩效工资+学期绩效工资1+..+学期绩效工资5
 		//5.奖励工资=奖励1+…+奖励10
 		//6.职务津贴=领导干部补贴+领导干部考核补贴+备课组长+备课组长考核补贴+教研组长+教研组长考核补贴
@@ -2449,7 +2449,7 @@ public class SalaryItemServiceImpl extends ServiceImpl<SalaryItemMapper, SalaryI
 			//扣除项
 			item.setDeductions(item.getAttendance().add(item.getInspectorFines()).add(item.getTelephoneBill()).add(item.getLearningPower()).add(item.getDormitoryManagementFee()).add(item.getChildbirthAllowance()).add(item.getPauseNoPay()).add(item.getRibbonOne()).add(item.getRibbonTwo()).add(item.getRibbonThree()).add(item.getRibbonFour()).add(item.getRibbonFive()).add(item.getRibbonSix()).add(item.getRibbonSeven()).add(item.getRibbonEight()).add(item.getRibbonNine()));
 			//日常考核工资
-			item.setDailyAssessmentSalary(item.getDailyAssessmentSalary().subtract(item.getVirtualDailyAssessmentCriteria()));
+			//item.setDailyAssessmentSalary(item.getDailyAssessmentSalary().subtract(item.getVirtualDailyAssessmentCriteria()));
 			//应发工资  保险(个人部分)提取 享受公办待遇不减个人保险
 			if (StringUtils.isNotBlank(item.getEnjoyOfficeTreatment()) && item.getEnjoyOfficeTreatment().equals("是")){
 				item.setSalary(item.getBasicsSalary().add(item.getWorkloadSalary()).add(item.getDailyAssessmentSalary()).add(item.getAwardSalary()).add(item.getDutyAllowances()).add(item.getClassTeacherSubsidy())

+ 57 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/excel/DealWithItemExcel.java

@@ -0,0 +1,57 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 应付总账明细导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class DealWithItemExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 结算单位
+	 */
+	@ExcelProperty(value = "结算单位")
+	private String corpName;
+	/**
+	 * 订单号
+	 */
+	@ExcelProperty(value = "订单号")
+	private String accSysNo;
+	/**
+	 * 业务类型
+	 */
+	@ExcelProperty(value = "业务类型")
+	private String billType;
+	/**
+	 * 业务时间
+	 */
+	@ExcelProperty(value = "业务时间")
+	private Date accDate;
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "应付金额")
+	private BigDecimal amount;
+	/**
+	 * 结算金额
+	 */
+	@ExcelProperty(value = "实付金额")
+	private BigDecimal settlementAmount;
+	/**
+	 * 未收金额
+	 */
+	@ExcelProperty(value = "未付金额")
+	private BigDecimal outstandingAmount;
+}

+ 48 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/excel/ProfitExcel.java

@@ -0,0 +1,48 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 利润总账导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class ProfitExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 公司中文名
+	 */
+	@ExcelProperty(value = "结算单位")
+	private String corpName;
+	/**
+	 * 账单日期
+	 */
+	@ExcelProperty(value = "时间")
+	private Date accDate;
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "应收金额")
+	private BigDecimal amount;
+	/**
+	 * 利润总账中的应付金额
+	 */
+	@ExcelProperty(value = "利润总账中的应付金额")
+	private BigDecimal handleAmount;
+	/**
+	 * 利润金额
+	 */
+	@ExcelProperty(value = "利润金额")
+	private BigDecimal profitAmount;
+}

+ 68 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/excel/ProfitItemExcel.java

@@ -0,0 +1,68 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * 利润总账导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class ProfitItemExcel implements Serializable {
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 单据来源(收费/付费)
+	 */
+	@ExcelProperty(value = "单据来源")
+	private String dc;
+	/**
+	 * 结算单位
+	 */
+	@ExcelProperty(value = "结算单位")
+	private String corpName;
+	/**
+	 * 订单号
+	 */
+	@ExcelProperty(value = "订单号")
+	private String accSysNo;
+	/**
+	 * 费用名称
+	 */
+	@ExcelProperty(value = "费用名称")
+	private String itemName;
+	/**
+	 * 单价
+	 */
+	@ExcelProperty(value = "单价")
+	private BigDecimal price;
+	/**
+	 * 账单金额
+	 */
+	@ExcelProperty(value = "账单金额")
+	private BigDecimal amount;
+	/**
+	 * 结算金额
+	 */
+	@ExcelProperty(value = "结算金额")
+	private BigDecimal settlementAmount;
+	/**
+	 * 币别
+	 */
+	@ExcelProperty(value = "币别")
+	private String currency;
+	/**
+	 * 汇率
+	 */
+	@ExcelProperty(value = "汇率")
+	private BigDecimal exchangeRate;
+}

+ 56 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/excel/ReceivableItemExcle.java

@@ -0,0 +1,56 @@
+package org.springblade.finance.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+/**
+ * 应收总账明细导出
+ */
+@Data
+@ColumnWidth(25)
+@HeadRowHeight(20)
+@ContentRowHeight(18)
+public class ReceivableItemExcle implements Serializable {
+	private static final long serialVersionUID = 1L;
+	/**
+	 * 结算单位
+	 */
+	@ExcelProperty(value = "结算单位")
+	private String corpName;
+	/**
+	 * 订单号
+	 */
+	@ExcelProperty(value = "订单号")
+	private String accSysNo;
+	/**
+	 * 业务类型
+	 */
+	@ExcelProperty(value = "业务类型")
+	private String billType;
+	/**
+	 * 业务时间
+	 */
+	@ExcelProperty(value = "业务时间")
+	private Date accDate;
+	/**
+	 * 金额
+	 */
+	@ExcelProperty(value = "应收金额")
+	private BigDecimal amount;
+	/**
+	 * 结算金额
+	 */
+	@ExcelProperty(value = "实收金额")
+	private BigDecimal settlementAmount;
+	/**
+	 * 未收金额
+	 */
+	@ExcelProperty(value = "未收金额")
+	private BigDecimal outstandingAmount;
+}

+ 96 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/fince/DealWith.java

@@ -8,7 +8,9 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.entity.FeesDesc;
 import org.springblade.client.feign.ICorpsDescClient;
+import org.springblade.client.feign.IFeesDescClient;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
@@ -17,9 +19,11 @@ import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.finance.excel.DealWithExcel;
+import org.springblade.finance.excel.DealWithItemExcel;
 import org.springblade.finance.service.IAccService;
 import org.springblade.finance.vo.AccVO;
 import org.springblade.finance.vo.CostMessage;
+import org.springblade.finance.vojo.Acc;
 import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,6 +44,7 @@ public class DealWith extends BladeController {
 
 	private final IAccService accService;
 	private final ICorpsDescClient corpsDescClient;
+	private final IFeesDescClient iFeesDescClient;
 
 
 	/**
@@ -91,8 +96,99 @@ public class DealWith extends BladeController {
 		List<DealWithExcel> list = new ArrayList<>();
 		List<CostMessage> costMessageList = accService.salaryMessage(accVO);
 		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+			});
 			list = BeanUtil.copy(costMessageList, DealWithExcel.class);
 		}
 		ExcelUtil.export(response, "应付总账", "应付总账", list, DealWithExcel.class);
 	}
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "详情", notes = "传入acc")
+	public R detail(AccVO acc, Query query) {
+		if (StringUtils.isBlank(acc.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(acc.getDc())){
+			throw new SecurityException("请选择查询的收费类型");
+		}
+		if (acc.getCorpId() == null){
+			throw new SecurityException("请选择查询的客户");
+		}
+		acc.setTenantId(SecureUtil.getTenantId());
+		IPage<Acc> page = accService.page(Condition.getPage(query), Condition.getQueryWrapper(acc));
+		if (CollectionUtils.isNotEmpty(page.getRecords())){
+			page.getRecords().stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				item.setOutstandingAmount(item.getAmount().subtract(item.getSettlementAmount()));
+			});
+		}
+		return R.data(page);
+	}
+	/**
+	 * 导出-应付总账明细
+	 *
+	 * */
+	@GetMapping("/exportItem")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "应付总账明细")
+	public void exportItem(AccVO accVO, HttpServletResponse response) {
+		if (StringUtils.isBlank(accVO.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(accVO.getDc())){
+			throw new SecurityException("请选择查询的收费类型");
+		}
+		if (accVO.getCorpId() == null){
+			throw new SecurityException("请选择查询的明细");
+		}
+		if (StringUtils.isBlank(accVO.getTenantId())){
+			accVO.setTenantId(SecureUtil.getTenantId());
+		}
+		List<DealWithItemExcel> list = new ArrayList<>();
+		List<Acc> costMessageList = accService.list(Condition.getQueryWrapper(accVO));
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				item.setOutstandingAmount(item.getAmount().subtract(item.getSettlementAmount()));
+			});
+		}
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			list = BeanUtil.copy(costMessageList, DealWithItemExcel.class);
+		}
+		ExcelUtil.export(response, "应付总账明细", "应付总账明细", list, DealWithItemExcel.class);
+	}
 }

+ 151 - 3
blade-service/trade-finance/src/main/java/org/springblade/finance/fince/Profit.java

@@ -1,22 +1,40 @@
 package org.springblade.finance.fince;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.entity.FeesDesc;
 import org.springblade.client.feign.ICorpsDescClient;
+import org.springblade.client.feign.IFeesDescClient;
 import org.springblade.core.boot.ctrl.BladeController;
+import org.springblade.core.excel.util.ExcelUtil;
+import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
+import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.finance.excel.DealWithExcel;
+import org.springblade.finance.excel.DealWithItemExcel;
+import org.springblade.finance.excel.ProfitExcel;
+import org.springblade.finance.excel.ProfitItemExcel;
 import org.springblade.finance.service.IAccService;
 import org.springblade.finance.vo.AccVO;
 import org.springblade.finance.vo.CostMessage;
+import org.springblade.finance.vojo.Acc;
 import org.springblade.finance.vojo.Settlement;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 利润总账
  */
@@ -27,7 +45,7 @@ import org.springframework.web.bind.annotation.RestController;
 public class Profit extends BladeController {
 	private final IAccService accService;
 	private final ICorpsDescClient corpsDescClient;
-
+	private final IFeesDescClient iFeesDescClient;
 	/**
 	 * 分页 利润总账
 	 */
@@ -35,7 +53,137 @@ public class Profit extends BladeController {
 	@ApiOperationSupport(order = 1)
 	@ApiOperation(value = "利润总账分页", notes = "传入settlement")
 	public R<IPage<CostMessage>> list(AccVO accVO, Query query) {
-
-		return null;
+		if (StringUtils.isBlank(accVO.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(accVO.getTenantId())){
+			accVO.setTenantId(SecureUtil.getTenantId());
+		}
+		IPage<CostMessage> costMessageIPage = accService.salaryProfit(accVO, Condition.getPage(query));
+		if (CollectionUtils.isNotEmpty(costMessageIPage.getRecords())){
+			costMessageIPage.getRecords().stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+			});
+		}
+		return R.data(costMessageIPage);
+	}
+	/**
+	 * 导出-利润总账
+	 *
+	 * */
+	@GetMapping("/export")
+	@ApiOperationSupport(order = 2)
+	@ApiOperation(value = "利润总账")
+	public void export(AccVO accVO, HttpServletResponse response) {
+		if (StringUtils.isBlank(accVO.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(accVO.getTenantId())){
+			accVO.setTenantId(SecureUtil.getTenantId());
+		}
+		List<ProfitExcel> list = new ArrayList<>();
+		List<CostMessage> costMessageList = accService.salaryProfit(accVO);
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+			});
+			list = BeanUtil.copy(costMessageList, ProfitExcel.class);
+		}
+		ExcelUtil.export(response, "利润总账", "利润总账", list, ProfitExcel.class);
+	}
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "详情", notes = "传入acc")
+	public R detail(AccVO acc, Query query) {
+		if (StringUtils.isBlank(acc.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (acc.getCorpId() == null){
+			throw new SecurityException("请选择查询的明细");
+		}
+		acc.setTenantId(SecureUtil.getTenantId());
+		IPage<Acc> page = accService.page(Condition.getPage(query), Condition.getQueryWrapper(acc));
+		if (CollectionUtils.isNotEmpty(page.getRecords())){
+			page.getRecords().stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("d")){
+					item.setDc("收费");
+				}else if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("c")){
+					item.setDc("付费");
+				}
+			});
+		}
+		return R.data(page);
+	}
+	/**
+	 * 导出-利润总账明细
+	 *
+	 * */
+	@GetMapping("/exportItem")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "利润总账明细")
+	public void exportItem(AccVO accVO, HttpServletResponse response) {
+		if (StringUtils.isBlank(accVO.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (accVO.getCorpId() == null){
+			throw new SecurityException("请选择查询的明细");
+		}
+		if (StringUtils.isBlank(accVO.getTenantId())){
+			accVO.setTenantId(SecureUtil.getTenantId());
+		}
+		List<ProfitItemExcel> list = new ArrayList<>();
+		List<Acc> costMessageList = accService.list(Condition.getQueryWrapper(accVO));
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("d")){
+					item.setDc("收费");
+				}else if (StringUtils.isNotBlank(item.getDc()) && item.getDc().equals("c")){
+					item.setDc("付费");
+				}
+			});
+		}
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			list = BeanUtil.copy(costMessageList, ProfitItemExcel.class);
+		}
+		ExcelUtil.export(response, "利润总账明细", "利润总账明细", list, ProfitItemExcel.class);
 	}
 }

+ 97 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/fince/Receivable.java

@@ -8,7 +8,9 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import org.springblade.client.entity.CorpsDesc;
+import org.springblade.client.entity.FeesDesc;
 import org.springblade.client.feign.ICorpsDescClient;
+import org.springblade.client.feign.IFeesDescClient;
 import org.springblade.core.boot.ctrl.BladeController;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Condition;
@@ -17,10 +19,13 @@ import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.finance.excel.DealWithExcel;
+import org.springblade.finance.excel.DealWithItemExcel;
 import org.springblade.finance.excel.ReceivableExcle;
+import org.springblade.finance.excel.ReceivableItemExcle;
 import org.springblade.finance.service.IAccService;
 import org.springblade.finance.vo.AccVO;
 import org.springblade.finance.vo.CostMessage;
+import org.springblade.finance.vojo.Acc;
 import org.springblade.finance.vojo.Settlement;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -40,6 +45,7 @@ import java.util.List;
 public class Receivable extends BladeController {
 	private final IAccService accService;
 	private final ICorpsDescClient corpsDescClient;
+	private final IFeesDescClient iFeesDescClient;
 	/**
 	 * 分页 应收总账
 	 */
@@ -89,8 +95,99 @@ public class Receivable extends BladeController {
 		List<ReceivableExcle> list = new ArrayList<>();
 		List<CostMessage> costMessageList = accService.salaryMessage(accVO);
 		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+			});
 			list = BeanUtil.copy(costMessageList, ReceivableExcle.class);
 		}
 		ExcelUtil.export(response, "应收总账", "应收总账", list, ReceivableExcle.class);
 	}
+	/**
+	 * 详情
+	 */
+	@GetMapping("/detail")
+	@ApiOperationSupport(order = 3)
+	@ApiOperation(value = "详情", notes = "传入acc")
+	public R detail(AccVO acc, Query query) {
+		if (StringUtils.isBlank(acc.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(acc.getDc())){
+			throw new SecurityException("请选择查询的收费类型");
+		}
+		if (acc.getCorpId() == null){
+			throw new SecurityException("请选择查询的客户");
+		}
+		acc.setTenantId(SecureUtil.getTenantId());
+		IPage<Acc> page = accService.page(Condition.getPage(query), Condition.getQueryWrapper(acc));
+		if (CollectionUtils.isNotEmpty(page.getRecords())){
+			page.getRecords().stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				item.setOutstandingAmount(item.getAmount().subtract(item.getSettlementAmount()));
+			});
+		}
+		return R.data(page);
+	}
+	/**
+	 * 导出-应收总账明细
+	 *
+	 * */
+	@GetMapping("/exportItem")
+	@ApiOperationSupport(order = 4)
+	@ApiOperation(value = "应收总账明细")
+	public void exportItem(AccVO accVO, HttpServletResponse response) {
+		if (StringUtils.isBlank(accVO.getTradeType())){
+			throw new SecurityException("请选择查询的贸易类型");
+		}
+		if (StringUtils.isBlank(accVO.getDc())){
+			throw new SecurityException("请选择查询的收费类型");
+		}
+		if (accVO.getCorpId() == null){
+			throw new SecurityException("请选择查询的明细");
+		}
+		if (StringUtils.isBlank(accVO.getTenantId())){
+			accVO.setTenantId(SecureUtil.getTenantId());
+		}
+		List<ReceivableItemExcle> list = new ArrayList<>();
+		List<Acc> costMessageList = accService.list(Condition.getQueryWrapper(accVO));
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			costMessageList.stream().forEach(item ->{
+				if (item.getCorpId() != null){
+					R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(item.getCorpId());
+					if (corpMessage.isSuccess() && corpMessage.getData() != null){
+						item.setCorpName(corpMessage.getData().getCname());
+					}
+				}
+				//费用名称
+				if (StringUtils.isNotBlank(item.getCostType())) {
+					R<FeesDesc> detail = iFeesDescClient.detail(Long.valueOf(item.getCostType()));
+					if (detail.isSuccess() && detail.getData() != null) {
+						item.setItemName(detail.getData().getCname());
+					}
+				}
+				item.setOutstandingAmount(item.getAmount().subtract(item.getSettlementAmount()));
+			});
+		}
+		if (CollectionUtils.isNotEmpty(costMessageList)){
+			list = BeanUtil.copy(costMessageList, ReceivableItemExcle.class);
+		}
+		ExcelUtil.export(response, "应收总账明细", "应收总账明细", list, ReceivableItemExcle.class);
+	}
 }

+ 157 - 9
blade-service/trade-finance/src/main/java/org/springblade/finance/mapper/AccMapper.xml

@@ -61,29 +61,177 @@
 	    finance_acc
     WHERE
 	    is_deleted = 0
+        AND ( Corpid IS NOT NULL OR Corpid = '' )
         <if test="acc.tenantId!=null and acc.tenantId != ''">
-            AND tenant_id = #{tenantId}
+            AND tenant_id = #{acc.tenantId}
+        </if>
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
         </if>
         <if test="acc.tradeType!=null and acc.tradeType != ''">
-            AND trade_type = #{tradeType}
+            AND trade_type = #{acc.tradeType}
         </if>
         <if test="acc.itemType!=null and acc.itemType != ''">
-            AND item_type = #{itemType}
+            AND item_type = #{acc.itemType}
         </if>
         <if test="acc.dc!=null and acc.dc != ''">
-            AND DC = #{dc}
+            AND DC = #{acc.dc}
+        </if>
+        <if test="acc.accDateStart!=null and acc.accDateStart != ''">
+            AND create_time &gt;= #{acc.accDateStart}
         </if>
-        <if test="acc.createTimeStart!=null and acc.createTimeStart != ''">
-            AND create_time &lt;= #{createTimeStart}
+        <if test="acc.accDateEnd!=null and acc.accDateEnd != ''">
+            AND create_time &lt;= #{acc.accDateEnd}
         </if>
-        <if test="acc.createTimeEnd!=null and acc.createTimeEnd != ''">
-            AND create_time &gt;= #{createTimeEnd}
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
         </if>
     GROUP BY
 	    Corpid
     </select>
     <select id="salaryProfit" resultType="org.springblade.finance.vo.CostMessage">
-
+        SELECT
+	c.corpId AS corpId,
+	d.accDate AS accDate,
+	IFNULL( d.amount, 0 ) AS amount,
+	IFNULL( c.amount, 0 ) AS handleAmount,
+	IFNULL( d.amount, 0 ) - IFNULL( c.amount, 0 ) AS profitAmount
+FROM
+	(
+	SELECT
+		Corpid AS corpId,
+		create_time AS accDate,
+		IFNULL( SUM( Amount ), 0 ) AS amount
+	FROM
+		finance_acc
+	WHERE
+		is_deleted = 0
+		AND DC = 'c'
+		AND ( Corpid IS NOT NULL OR Corpid = '' )
+        <if test="acc.tenantId!=null and acc.tenantId != ''">
+            AND tenant_id = #{acc.tenantId}
+        </if>
+        <if test="acc.tradeType!=null and acc.tradeType != ''">
+            AND trade_type = #{acc.tradeType}
+        </if>
+        <if test="acc.itemType!=null and acc.itemType != ''">
+            AND item_type = #{acc.itemType}
+        </if>
+        <if test="acc.accDateStart!=null and acc.accDateStart != ''">
+            AND create_time &gt;= #{acc.accDateStart}
+        </if>
+        <if test="acc.accDateEnd!=null and acc.accDateEnd != ''">
+            AND create_time &lt;= #{acc.accDateEnd}
+        </if>
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
+        </if>
+	GROUP BY
+		Corpid
+	) c
+	LEFT JOIN (
+	SELECT
+		Corpid AS corpId,
+		create_time AS accDate,
+		IFNULL( SUM( Amount ), 0 ) AS amount
+	FROM
+		finance_acc
+	WHERE
+		is_deleted = 0
+		AND DC = 'd'
+		AND ( Corpid IS NOT NULL OR Corpid = '' )
+        <if test="acc.tenantId!=null and acc.tenantId != ''">
+            AND tenant_id = #{acc.tenantId}
+        </if>
+        <if test="acc.tradeType!=null and acc.tradeType != ''">
+            AND trade_type = #{acc.tradeType}
+        </if>
+        <if test="acc.itemType!=null and acc.itemType != ''">
+            AND item_type = #{acc.itemType}
+        </if>
+        <if test="acc.accDateStart!=null and acc.accDateStart != ''">
+            AND create_time &gt;= #{acc.accDateStart}
+        </if>
+        <if test="acc.accDateEnd!=null and acc.accDateEnd != ''">
+            AND create_time &lt;= #{acc.accDateEnd}
+        </if>
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
+        </if>
+	GROUP BY
+		Corpid
+	) d ON d.corpId = c.corpId UNION ALL
+SELECT
+	d.corpId AS corpId,
+	d.accDate AS accDate,
+	IFNULL( d.amount, 0 ) AS amount,
+	IFNULL( c.amount, 0 ) AS handleAmount,
+	IFNULL( d.amount, 0 ) - IFNULL( c.amount, 0 ) AS profitAmount
+FROM
+	(
+	SELECT
+		Corpid AS corpId,
+		create_time AS accDate,
+		IFNULL( SUM( Amount ), 0 ) AS amount
+	FROM
+		finance_acc
+	WHERE
+		is_deleted = 0
+		AND DC = 'd'
+		AND ( Corpid IS NOT NULL OR Corpid = '' )
+        <if test="acc.tenantId!=null and acc.tenantId != ''">
+            AND tenant_id = #{acc.tenantId}
+        </if>
+        <if test="acc.tradeType!=null and acc.tradeType != ''">
+            AND trade_type = #{acc.tradeType}
+        </if>
+        <if test="acc.itemType!=null and acc.itemType != ''">
+            AND item_type = #{acc.itemType}
+        </if>
+        <if test="acc.accDateStart!=null and acc.accDateStart != ''">
+            AND create_time &gt;= #{acc.accDateStart}
+        </if>
+        <if test="acc.accDateEnd!=null and acc.accDateEnd != ''">
+            AND create_time &lt;= #{acc.accDateEnd}
+        </if>
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
+        </if>
+	GROUP BY
+		Corpid
+	) d
+	LEFT JOIN (
+	SELECT
+		Corpid AS corpId,
+		create_time AS accDate,
+		IFNULL( SUM( Amount ), 0 ) AS amount
+	FROM
+		finance_acc
+	WHERE
+		is_deleted = 0
+		AND DC = 'c'
+		AND ( Corpid IS NOT NULL OR Corpid = '' )
+        <if test="acc.tenantId!=null and acc.tenantId != ''">
+            AND tenant_id = #{acc.tenantId}
+        </if>
+        <if test="acc.tradeType!=null and acc.tradeType != ''">
+            AND trade_type = #{acc.tradeType}
+        </if>
+        <if test="acc.itemType!=null and acc.itemType != ''">
+            AND item_type = #{acc.itemType}
+        </if>
+        <if test="acc.accDateStart!=null and acc.accDateStart != ''">
+            AND create_time &gt;= #{acc.accDateStart}
+        </if>
+        <if test="acc.accDateEnd!=null and acc.accDateEnd != ''">
+            AND create_time &lt;= #{acc.accDateEnd}
+        </if>
+        <if test="acc.corpId!=null">
+            AND Corpid = #{acc.corpId}
+        </if>
+	GROUP BY
+	Corpid
+	) c ON d.corpId = c.corpId
     </select>
 
 </mapper>

+ 12 - 0
blade-service/trade-finance/src/main/java/org/springblade/finance/service/IAccService.java

@@ -56,5 +56,17 @@ public interface IAccService extends IService<Acc> {
 	 * @return
 	 */
 	List<CostMessage> salaryMessage(AccVO accVO);
+	/**
+	 * 查询利润总账
+	 * @param accVO
+	 * @return
+	 */
+	IPage<CostMessage> salaryProfit(AccVO accVO,IPage<CostMessage> page);
+	/**
+	 * 查询利润总账
+	 * @param accVO
+	 * @return
+	 */
+	List<CostMessage> salaryProfit(AccVO accVO);
 
 }

+ 21 - 2
blade-service/trade-finance/src/main/java/org/springblade/finance/service/impl/AccServiceImpl.java

@@ -17,6 +17,7 @@
 package org.springblade.finance.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import io.seata.spring.annotation.GlobalTransactional;
 import lombok.AllArgsConstructor;
@@ -38,8 +39,8 @@ import org.springblade.purchase.sales.feign.IOrderItemsClient;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 财务账单 服务实现类
@@ -165,4 +166,22 @@ public class AccServiceImpl extends ServiceImpl<AccMapper, Acc> implements IAccS
 		return baseMapper.salaryMessage(accVO);
 	}
 
+	@Override
+	public IPage<CostMessage> salaryProfit(AccVO accVO, IPage<CostMessage> page) {
+		List<CostMessage> costMessages = baseMapper.salaryProfit(accVO, page);
+		if (CollectionUtils.isNotEmpty(costMessages)){
+			costMessages = costMessages.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CostMessage::getCorpId))), ArrayList::new));
+		}
+		return page.setRecords(costMessages);
+	}
+
+	@Override
+	public List<CostMessage> salaryProfit(AccVO accVO) {
+		List<CostMessage> costMessages = baseMapper.salaryProfit(accVO);
+		if (CollectionUtils.isNotEmpty(costMessages)){
+			costMessages = costMessages.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(CostMessage::getCorpId))), ArrayList::new));
+		}
+		return costMessages;
+	}
+
 }

+ 1 - 1
blade-service/trade-finance/src/main/resources/application-dev.yml

@@ -11,4 +11,4 @@ spring:
 #swagger文档
 swagger:
   base-packages:
-    - com.trade.finance
+    - org.springblade.finance