Browse Source

Merge remote-tracking branch 'origin/master'

24282 1 year ago
parent
commit
746fb23c1d

+ 8 - 0
sd-business/src/main/java/com/sd/business/controller/statement/StatementOfAccountController.java

@@ -146,4 +146,12 @@ public class StatementOfAccountController {
         return statementOfAccountService.getOrderWlnCodeStr(idList);
     }
 
+    /**
+     * 获取对账单订单分类总计
+     */
+    @PostMapping("/getOrderClassifyTotalCount")
+    public StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(@RequestBody List<Long> idList) {
+        return statementOfAccountService.getOrderClassifyTotalCount(idList);
+    }
+
 }

+ 3 - 1
sd-business/src/main/java/com/sd/business/entity/inventory/po/Inventory.java

@@ -40,13 +40,15 @@ public class Inventory extends BasePo {
     /**
      * 锁定库存
      */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "锁定库存", index = 5)
     private BigDecimal lockQuantity;
 
     /**
      * 数量
      */
     @ColumnWidth(15)
-    @ExcelProperty(value = "库存", index = 4)
+    @ExcelProperty(value = "可用库存", index = 4)
     private BigDecimal quantity;
 
     /**

+ 9 - 1
sd-business/src/main/java/com/sd/business/entity/inventory/vo/InventoryVo.java

@@ -50,7 +50,15 @@ public class InventoryVo extends Inventory {
      * 结存总价
      */
     @ColumnWidth(15)
-    @ExcelProperty(value = "结存总价", index = 5)
+    @ExcelProperty(value = "结存总价", index = 6)
     private BigDecimal totalPrice;
 
+
+    /**
+     * 总库存
+     */
+    @ColumnWidth(15)
+    @ExcelProperty(value = "总库存", index = 7)
+    private BigDecimal totalQuantity;
+
 }

+ 40 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/StatementOrderClassifyTotalCountVo.java

@@ -0,0 +1,40 @@
+package com.sd.business.entity.statement.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 对账单订单分类数量总计查询返回值实体
+ *
+ * @author
+ * @since 2023-10-17
+ */
+@Getter
+@Setter
+public class StatementOrderClassifyTotalCountVo {
+
+    /**
+     * 万里牛订单数量
+     */
+    private Integer wlnOrderCount;
+
+    /**
+     * 采购订单数量
+     */
+    private Integer purchaseOrderCount;
+
+    /**
+     * 委外订单数量
+     */
+    private Integer outsourceOrderCount;
+
+    /**
+     * 售后订单数量
+     */
+    private Integer afterSaleOrderCount;
+
+    /**
+     * 无理由订单数量
+     */
+    private Integer noReasonOrderCount;
+}

+ 8 - 0
sd-business/src/main/java/com/sd/business/mapper/order/OrderMapper.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.vo.OrderInfoVo;
+import com.sd.business.entity.statement.vo.StatementOrderClassifyTotalCountVo;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
@@ -36,4 +37,11 @@ public interface OrderMapper extends BaseMapper<OrderInfo> {
      * @return
      */
     BigDecimal getOrderSkuBomOutStorageQuantity(@Param("ew") IWrapper<OrderInfo> wrapper);
+
+    /**
+     * 获取订单分类数量总计
+     * @param wrapper
+     * @return
+     */
+    StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(@Param("ew") IWrapper<OrderInfo> wrapper);
 }

+ 6 - 0
sd-business/src/main/java/com/sd/business/service/inventory/impl/InventoryServiceImpl.java

@@ -349,6 +349,11 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
 
     @Override
     public void exportBackExcel(InventorySelectDto dto) {
+        Date backupDate = dto.getBackupDate();
+        if (backupDate == null) {
+            throw new ServiceException("备份日期不能为空");
+        }
+        dto.setBackupDate(DateUtil.offsetDay(backupDate, -1));
         dto.setPageNum(1);
         dto.setPageSize(999999999);
         IWrapper<Inventory> wrapper = getDtoWrapper(dto);
@@ -658,6 +663,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
         wrapper.like("bs", BomSpec::getColour, dto.getBomSpecColour());
         wrapper.like("bs", BomSpec::getLength, dto.getBomSpecLength());
         wrapper.like("bs", BomSpec::getWidth, dto.getBomSpecWidth());
+        wrapper.notIn("bs", BomSpec::getCode, Arrays.asList("40904003", "409001"));
         wrapper.eq("i", Inventory::getWarehouseId, dto.getWarehouseId());
         wrapper.eq("i", Inventory::getDepartmentId, dto.getDepartmentId());
         wrapper.eq("i", InventoryBackup::getBackupDate, dto.getBackupDate());

+ 8 - 0
sd-business/src/main/java/com/sd/business/service/order/OrderService.java

@@ -10,9 +10,11 @@ import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.vo.CompareVo;
 import com.sd.business.entity.order.vo.OrderInfoVo;
 import com.sd.business.entity.order.vo.SkuSpecPriceVo;
+import com.sd.business.entity.statement.vo.StatementOrderClassifyTotalCountVo;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * <p>
@@ -140,4 +142,10 @@ public interface OrderService extends BaseService<OrderInfo> {
      * @param id
      */
     void cancelSuspendOrder(Long id);
+
+    /**
+     * 获取订单分类数量总计
+     * @return
+     */
+    StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(List<Long> statementIds);
 }

+ 8 - 0
sd-business/src/main/java/com/sd/business/service/order/impl/OrderServiceImpl.java

@@ -40,6 +40,7 @@ import com.sd.business.entity.price.po.PriceBillingStandard;
 import com.sd.business.entity.price.po.PriceBillingStandardDetail;
 import com.sd.business.entity.sku.po.SkuSpec;
 import com.sd.business.entity.statement.po.StatementOfAccount;
+import com.sd.business.entity.statement.vo.StatementOrderClassifyTotalCountVo;
 import com.sd.business.entity.warehouse.constant.WarehouseConstant;
 import com.sd.business.mapper.order.OrderMapper;
 import com.sd.business.service.bom.BomService;
@@ -1011,6 +1012,13 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, OrderInfo> implem
                 .eq(BaseIdPo::getId, id));
     }
 
+    @Override
+    public StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(List<Long> statementIds) {
+        IWrapper<OrderInfo> wrapper = getWrapper();
+        wrapper.in("o", OrderInfo::getStatementOfAccountId, statementIds);
+        return this.baseMapper.getOrderClassifyTotalCount(wrapper);
+    }
+
     /**
      * 删除订单以及订单关联数据
      */

+ 6 - 0
sd-business/src/main/java/com/sd/business/service/statement/StatementOfAccountService.java

@@ -86,4 +86,10 @@ public interface StatementOfAccountService extends BaseService<StatementOfAccoun
      */
     String getOrderWlnCodeStr(List<Long> idList);
 
+    /**
+     * 获取对账单订单分类总计
+     * @param idList
+     * @return
+     */
+    StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(List<Long> idList);
 }

+ 3 - 2
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountExportServiceImpl.java

@@ -2,6 +2,7 @@ package com.sd.business.service.statement.impl;
 
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
+import com.sd.business.entity.order.enums.OrderClassifyEnum;
 import com.sd.business.entity.statement.vo.DocumentByBomVo;
 import com.sd.business.entity.statement.vo.DocumentBySkuVo;
 import com.sd.business.service.statement.StatementOfAccountExportService;
@@ -37,7 +38,7 @@ public class StatementOfAccountExportServiceImpl implements StatementOfAccountEx
         map.put("totalQuantity", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getQuantity));
         map.put("totalSubtotal", StreamUtil.bigDecimalAdd(list, DocumentBySkuVo::getSubtotal));
 
-        TemplateExcelUtil.writeBrowser("skuDocument.xlsx", "sku对账单", response, list, map);
+        TemplateExcelUtil.writeBrowser("skuDocument.xlsx", OrderClassifyEnum.getEnum(orderClassify).getValue() + "-sku对账单", response, list, map);
     }
 
     @Override
@@ -57,7 +58,7 @@ public class StatementOfAccountExportServiceImpl implements StatementOfAccountEx
         map.put("totalPackingLaborSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getPackingLaborSummary));
         map.put("totalManagementFeeSummary", StreamUtil.bigDecimalAdd(list, DocumentByBomVo::getManagementFeeSummary));
 
-        TemplateExcelUtil.writeBrowser("bomDocument.xlsx", "bom对账单", response, list, map);
+        TemplateExcelUtil.writeBrowser("bomDocument.xlsx", OrderClassifyEnum.getEnum(orderClassify).getValue() + "-bom对账单", response, list, map);
     }
 
 }

+ 2 - 1
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountMergeServiceImpl.java

@@ -14,6 +14,7 @@ import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.PageUtils;
 import com.sd.business.entity.excel.enums.ExcelTypeEnum;
 import com.sd.business.entity.inventory.po.InventoryFinishedOrderDetail;
+import com.sd.business.entity.order.enums.OrderClassifyEnum;
 import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.po.OrderSku;
 import com.sd.business.entity.order.po.OrderSkuProductionCost;
@@ -221,7 +222,7 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
             case 3:
                 excelGenerateLogService.generateExcel(ExcelTypeEnum.STATISTICS_DOCUMENT_BY_ORDER,
                         new DocumentByOrderExcelExportStrategy(idList, departmentName, beginDate, endDate, orderClassify),
-                        DateUtil.formatDate(new Date()) + " 对账报表");
+                        DateUtil.formatDate(new Date()) + " " + OrderClassifyEnum.getEnum(orderClassify).getValue() + "-订单对账报表");
                 break;
             default:
                 throw new ServiceException("未知对账单类型");

+ 9 - 38
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountServiceImpl.java

@@ -18,6 +18,7 @@ import com.ruoyi.framework.config.ThreadPoolConfig;
 import com.sd.business.entity.bom.bo.BomSpecBo;
 import com.sd.business.entity.department.po.Department;
 import com.sd.business.entity.excel.enums.ExcelTypeEnum;
+import com.sd.business.entity.order.enums.OrderClassifyEnum;
 import com.sd.business.entity.order.po.OrderInfo;
 import com.sd.business.entity.order.po.OrderSku;
 import com.sd.business.entity.order.po.OrderSkuBom;
@@ -262,9 +263,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         // 获取订单sku
         List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
 
-        // 查询委外订单
-        Map<Long, OrderInfo> map = orderService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, orderIdList).eq(OrderInfo::getType, 2));
-
         // 生成结果集
         List<DocumentBySkuVo> documentBySkuVoList = orderSkuList.stream()
                 .map(item -> DocumentBySkuVo.builder()
@@ -282,13 +280,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                         .build())
                 .peek(item -> item.setSubtotal(ObjectUtil.equals(item.getQuantity(), BigDecimal.ZERO) ? item.getUnitPrice() : item.getQuantity().multiply(item.getUnitPrice())))
                 .peek(item -> item.setTotal(item.getSubtotal()))
-                .peek(item -> {
-                    // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
-                    OrderInfo orderInfo = map.get(item.getOrderId());
-                    if (ObjectUtil.isNotEmpty(orderInfo)) {
-                        item.setQuantity(BigDecimal.ZERO);
-                    }
-                })
                 .collect(Collectors.toList());
 
         // 赋值sku规格品名和品号
@@ -323,9 +314,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
             return Collections.emptyList();
         }
 
-        // 查询委外订单
-        Map<Long, OrderInfo> map = orderService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, orderIdList).eq(OrderInfo::getType, 2));
-
         // 获取订单sku
         List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
 
@@ -356,13 +344,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                                 .add(item.getManagementFeeSummary())
                 ))
                 .peek(item -> item.setTotal(item.getSubtotal()))
-                .peek(item -> {
-                    // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
-                    OrderInfo orderInfo = map.get(item.getOrderId());
-                    if (ObjectUtil.isNotEmpty(orderInfo)) {
-                        item.setQuantity(BigDecimal.ZERO);
-                    }
-                })
                 .collect(Collectors.toList());
 
         // 赋值主材bom品名品号
@@ -534,7 +515,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
             case 3:
                 excelGenerateLogService.generateExcel(ExcelTypeEnum.STATISTICS_DOCUMENT_BY_ORDER,
                         new DocumentByOrderExcelExportStrategy(idList, departmentName, date, date, orderClassify),
-                        DateUtil.formatDate(new Date()) + " 对账单");
+                        DateUtil.formatDate(new Date()) + " " + OrderClassifyEnum.getEnum(orderClassify).getValue() + "-订单对账单");
                 break;
             default:
                 throw new ServiceException("未知对账单类型");
@@ -549,6 +530,12 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         return JSON.toJSONString(wlnCodeList);
     }
 
+    @Override
+    public StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(List<Long> idList) {
+        Assert.notEmpty(idList, "对账单id不能为空");
+        return orderService.getOrderClassifyTotalCount(idList);
+    }
+
     /**
      * 根据对账单id获取对账订单id列表
      */
@@ -564,10 +551,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
      */
     private List<DocumentByOrderVo.SkuSpec> getSkuSpecList(List<OrderSku> orderSkuList) {
 
-        List<Long> orderIdList = orderSkuList.stream().map(OrderSku::getOrderId).collect(Collectors.toList());
-        // 查询委外订单
-        Map<Long, OrderInfo> map = orderService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, orderIdList).eq(OrderInfo::getType, 2));
-
         List<DocumentByOrderVo.SkuSpec> skuSpecList = orderSkuList.stream()
                 .map(item -> {
                     DocumentByOrderVo.SkuSpec skuSpec = new DocumentByOrderVo.SkuSpec();
@@ -585,14 +568,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                     return skuSpec;
                 })
                 .peek(item -> item.setSubtotal(item.getQuantity().multiply(item.getUnitPrice())))
-                .peek(item -> {
-
-                    OrderInfo tempOrderInfo = map.get(item.getOrderId());
-                    // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
-                    if (ObjectUtil.isNotEmpty(tempOrderInfo)) {
-                        item.setQuantity(BigDecimal.ZERO);
-                    }
-                })
                 .collect(Collectors.toList());
 
         skuSpecService.attributeAssign(skuSpecList, DocumentByOrderVo.SkuSpec::getSkuSpecId, (item, skuSpec) -> {
@@ -607,8 +582,6 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
      * 获取订单bom
      */
     private List<DocumentByOrderVo.BomSpec> getBomSpecList(List<Long> orderIdList, List<OrderSku> orderSkuList) {
-        // 查询委外订单
-        Map<Long, OrderInfo> orderMap = orderService.mapKEntity(BaseIdPo::getId, q -> q.in(BaseIdPo::getId, orderIdList).eq(OrderInfo::getType, 2));
 
         // 主材
         List<DocumentByOrderVo.BomSpec> bomSpecList = orderSkuList.stream()
@@ -616,9 +589,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
                     DocumentByOrderVo.BomSpec bomSpec = new DocumentByOrderVo.BomSpec();
                     bomSpec.setOrderSkuId(item.getId());
                     bomSpec.setBomSpecId(item.getBomSpecId());
-                    // 判断是否是委外订单,如果是委外订单时将bom数量修改为0
-                    bomSpec.setQuantity(ObjectUtil.isNotEmpty(orderMap.get(item.getOrderId()))
-                            ? BigDecimal.ZERO : item.getQuantity());
+                    bomSpec.setQuantity(item.getQuantity());
                     bomSpec.setUnitPrice(item.getUnitPrice());
                     bomSpec.setCustomProcessingType(item.getCustomProcessingType());
                     bomSpec.setLaserLogoSummary((Objects.equals(item.getCustomProcessingType(), "20")

+ 6 - 2
sd-business/src/main/resources/mapper/inventory/InventoryMapper.xml

@@ -8,11 +8,13 @@
                i.bom_spec_id,
                i.balance_unit_price,
                i.quantity,
+               ifnull(i.lock_quantity, 0) lockQuantity,
                i.department_id,
                w.name  warehouseName,
                bs.name bomSpecName,
                bs.code bomSpecCode,
-               d.name  departmentName
+               d.name  departmentName,
+               i.quantity + ifnull(i.lock_quantity, 0) totalQuantity
         from ${tableName} i
                  left join bom_spec bs on i.bom_spec_id = bs.id
                  left join bom b on bs.bom_id = b.id
@@ -80,12 +82,14 @@
                i.bom_spec_id,
                i.balance_unit_price,
                i.quantity,
+               ifnull(i.lock_quantity, 0)        lockQuantity,
                i.department_id,
                w.name                            warehouseName,
                bs.name                           bomSpecName,
                bs.code                           bomSpecCode,
                d.name                            departmentName,
-               i.quantity * i.balance_unit_price totalPrice
+               i.quantity * i.balance_unit_price totalPrice,
+               i.quantity + ifnull(i.lock_quantity, 0)      totalQuantity
         from inventory i
                  left join bom_spec bs on i.bom_spec_id = bs.id
                  left join bom b on bs.bom_id = b.id

+ 12 - 0
sd-business/src/main/resources/mapper/order/OrderMapper.xml

@@ -76,4 +76,16 @@
                 LEFT JOIN order_sku_bom osb on os.id = osb.order_sku_id
                 ${ew.customSqlSegment}
        </select>
+
+       <select id="getOrderClassifyTotalCount" resultType="com.sd.business.entity.statement.vo.StatementOrderClassifyTotalCountVo">
+            select
+                sum(case when o.classify = 1 then 1 else 0 end) as wlnOrderCount,
+                sum(case when o.classify = 2 then 1 else 0 end) as purchaseOrderCount,
+                sum(case when o.classify = 3 then 1 else 0 end) as outsourceOrderCount,
+                sum(case when o.classify = 4 then 1 else 0 end) as afterSaleOrderCount,
+                sum(case when o.classify = 5 then 1 else 0 end) as noReasonOrderCount
+            from
+                order_info o
+                ${ew.customSqlSegment}
+       </select>
 </mapper>