Browse Source

修改周转率为百分比格式

fgd 1 year ago
parent
commit
84e30d5da8

+ 1 - 1
sd-business/src/main/java/com/sd/business/entity/apply/vo/ApplyBuyBomAccessoryVo.java

@@ -112,7 +112,7 @@ public class ApplyBuyBomAccessoryVo {
      */
     @ColumnWidth(15)
     @ExcelProperty(value = "周转率", index = 13)
-    private BigDecimal turnoverRate;
+    private String turnoverRate;
 
     /**
      * 备注

+ 1 - 1
sd-business/src/main/java/com/sd/business/entity/board/bo/OrderSalesShipmentStatisticsBo.java

@@ -57,5 +57,5 @@ public class OrderSalesShipmentStatisticsBo {
     /**
      * 周转率
      */
-    private BigDecimal turnoverRate;
+    private String turnoverRate;
 }

+ 1 - 1
sd-business/src/main/java/com/sd/business/entity/board/vo/InventoryTurnoverRateVo.java

@@ -35,5 +35,5 @@ public class InventoryTurnoverRateVo {
      */
     @ColumnWidth(15)
     @ExcelProperty(value = "周转率", index = 2)
-    private BigDecimal turnoverRate;
+    private String turnoverRate;
 }

+ 3 - 3
sd-business/src/main/java/com/sd/business/entity/board/vo/TurnoverRateStatisticsVo.java

@@ -52,7 +52,7 @@ public class TurnoverRateStatisticsVo {
      * 周转率
      */
     @ExcelProperty(value = "30天周转率", index = 5)
-    private BigDecimal turnoverRateThirtyDays;
+    private String turnoverRateThirtyDays;
 
     /**
      * 30天销售量
@@ -64,7 +64,7 @@ public class TurnoverRateStatisticsVo {
      * 周转率
      */
     @ExcelProperty(value = "60天周转率", index = 7)
-    private BigDecimal turnoverRateSixtyDays;
+    private String turnoverRateSixtyDays;
 
     /**
      * 60天销售量
@@ -76,7 +76,7 @@ public class TurnoverRateStatisticsVo {
      * 周转率
      */
     @ExcelProperty(value = "90天周转率", index = 9)
-    private BigDecimal turnoverRateNinetyDays;
+    private String turnoverRateNinetyDays;
 
     /**
      * 90天销售量

+ 1 - 1
sd-business/src/main/java/com/sd/business/entity/purchase/vo/PurchaseBomBoardVo.java

@@ -102,5 +102,5 @@ public class PurchaseBomBoardVo {
     /**
      * 周转率
      */
-    private BigDecimal turnoverRate;
+    private String turnoverRate;
 }

+ 1 - 1
sd-business/src/main/java/com/sd/business/entity/purchase/vo/PurchaseInTransitBomVo.java

@@ -109,7 +109,7 @@ public class PurchaseInTransitBomVo {
      */
     @ColumnWidth(20)
     @ExcelProperty(value = "周转率", index = 11)
-    private BigDecimal turnoverRate;
+    private String turnoverRate;
 
     /**
      * 库存数量

+ 2 - 2
sd-business/src/main/java/com/sd/business/service/apply/impl/ApplyBuyServiceImpl.java

@@ -212,7 +212,7 @@ public class ApplyBuyServiceImpl extends ServiceImpl<ApplyBuyMapper, ApplyBuy> i
         List<ApplyBuyBom> list = applyBuyBomService.list(q -> q.eq(ApplyBuyBom::getApplyBuyId, applyBuyId));
         List<Long> bomSpecIds = list.stream().map(ApplyBuyBom::getBomSpecId).collect(Collectors.toList());
         Map<Long, BomSpec> bomSpecMap = bomSpecService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, bomSpecIds));
-        Map<Long, BigDecimal> turnoverRateMap = orderSalesShipmentStatisticsService.getTurnoverRateMapByBomSpecIds(bomSpecIds);
+        Map<Long, String> turnoverRateMap = orderSalesShipmentStatisticsService.getTurnoverRateMapByBomSpecIds(bomSpecIds);
         // 在途数据
         List<PurchaseInTransitBomVo> purchaseBomInTransitList = purchaseBomService.getPurchaseBomInTransitSum(bomSpecIds);
         Map<Long, BigDecimal> inTransitMap = purchaseBomInTransitList.stream().collect(Collectors.toMap(PurchaseInTransitBomVo::getBomSpecId, PurchaseInTransitBomVo::getInTransitQuantity));
@@ -301,7 +301,7 @@ public class ApplyBuyServiceImpl extends ServiceImpl<ApplyBuyMapper, ApplyBuy> i
             vo.setActualSalesDays(actualSalesDays);
             vo.setShortageQuantity(shortageQuantity);
             vo.setApplyBuyQuantity(applyBuyBom.getQuantity());
-            vo.setTurnoverRate(turnoverRateMap.getOrDefault(applyBuyBom.getBomSpecId(), BigDecimal.ZERO));
+            vo.setTurnoverRate(turnoverRateMap.getOrDefault(applyBuyBom.getBomSpecId(), "0%"));
             accessoryList.add(vo);
         }
 

+ 2 - 2
sd-business/src/main/java/com/sd/business/service/board/impl/InventoryBoardServiceImpl.java

@@ -79,9 +79,9 @@ public class InventoryBoardServiceImpl implements InventoryBoardService {
         wrapper.eq("bs", BomSpec::getHeight, dto.getBomSpecHeight());
         wrapper.eq("bs", BomSpec::getColour, dto.getColour());
         if (Objects.equals(dto.getSortBy(), 1)) {
-            wrapper.orderByAsc("turnoverRate");
+            wrapper.orderByAsc("turnoverRateSort");
         } else {
-            wrapper.orderByDesc("turnoverRate");
+            wrapper.orderByDesc("turnoverRateSort");
         }
         long days = 30;
         if (dto.getBeginTime() != null && dto.getEndTime() != null) {

+ 1 - 2
sd-business/src/main/java/com/sd/business/service/order/OrderSalesShipmentStatisticsService.java

@@ -4,7 +4,6 @@ import com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo;
 import com.sd.business.entity.board.dto.TurnoverRateBoardSelectDto;
 import com.sd.business.entity.board.vo.TurnoverRateStatisticsVo;
 
-import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -38,5 +37,5 @@ public interface OrderSalesShipmentStatisticsService {
      *
      * @return
      */
-    Map<Long, BigDecimal> getTurnoverRateMapByBomSpecIds(List<Long> bomSpecIds);
+    Map<Long, String> getTurnoverRateMapByBomSpecIds(List<Long> bomSpecIds);
 }

+ 91 - 85
sd-business/src/main/java/com/sd/business/service/order/impl/OrderSalesShipmentStatisticsServiceImpl.java

@@ -59,7 +59,7 @@ public class OrderSalesShipmentStatisticsServiceImpl implements OrderSalesShipme
     @Override
     public Map<Long, OrderSalesShipmentStatisticsBo> getSalesShipmentStatisticsByDate(List<Long> bomSpecIds) {
         Date date = new Date();
-        Date startDate = DateUtil.offsetDay(date, -90);
+        Date startDate = DateUtil.beginOfDay(DateUtil.offsetDay(date, -90));
         IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
         wrapper.orderByDesc("os", OrderSku::getId);
         wrapper.between("oi", OrderInfo::getShippingTime, startDate, date);
@@ -71,9 +71,9 @@ public class OrderSalesShipmentStatisticsServiceImpl implements OrderSalesShipme
     @Override
     public List<TurnoverRateStatisticsVo> getTurnoverRateStatisticsList(TurnoverRateBoardSelectDto dto) {
         Date date = new Date();
-        String ninetyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -90));
-        String sixtyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -60));
-        String thirtyDaysDate = DateUtil.formatDateTime(DateUtil.offsetDay(date, -30));
+        String ninetyDaysDate = DateUtil.formatDate(DateUtil.offsetDay(date, -90));
+        String sixtyDaysDate = DateUtil.formatDate(DateUtil.offsetDay(date, -60));
+        String thirtyDaysDate = DateUtil.formatDate(DateUtil.offsetDay(date, -30));
 
         IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
         wrapper.orderByDesc("os", OrderSku::getId);
@@ -121,91 +121,97 @@ public class OrderSalesShipmentStatisticsServiceImpl implements OrderSalesShipme
                 .eq(Inventory::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
                 .in(Inventory::getBomSpecId, bomSpecIds));
 
-        List<TurnoverRateStatisticsVo> list = statisticsVoList.stream().map(item -> {
-            Long bomSpecId = item.getBomSpecId();
-            // 计算周转率
-            // 时间段库存周转天数 = 时间段天数 * (1 / 2) * (期初库存数量+期末库存数量) / 时间段销售量;
-            // 库存周转率 = 时间段天数 / 库存周转天数。
-            // 获取期初和期末数据
-            InventoryBackup beginBackupNinetyDays = beginBackupMap.getOrDefault(ninetyDaysDate, Collections.emptyMap()).get(bomSpecId);
-            InventoryBackup beginBackupSixtyDays = beginBackupMap.getOrDefault(sixtyDaysDate, Collections.emptyMap()).get(bomSpecId);
-            InventoryBackup beginBackupThirtyDays = beginBackupMap.getOrDefault(thirtyDaysDate, Collections.emptyMap()).get(bomSpecId);
-            Inventory endBackup = endBackupMap.get(bomSpecId);
-            // 计算bom近90、60、30天的期初库存数量
-            BigDecimal beginQuantityNinetyDays = BigDecimal.ZERO;
-            BigDecimal beginQuantitySixtyDays = BigDecimal.ZERO;
-            BigDecimal beginQuantityThirtyDays = BigDecimal.ZERO;
-            BigDecimal endQuantity = BigDecimal.ZERO;
-            if (beginBackupNinetyDays != null) {
-                beginQuantityNinetyDays = beginBackupNinetyDays.getQuantity()
-                        .add(beginBackupNinetyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupNinetyDays.getLockQuantity());
-            }
-            if (beginBackupSixtyDays != null) {
-                beginQuantitySixtyDays = beginBackupSixtyDays.getQuantity()
-                        .add(beginBackupSixtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupSixtyDays.getLockQuantity());
-            }
-            if (beginBackupThirtyDays != null) {
-                beginQuantityThirtyDays = beginBackupThirtyDays.getQuantity()
-                        .add(beginBackupThirtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupThirtyDays.getLockQuantity());
-            }
-            if (endBackup != null) {
-                endQuantity = endBackup.getQuantity().add(endBackup.getLockQuantity() == null ? BigDecimal.ZERO : endBackup.getLockQuantity());
-            }
-            // 时间段天数
-            BigDecimal days;
-            BigDecimal turnoverRateNinetyDays = BigDecimal.ZERO;
-            BigDecimal turnoverRateSixtyDays = BigDecimal.ZERO;
-            BigDecimal turnoverRateThirtyDays = BigDecimal.ZERO;
-            if (ObjectUtil.notEqual(item.getNinetyDaysSalesQuantity(), BigDecimal.ZERO)
-                    && ObjectUtil.notEqual(beginQuantityNinetyDays.add(endQuantity), BigDecimal.ZERO)) {
-                days = new BigDecimal(90);
-                turnoverRateNinetyDays = days
-                        .divide(days.multiply(new BigDecimal("0.5"))
-                                        .multiply(beginQuantityNinetyDays.add(endQuantity))
-                                        .divide(item.getNinetyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
-                                4, RoundingMode.HALF_UP);
-            }
-            if (ObjectUtil.notEqual(item.getSixtyDaysSalesQuantity(), BigDecimal.ZERO)
-                    && ObjectUtil.notEqual(beginQuantitySixtyDays.add(endQuantity), BigDecimal.ZERO)) {
-                days = new BigDecimal(60);
-                turnoverRateSixtyDays = days
-                        .divide(days.multiply(new BigDecimal("0.5"))
-                                        .multiply(beginQuantitySixtyDays.add(endQuantity))
-                                        .divide(item.getSixtyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
-                                4, RoundingMode.HALF_UP);
-            }
-            if (ObjectUtil.notEqual(item.getThirtyDaysSalesQuantity(), BigDecimal.ZERO)
-                    && ObjectUtil.notEqual(beginQuantityThirtyDays.add(endQuantity), BigDecimal.ZERO)) {
-                days = new BigDecimal(30);
-                turnoverRateThirtyDays = days
-                        .divide(days.multiply(new BigDecimal("0.5"))
-                                        .multiply(beginQuantityThirtyDays.add(endQuantity))
-                                        .divide(item.getThirtyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
-                                4, RoundingMode.HALF_UP);
-            }
-            if (ObjectUtil.equals(endQuantity, BigDecimal.ZERO)) {
-                return null;
-            }
-            TurnoverRateStatisticsVo vo = new TurnoverRateStatisticsVo();
-            vo.setBomSpecCode(item.getBomSpecCode());
-            vo.setBomSpecName(item.getBomSpecName());
-            vo.setWidth(item.getWidth());
-            vo.setHeight(item.getHeight());
-            vo.setChromatophore(bomChromatophoreMap.get(item.getChromatophore()));
-            vo.setSalesQuantityThirtyDays(item.getThirtyDaysSalesQuantity());
-            vo.setSalesQuantitySixtyDays(item.getSixtyDaysSalesQuantity());
-            vo.setSalesQuantityNinetyDays(item.getNinetyDaysSalesQuantity());
-            vo.setTurnoverRateNinetyDays(turnoverRateNinetyDays);
-            vo.setTurnoverRateSixtyDays(turnoverRateSixtyDays);
-            vo.setTurnoverRateThirtyDays(turnoverRateThirtyDays);
-            vo.setQuantity(endQuantity);
-            return vo;
-        }).filter(Objects::nonNull).sorted(comparing(TurnoverRateStatisticsVo::getTurnoverRateNinetyDays)).collect(Collectors.toList());
+        List<TurnoverRateStatisticsVo> list = statisticsVoList.stream()
+                .map(item -> {
+                    Long bomSpecId = item.getBomSpecId();
+                    // 计算周转率
+                    // 时间段库存周转天数 = 时间段天数 * (1 / 2) * (期初库存数量+期末库存数量) / 时间段销售量;
+                    // 库存周转率 = 时间段天数 / 库存周转天数。
+                    // 获取期初和期末数据
+                    InventoryBackup beginBackupNinetyDays = beginBackupMap.getOrDefault(ninetyDaysDate, Collections.emptyMap()).get(bomSpecId);
+                    InventoryBackup beginBackupSixtyDays = beginBackupMap.getOrDefault(sixtyDaysDate, Collections.emptyMap()).get(bomSpecId);
+                    InventoryBackup beginBackupThirtyDays = beginBackupMap.getOrDefault(thirtyDaysDate, Collections.emptyMap()).get(bomSpecId);
+                    Inventory endBackup = endBackupMap.get(bomSpecId);
+                    // 计算bom近90、60、30天的期初库存数量
+                    BigDecimal beginQuantityNinetyDays = BigDecimal.ZERO;
+                    BigDecimal beginQuantitySixtyDays = BigDecimal.ZERO;
+                    BigDecimal beginQuantityThirtyDays = BigDecimal.ZERO;
+                    BigDecimal endQuantity = BigDecimal.ZERO;
+                    if (beginBackupNinetyDays != null) {
+                        beginQuantityNinetyDays = beginBackupNinetyDays.getQuantity()
+                                .add(beginBackupNinetyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupNinetyDays.getLockQuantity());
+                    }
+                    if (beginBackupSixtyDays != null) {
+                        beginQuantitySixtyDays = beginBackupSixtyDays.getQuantity()
+                                .add(beginBackupSixtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupSixtyDays.getLockQuantity());
+                    }
+                    if (beginBackupThirtyDays != null) {
+                        beginQuantityThirtyDays = beginBackupThirtyDays.getQuantity()
+                                .add(beginBackupThirtyDays.getLockQuantity() == null ? BigDecimal.ZERO : beginBackupThirtyDays.getLockQuantity());
+                    }
+                    if (endBackup != null) {
+                        endQuantity = endBackup.getQuantity().add(endBackup.getLockQuantity() == null ? BigDecimal.ZERO : endBackup.getLockQuantity());
+                    }
+                    // 时间段天数
+                    BigDecimal days;
+                    BigDecimal turnoverRateNinetyDays = BigDecimal.ZERO;
+                    BigDecimal turnoverRateSixtyDays = BigDecimal.ZERO;
+                    BigDecimal turnoverRateThirtyDays = BigDecimal.ZERO;
+                    if (ObjectUtil.notEqual(item.getNinetyDaysSalesQuantity(), BigDecimal.ZERO)
+                            && ObjectUtil.notEqual(beginQuantityNinetyDays.add(endQuantity), BigDecimal.ZERO)) {
+                        days = new BigDecimal(90);
+                        turnoverRateNinetyDays = days
+                                .divide(days.multiply(new BigDecimal("0.5"))
+                                                .multiply(beginQuantityNinetyDays.add(endQuantity))
+                                                .divide(item.getNinetyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
+                                        4, RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(100));
+                    }
+                    if (ObjectUtil.notEqual(item.getSixtyDaysSalesQuantity(), BigDecimal.ZERO)
+                            && ObjectUtil.notEqual(beginQuantitySixtyDays.add(endQuantity), BigDecimal.ZERO)) {
+                        days = new BigDecimal(60);
+                        turnoverRateSixtyDays = days
+                                .divide(days.multiply(new BigDecimal("0.5"))
+                                                .multiply(beginQuantitySixtyDays.add(endQuantity))
+                                                .divide(item.getSixtyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
+                                        4, RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(100));
+                    }
+                    if (ObjectUtil.notEqual(item.getThirtyDaysSalesQuantity(), BigDecimal.ZERO)
+                            && ObjectUtil.notEqual(beginQuantityThirtyDays.add(endQuantity), BigDecimal.ZERO)) {
+                        days = new BigDecimal(30);
+                        turnoverRateThirtyDays = days
+                                .divide(days.multiply(new BigDecimal("0.5"))
+                                                .multiply(beginQuantityThirtyDays.add(endQuantity))
+                                                .divide(item.getThirtyDaysSalesQuantity(), 4, RoundingMode.HALF_UP),
+                                        4, RoundingMode.HALF_UP)
+                                .multiply(new BigDecimal(100));
+                    }
+                    if (ObjectUtil.equals(endQuantity, BigDecimal.ZERO)) {
+                        return null;
+                    }
+                    TurnoverRateStatisticsVo vo = new TurnoverRateStatisticsVo();
+                    vo.setBomSpecCode(item.getBomSpecCode());
+                    vo.setBomSpecName(item.getBomSpecName());
+                    vo.setWidth(item.getWidth());
+                    vo.setHeight(item.getHeight());
+                    vo.setChromatophore(bomChromatophoreMap.get(item.getChromatophore()));
+                    vo.setSalesQuantityThirtyDays(item.getThirtyDaysSalesQuantity());
+                    vo.setSalesQuantitySixtyDays(item.getSixtyDaysSalesQuantity());
+                    vo.setSalesQuantityNinetyDays(item.getNinetyDaysSalesQuantity());
+                    vo.setTurnoverRateNinetyDays(turnoverRateNinetyDays.stripTrailingZeros().toPlainString() + "%");
+                    vo.setTurnoverRateSixtyDays(turnoverRateSixtyDays.stripTrailingZeros().toPlainString() + "%");
+                    vo.setTurnoverRateThirtyDays(turnoverRateThirtyDays.stripTrailingZeros().toPlainString() + "%");
+                    vo.setQuantity(endQuantity);
+                    return vo;
+                }).filter(Objects::nonNull)
+                .sorted(comparing(item -> new BigDecimal(item.getTurnoverRateNinetyDays().replace("%", ""))))
+                .collect(Collectors.toList());
         return list;
     }
 
     @Override
-    public Map<Long, BigDecimal> getTurnoverRateMapByBomSpecIds(List<Long> bomSpecIds) {
+    public Map<Long, String> getTurnoverRateMapByBomSpecIds(List<Long> bomSpecIds) {
         IWrapper<OrderSku> wrapper = IWrapper.getWrapper();
         wrapper.in("oq.bom_spec_id", bomSpecIds);
         wrapper.groupBy("oq.bom_spec_id");

+ 6 - 1
sd-business/src/main/java/com/sd/business/service/purchase/impl/PurchaseBomServiceImpl.java

@@ -139,7 +139,7 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
         wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
         wrapper.apply("(pb.purchase_quantity + pb.return_quantity) > pb.arrival_quantity");
-        wrapper.orderByAsc("turnoverRate");
+        wrapper.orderByAsc("ifnull(btr.turnover_rate, 0)");
         wrapper.orderByAsc("pb", PurchaseBom::getId);
         Page<PurchaseInTransitBomVo> page = this.baseMapper.getPurchaseInTransitBomPage(dto.getPage(), wrapper);
         List<PurchaseInTransitBomVo> records = page.getRecords();
@@ -177,11 +177,16 @@ public class PurchaseBomServiceImpl extends ServiceImpl<PurchaseBomMapper, Purch
         IWrapper<PurchaseBom> wrapper = getWrapper();
         wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
         wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
+        if ("turnoverRate".equals(dto.getSortField())) {
+            dto.setSortField("ifnull(btr.turnover_rate, 0)");
+        }
+
         if (Objects.equals(dto.getSortBy(), 1)) {
             wrapper.orderByAsc(dto.getSortField());
         } else {
             wrapper.orderByDesc(dto.getSortField());
         }
+        wrapper.orderByDesc("bs", BomSpec::getId);
         Page<PurchaseBomBoardVo> bomSpecVoPage = this.baseMapper.getPurchaseBomBoardPage(dto.getPage(), wrapper);
         List<PurchaseBomBoardVo> records = bomSpecVoPage.getRecords();
         if (ObjectUtil.isEmpty(records)) {

+ 17 - 12
sd-business/src/main/resources/mapper/board/InventoryBoardMapper.xml

@@ -47,33 +47,38 @@
         select
             bs.name bomSpecName,
             bs.code bomSpecCode,
+            concat(round(${days} / (${days} * 0.5 * (
+                    (ibb.quantity + IFNULL(ibb.lock_quantity, 0))
+                    +
+                    (i.quantity + IFNULL(i.lock_quantity, 0))
+                ) / oq.quantity) * 100, 2), '%') turnoverRate,
             ${days} / (${days} * 0.5 * (
                     (ibb.quantity + IFNULL(ibb.lock_quantity, 0))
                         +
-                    (ibe.quantity + IFNULL(ibe.lock_quantity, 0))
-                ) / oq.quantity) turnoverRate
+                    (i.quantity + IFNULL(i.lock_quantity, 0))
+                ) / oq.quantity) * 100 turnoverRateSort
         from
             bom_spec bs
                 inner join bom b on bs.bom_id = b.id
                 inner join bom_classify bc on b.bom_classify_id = bc.id
                 inner join (
                     select
-                        osss.bom_spec_id,
-                        sum(osss.quantity) quantity
+                        os.bom_spec_id,
+                        sum(os.quantity) quantity
                     FROM
-                        order_sales_shipment_statistics osss
-                    where total_date >= date(date_sub(now(), INTERVAL ${days} + 1 day))
-                    group by osss.bom_spec_id
+                        order_info oi
+                            inner join order_sku  os on oi.id = os.order_id
+                    where oi.shipping_time >= date(date_sub(now(), INTERVAL ${days} day))
+                    group by os.bom_spec_id
                 ) oq on bs.id = oq.bom_spec_id
                 inner join inventory_backup ibb on bs.id = ibb.bom_spec_id
                     and ibb.backup_date = date(date_sub(now(), INTERVAL ${days} + 1 day))
                     and ibb.department_id = 0
                     and ibb.warehouse_id in (1684037244354052098, 1684037201379213314)
-                inner join inventory_backup ibe on bs.id = ibe.bom_spec_id
-                    and ibe.backup_date = date(date_sub(now(), INTERVAL 1 day))
-                    and ibe.department_id = 0
-                    and ibe.warehouse_id in (1684037244354052098, 1684037201379213314)
-                    and (ibe.quantity + IFNULL(ibe.lock_quantity, 0)) > 0
+                inner join inventory i on bs.id = i.bom_spec_id
+                    and i.department_id = 0
+                    and i.warehouse_id in (1684037244354052098, 1684037201379213314)
+                    and (i.quantity + IFNULL(i.lock_quantity, 0)) > 0
             ${ew.customSqlSegment}
     </select>
 

+ 6 - 6
sd-business/src/main/resources/mapper/order/OrderSalesShipmentStatisticsMapper.xml

@@ -10,9 +10,9 @@
             bs.width,
             bs.height,
             b.chromatophore,
-            sum(case when oi.shipping_time >= date_sub(now(), interval 90 day) then os.quantity else 0 end) ninetyDaysSalesQuantity,
-            sum(case when oi.shipping_time >= date_sub(now(), interval 60 day) then os.quantity else 0 end) sixtyDaysSalesQuantity,
-            sum(case when oi.shipping_time >= date_sub(now(), interval 30 day) then os.quantity else 0 end) thirtyDaysSalesQuantity
+            sum(case when oi.shipping_time >= date(date_sub(now(), interval 90 day)) then os.quantity else 0 end) ninetyDaysSalesQuantity,
+            sum(case when oi.shipping_time >= date(date_sub(now(), interval 60 day)) then os.quantity else 0 end) sixtyDaysSalesQuantity,
+            sum(case when oi.shipping_time >= date(date_sub(now(), interval 30 day)) then os.quantity else 0 end) thirtyDaysSalesQuantity
         from
             order_info oi
                 inner join order_sku os on oi.id = os.order_id
@@ -25,14 +25,14 @@
     <select id="getTurnoverRateMapByBomSpecIds" resultType="com.sd.business.entity.board.bo.OrderSalesShipmentStatisticsBo">
         select
             oq.bom_spec_id,
-            ifnull(90 / (90 * 0.5 *
+            concat(ifnull(90 / (90 * 0.5 *
                   (ifnull(ib.quantity, 0)
                       +
                   ifnull(ib.lock_quantity, 0)
                       +
                   ifnull(i.quantity, 0)
                       +
-                  ifnull(i.lock_quantity, 0)) / oq.quantity), 0) turnover_rate
+                  ifnull(i.lock_quantity, 0)) / oq.quantity) * 100, 0), '%') turnover_rate
         from (
              select
                  os.bom_spec_id,
@@ -40,7 +40,7 @@
              FROM
                  order_info oi
                      inner join order_sku  os on oi.id = os.order_id
-             where oi.shipping_time >= date_sub(now(), INTERVAL 90 day)
+             where oi.shipping_time >= date(date_sub(now(), INTERVAL 90 day))
              group by os.bom_spec_id
         ) oq
             left join inventory_backup ib on oq.bom_spec_id = ib.bom_spec_id

+ 6 - 6
sd-business/src/main/resources/mapper/purchase/PurchaseBomMapper.xml

@@ -87,7 +87,7 @@
             pb.purchase_quantity,
             pb.purchase_quantity - pb.arrival_quantity + pb.return_quantity inTransitQuantity,
             p.delivery_date,
-            ifnull(btr.turnover_rate, 0) turnoverRate,
+            concat(ifnull(round(btr.turnover_rate, 2), 0), '%') turnoverRate,
             ifnull(btr.quantity, 0) salesQuantity
         from
             purchase_bom pb
@@ -106,7 +106,7 @@
                                +
                           ifnull(i.quantity, 0)
                                +
-                          ifnull(i.lock_quantity, 0)) / oq.quantity) turnover_rate,
+                          ifnull(i.lock_quantity, 0)) / oq.quantity) * 100 turnover_rate,
                     oq.quantity
                 from (
                      select
@@ -115,7 +115,7 @@
                      FROM
                          order_info oi
                          inner join order_sku  os on oi.id = os.order_id
-                         where oi.shipping_time >= date_sub(now(), INTERVAL 90 day)
+                         where oi.shipping_time >= date(date_sub(now(), INTERVAL 90 day))
                     group by os.bom_spec_id
                 ) oq
                 left join inventory_backup ib on oq.bom_spec_id = ib.bom_spec_id
@@ -169,7 +169,7 @@
             bs.height,
             ifnull((i.quantity + ifnull(i.lock_quantity, 0)) / ((ifnull(osq.quantity, 0) + ifnull(osbq.quantity, 0)) / 7), 0) predictOutStorageDays,
             ifnull(pd.next_delivery_days, 0) nextDeliveryDays,
-            ifnull(btr.turnover_rate, 0) turnoverRate
+            concat(ifnull(round(btr.turnover_rate, 2), 0), '%') turnoverRate
         FROM
             bom_spec bs
             left join inventory i on bs.id = i.bom_spec_id and department_id = 0 and warehouse_id in (1684037244354052098, 1684037201379213314)
@@ -220,7 +220,7 @@
                               +
                           ifnull(i.quantity, 0)
                               +
-                          ifnull(i.lock_quantity, 0)) / oq.quantity) turnover_rate
+                          ifnull(i.lock_quantity, 0)) / oq.quantity) * 100 turnover_rate
                 from (
                     select
                         os.bom_spec_id,
@@ -228,7 +228,7 @@
                     FROM
                         order_info oi
                         inner join order_sku  os on oi.id = os.order_id
-                    where oi.shipping_time >= date_sub(now(), INTERVAL 90 day)
+                    where oi.shipping_time >= date(date_sub(now(), INTERVAL 90 day))
                     group by os.bom_spec_id
                 ) oq
                 left join inventory_backup ib on oq.bom_spec_id = ib.bom_spec_id