|
@@ -1,15 +1,19 @@
|
|
|
package com.sd.business.service.statement.impl;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.file.entity.FileInfoVo;
|
|
|
import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.ruoyi.common.constant.StatusConstant;
|
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.ruoyi.framework.config.ThreadPoolConfig;
|
|
|
import com.sd.business.entity.bom.bo.BomSpecBo;
|
|
|
import com.sd.business.entity.department.po.Department;
|
|
@@ -26,6 +30,7 @@ import com.sd.business.entity.statement.po.StatementOfAccount;
|
|
|
import com.sd.business.entity.statement.vo.DocumentByBomVo;
|
|
|
import com.sd.business.entity.statement.vo.DocumentByOrderVo;
|
|
|
import com.sd.business.entity.statement.vo.DocumentBySkuVo;
|
|
|
+import com.sd.business.entity.statement.vo.ReconciliationDetailVo;
|
|
|
import com.sd.business.entity.statement.vo.StatementOfAccountVo;
|
|
|
import com.sd.business.entity.statement.vo.StatementOrderClassifyTotalCountVo;
|
|
|
import com.sd.business.mapper.statement.StatementOfAccountMapper;
|
|
@@ -41,7 +46,6 @@ import com.sd.business.service.statement.StatementOfAccountService;
|
|
|
import com.sd.business.strategy.impl.DocumentByOrderExcelExportStrategy;
|
|
|
import com.sd.business.util.code.CodeEnum;
|
|
|
import com.sd.framework.util.Assert;
|
|
|
-import com.sd.framework.util.sql.Sql;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.security.core.context.SecurityContext;
|
|
@@ -109,27 +113,80 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
|
|
|
@Override
|
|
|
public Page<StatementOfAccountVo> getPage(StatementOfAccountSelectDto dto) {
|
|
|
|
|
|
- Page<StatementOfAccountVo> page = Sql.create(StatementOfAccountVo.class)
|
|
|
- .selectAll(StatementOfAccount.class)
|
|
|
- .from(StatementOfAccount.class)
|
|
|
- .orderByDesc(StatementOfAccount::getId)
|
|
|
- .page(dto);
|
|
|
+ IWrapper<StatementOfAccount> wrapper = getWrapper();
|
|
|
+ wrapper.like("soa", StatementOfAccount::getCode, dto.getCode());
|
|
|
+ wrapper.eq("soa", StatementOfAccount::getDepartmentId, dto.getDepartmentId());
|
|
|
+ wrapper.eq("soa", StatementOfAccount::getCheckStatus, dto.getCheckStatus());
|
|
|
+ wrapper.ge("soa", StatementOfAccount::getTimePeriod, dto.getBeginTime());
|
|
|
+ wrapper.le("soa", StatementOfAccount::getTimePeriod, dto.getEndTime());
|
|
|
+ wrapper.orderByDesc("soa", StatementOfAccount::getCode);
|
|
|
+
|
|
|
+ Page<StatementOfAccountVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ List<StatementOfAccountVo> records = page.getRecords();
|
|
|
+ if (records.isEmpty()) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询对账单和转帐凭证
|
|
|
+ List<Long> idList = records.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ Map<Long, List<FileInfoVo>> receiptFileMap = ObsFileUtil.getFileMap(idList, 1);
|
|
|
+ Map<Long, List<FileInfoVo>> proofFileMap = ObsFileUtil.getFileMap(idList, 2);
|
|
|
+
|
|
|
+ Map<Long, Map<String, Object>> map = orderInfoService.listMaps(Wrappers.<OrderInfo>query()
|
|
|
+ .select(
|
|
|
+ "statement_of_account_id as statementOfAccountId",
|
|
|
+ "sum(total_amount) as amount",
|
|
|
+ "count(0) as orderNum"
|
|
|
+ )
|
|
|
+ .in("statement_of_account_id", idList)
|
|
|
+ .groupBy("statement_of_account_id")
|
|
|
+ )
|
|
|
+ .stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ item -> Convert.toLong(item.get("statementOfAccountId")),
|
|
|
+ Function.identity()
|
|
|
+ ));
|
|
|
+
|
|
|
+ for (StatementOfAccountVo record : records) {
|
|
|
+ record.setReceiptFileList(receiptFileMap.getOrDefault(record.getId(), Collections.emptyList()));
|
|
|
+ record.setProofFileList(proofFileMap.getOrDefault(record.getId(), Collections.emptyList()));
|
|
|
+ Map<String, Object> tempMap = map.get(record.getId());
|
|
|
+ if (tempMap == null) {
|
|
|
+ record.setOrderNum(0);
|
|
|
+ record.setAmount(BigDecimal.ZERO);
|
|
|
+ } else {
|
|
|
+ record.setOrderNum(Convert.toInt(tempMap.get("orderNum"), 0));
|
|
|
+ record.setAmount(Convert.toBigDecimal(tempMap.get("amount"), BigDecimal.ZERO));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
return page;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public StatementOfAccountVo detail(Long id) {
|
|
|
-
|
|
|
- StatementOfAccountVo vo = Sql.create(StatementOfAccountVo.class)
|
|
|
- .selectAll(StatementOfAccount.class)
|
|
|
- .from(StatementOfAccount.class)
|
|
|
- .eq(StatementOfAccount::getId, id)
|
|
|
- .one();
|
|
|
+ public List<ReconciliationDetailVo> detail(Long id) {
|
|
|
+ List<OrderInfo> orderInfoList = orderInfoService.list(q -> q.eq(OrderInfo::getStatementOfAccountId, id));
|
|
|
+
|
|
|
+ List<ReconciliationDetailVo> result = orderInfoList.stream().map(item -> ReconciliationDetailVo.builder()
|
|
|
+ .orderId(item.getId())
|
|
|
+ .departmentId(item.getDepartmentId())
|
|
|
+ .orderCode(item.getCode())
|
|
|
+ .totalAmount(item.getTotalAmount())
|
|
|
+ .productTotalAmount(item.getProductTotalAmount())
|
|
|
+ .customProcessingFee(item.getCustomProcessingFee())
|
|
|
+ .lssueFee(item.getLssueFee())
|
|
|
+ .deliveryMaterialsFee(item.getDeliveryMaterialsFee())
|
|
|
+ .packingLabor(item.getPackingLabor())
|
|
|
+ .packagingMaterialCost(item.getPackagingMaterialCost())
|
|
|
+ .managementFee(item.getManagementFee())
|
|
|
+ .build()
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
|
|
- Assert.notNull(vo, "未知数据");
|
|
|
+ departmentService.attributeAssign(result, ReconciliationDetailVo::getDepartmentId, (item, department) -> {
|
|
|
+ item.setDepartmentName(department.getName());
|
|
|
+ });
|
|
|
|
|
|
- return vo;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|