Commit e5366a29 authored by zhangfeng's avatar zhangfeng

feat(wealth): 优化

parent 661c044a
......@@ -437,4 +437,6 @@ public interface ReceivableMapper extends AbstractMapper<ReceivableDO> {
List<ReceivableDO> selectBoxReceivablesByOrderIds(@Param("orderIds") Set<Long> orderIds);
List<Long> getAllBoxId();
List<Long> getDestWarehouseIdListByDestCity(@Param("destCity") List<Long> destCity);
}
\ No newline at end of file
......@@ -83,6 +83,8 @@ public class ReceivableBoxReportQueryVO {
private Boolean forceUpdateCache = false;
private List<String> selfNoList;
public Boolean isEmpty() {
return StringUtils.isBlank(selfNo)
&& (CollectionUtil.isEmpty(startWarehouseIdList))
......
......@@ -15,7 +15,7 @@ public class ReceivableCurrencyAmount {
public ReceivableCurrencyAmount(Long currencyId, BigDecimal amount) {
this.currencyId = currencyId;
this.amount = amount;
this.amount = amount.setScale(2, BigDecimal.ROUND_HALF_UP);
}
@Override
......@@ -32,6 +32,11 @@ public class ReceivableCurrencyAmount {
}
public void addAmount(BigDecimal amount) {
this.amount = this.amount.add(amount);
this.amount = this.amount.add(amount).setScale(2, BigDecimal.ROUND_HALF_UP);
}
@Override
public ReceivableCurrencyAmount clone() {
return new ReceivableCurrencyAmount(this.currencyId, this.amount);
}
}
\ No newline at end of file
......@@ -12,4 +12,5 @@ public class ReceivableIncomeBelong {
*/
private Integer incomeBelong;
private BigDecimal writeOffAmount;
private BigDecimal writeOffBaseAmount;
}
package cn.iocoder.yudao.module.wealth.controller.admin.job;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.redis.helper.RedisHelper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receivable.ReceivableMapper;
import cn.iocoder.yudao.module.wealth.service.receivable.ReceivableService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.List;
......@@ -19,12 +18,13 @@ import static cn.iocoder.yudao.module.wealth.enums.BoxReportConstant.BOX_AMOUNT_
@Component
@Slf4j
@AllArgsConstructor
public class BoxReportCacheLoader implements ApplicationRunner {
public class BoxReportCacheRefreshJob implements JobHandler {
private final ReceivableService receivableService;
private final ReceivableMapper receivableMapper;
private final RedisHelper redisHelper;
@Override
public void run(ApplicationArguments args) throws Exception {
public String execute(String param) {
log.info("初始化应收报表缓存");
try {
List<Long> boxIds = receivableMapper.getAllBoxId();
......@@ -33,10 +33,11 @@ public class BoxReportCacheLoader implements ApplicationRunner {
List<Long> cacheBoxIds = keys.stream().map(key -> Long.parseLong(key.replace(BOX_AMOUNT_CACHE, ""))).collect(Collectors.toList());
boxIds = boxIds.stream().filter(boxId -> !cacheBoxIds.contains(boxId)).collect(Collectors.toList());
}
receivableService.updateBoxAmountCache(boxIds, false);
receivableService.updateBoxAmountCache(boxIds, true);
} catch (Exception e) {
log.error("初始化应收报表缓存失败", e);
}
log.info("初始化应收报表缓存完成");
return "";
}
}
......@@ -108,7 +108,8 @@
SELECT
erwor.receivable_id,
erwor.income_belong,
SUM(erwor.receivable_write_off_amount) AS write_off_amount
IFNULL(SUM(erwor.receivable_write_off_amount), 0) AS write_off_amount
IFNULL(SUM(erwor.write_off_amount), 0) AS write_off_base_amount
FROM ecw_receivable_write_off_record erwor
LEFT JOIN ecw_receipt_item eri ON erwor.receipt_item_id = eri.id
WHERE
......
......@@ -486,12 +486,24 @@
<if test="query.selfNo != null and query.selfNo != '' ">
AND box.self_no LIKE concat('%',#{query.selfNo},'%')
</if>
<if test="query.selfNoList != null and query.selfNoList.size() > 0">
AND box.self_no IN
<foreach collection="query.selfNoList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.startWarehouseIdList != null and query.startWarehouseIdList.size() > 0">
AND box.start_warehouse_id IN
<foreach collection="query.startWarehouseIdList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.destCountryId != null and query.destCountryId.size() > 0">
AND box.dest_country_id IN
<foreach collection="query.destCountryId" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="query.destWarehouseIdList != null and query.destWarehouseIdList.size() > 0">
AND box.dest_warehouse_id IN
<foreach collection="query.destWarehouseIdList" item="item" open="(" separator="," close=")">
......@@ -569,4 +581,11 @@
<select id="getAllBoxId" resultType="java.lang.Long">
SELECT id FROM ecw_box WHERE deleted = 0 AND pr_status &gt; 21 AND dest_country_id > 0
</select>
<select id="getDestWarehouseIdListByDestCity" resultType="java.lang.Long">
SELECT id FROM ecw_warehouse WHERE deleted = 0
AND shi IN
<foreach collection="query.destCity" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment