Browse Source

新增对账单核对功能

fgd 1 year ago
parent
commit
e6f0440f8e

+ 1 - 0
pom.xml

@@ -32,6 +32,7 @@
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
         <version>2.7.6</version>
+
     </parent>
 
     <!-- 依赖声明 -->

+ 8 - 1
sd-business/src/main/java/com/sd/business/controller/board/DailyBoardController.java

@@ -73,5 +73,12 @@ public class DailyBoardController {
         return dailyBoardService.getSelfOrderOutStorageInfo(dto);
     }
 
-
+    /**
+     * 核对对账单
+     * @return
+     */
+    @PostMapping("/checkStatementOfAccount")
+    public void checkStatementOfAccount(@Validated @RequestBody DailyBoardSelectDto dto) {
+        dailyBoardService.checkStatementOfAccount(dto);
+    }
 }

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

@@ -154,4 +154,12 @@ public class StatementOfAccountController {
         return statementOfAccountService.getOrderClassifyTotalCount(idList);
     }
 
+    /**
+     * 获取对账单未签核的数量
+     */
+    @PostMapping("/getNotCheckCount")
+    public Long getNotCheckCount() {
+        return statementOfAccountService.getNotCheckCount();
+    }
+
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/statement/dto/StatementOfAccountSelectDto.java

@@ -24,5 +24,10 @@ public class StatementOfAccountSelectDto extends BaseSelectDto {
      */
     private String code;
 
+    /**
+     * 核对状态 1 已核对,0 未核对
+     */
+    private Integer checkStatus;
+
 
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/statement/po/StatementOfAccount.java

@@ -42,4 +42,9 @@ public class StatementOfAccount extends BasePo {
      */
     private Integer type;
 
+    /**
+     * 核对状态 1 已核对,0 未核对
+     */
+    private Integer checkStatus;
+
 }

+ 5 - 0
sd-business/src/main/java/com/sd/business/entity/statement/vo/StatementOfAccountMergePageVo.java

@@ -44,4 +44,9 @@ public class StatementOfAccountMergePageVo {
      */
     private Integer orderQuantity;
 
+    /**
+     * 核对状态 1 已核对,0 未核对
+     */
+    private Integer checkStatus;
+
 }

+ 6 - 0
sd-business/src/main/java/com/sd/business/service/board/DailyBoardService.java

@@ -45,4 +45,10 @@ public interface DailyBoardService {
      * @return
      */
     SelfOrderOutStorageVo getSelfOrderOutStorageInfo(DailyBoardSelectDto dto);
+
+    /**
+     * 核对对账单
+     * @param dto
+     */
+    void checkStatementOfAccount(DailyBoardSelectDto dto);
 }

+ 42 - 0
sd-business/src/main/java/com/sd/business/service/board/impl/DailyBoardServiceImpl.java

@@ -3,8 +3,10 @@ package com.sd.business.service.board.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
+import com.ruoyi.common.constant.StatusConstant;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.core.domain.BasePo;
+import com.ruoyi.common.exception.ServiceException;
 import com.sd.business.entity.board.dto.DailyBoardSelectDto;
 import com.sd.business.entity.board.vo.*;
 import com.sd.business.entity.bom.bo.BomSpecBo;
@@ -18,6 +20,7 @@ import com.sd.business.entity.order.po.OrderSku;
 import com.sd.business.entity.outbound.po.OutboundOrder;
 import com.sd.business.entity.production.po.ProductionTask;
 import com.sd.business.entity.sku.po.SkuSpec;
+import com.sd.business.entity.statement.po.StatementOfAccount;
 import com.sd.business.service.board.DailyBoardService;
 import com.sd.business.service.bom.BomSpecService;
 import com.sd.business.service.department.DepartmentService;
@@ -28,6 +31,7 @@ import com.sd.business.service.order.OrderSkuService;
 import com.sd.business.service.outbound.OutboundOrderService;
 import com.sd.business.service.production.ProductionTaskService;
 import com.sd.business.service.sku.SkuSpecService;
+import com.sd.business.service.statement.StatementOfAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -68,6 +72,9 @@ public class DailyBoardServiceImpl implements DailyBoardService {
     @Autowired
     private DepartmentService departmentService;
 
+    @Autowired
+    private StatementOfAccountService statementOfAccountService;
+
 
     @Override
     public List<DailyBoardOutStorageBomVo> getProductionOutStorageList(DailyBoardSelectDto dto) {
@@ -526,4 +533,39 @@ public class DailyBoardServiceImpl implements DailyBoardService {
         vo.setOutStorageBomList(new ArrayList<>(outStorageBomMap.values()));
         return vo;
     }
+
+    @Override
+    public void checkStatementOfAccount(DailyBoardSelectDto dto) {
+        Date beginDate = DateUtil.beginOfDay(dto.getBeginDate());
+        Date endDate = DateUtil.endOfDay(dto.getEndDate());
+        // 查询佰卓和实业的事业部id
+        List<Department> departmentList = departmentService.list(q -> q.like(Department::getName, "实业").or().eq(Department::getName, "佰卓").select(BaseIdPo::getId));
+        List<Long> departmentIds = departmentList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
+        // 查询今日生成完成任务
+        List<ProductionTask> productionTaskList = productionTaskService.list(q -> q.between(ProductionTask::getCompleteTime, beginDate, endDate));
+        List<Long> orderIds = productionTaskList.stream().map(ProductionTask::getOrderId).collect(Collectors.toList());
+        long productionOrderCount = orderService.count(q -> q.in(OrderInfo::getDepartmentId, departmentIds).in(BaseIdPo::getId, orderIds));
+
+        // 查询今日出库单出库数据
+        List<OutboundOrder> outboundOrderList = outboundOrderService.list(q -> q.between(OutboundOrder::getOutboundTime, beginDate, endDate));
+        List<String> wlnCodes = outboundOrderList.stream().map(OutboundOrder::getOrderWlnCode).collect(Collectors.toList());
+        long wlnOrderCount = orderService.count(q -> q.in(OrderInfo::getDepartmentId, departmentIds).in(OrderInfo::getWlnCode, wlnCodes));
+        if (ObjectUtil.notEqual(productionOrderCount, wlnOrderCount)) {
+            throw new ServiceException("核对失败,订单总数存在差异!");
+        }
+
+        // 查询bom总数
+        BigDecimal productionBomQuantity = productionTaskList.stream().map(ProductionTask::getCompleteQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+        BigDecimal outboundBomQuantity = outboundOrderList.stream().map(OutboundOrder::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add);
+
+        if (ObjectUtil.notEqual(productionBomQuantity, outboundBomQuantity)) {
+            throw new ServiceException("核对失败,bom出库总数存在差异!");
+        }
+
+        // 更新对账单核对状态
+        statementOfAccountService.update(q -> q
+                .set(StatementOfAccount::getCheckStatus, StatusConstant.YES)
+                .in(StatementOfAccount::getDepartmentId, departmentIds)
+                .between(StatementOfAccount::getTimePeriod, beginDate, endDate));
+    }
 }

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

@@ -92,4 +92,10 @@ public interface StatementOfAccountService extends BaseService<StatementOfAccoun
      * @return
      */
     StatementOrderClassifyTotalCountVo getOrderClassifyTotalCount(List<Long> idList);
+
+    /**
+     * 获取未签核的数量
+     * @return
+     */
+    Long getNotCheckCount();
 }

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

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.constant.StatusConstant;
 import com.ruoyi.common.core.domain.BaseIdPo;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.exception.ServiceException;
@@ -155,6 +156,9 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
         Map<Long, List<OrderInfo>> map = orderService.mapKGroup(OrderInfo::getStatementOfAccountId,
                 q -> q.in(OrderInfo::getStatementOfAccountId, statementOfAccountIdList));
 
+        Map<Long, Integer> statementOfAccountMap = statementOfAccountService.mapKV(BaseIdPo::getId, StatementOfAccount::getCheckStatus,
+                q -> q.in(BaseIdPo::getId, statementOfAccountIdList));
+
         for (StatementOfAccountMergePageVo record : records) {
 
             String[] tempStatementOfAccountIdList = record.getIdGroupConcat().split(",");
@@ -176,6 +180,11 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
 
                 record.setOrderQuantity(record.getOrderQuantity() + tempOrderInfoList.size());
                 record.setReconcilingAmount(record.getReconcilingAmount().add(reconcilingAmount));
+
+                if (ObjectUtil.notEqual(record.getCheckStatus(), StatusConstant.NO)
+                        && ObjectUtil.equals(statementOfAccountMap.get(statementOfAccountId), StatusConstant.NO)) {
+                    record.setCheckStatus(StatusConstant.NO);
+                }
             }
 
         }
@@ -421,7 +430,7 @@ public class StatementOfAccountMergeServiceImpl implements StatementOfAccountMer
                             .skuSpecName(skuSpecBo.getSkuSpecName())
                             .spec(length + " * " + width + " * " + height)
                             .classifyName(skuSpecBo.getSkuClassifyName())
-                            .measuringUnit("pcs")
+                            .measuringUnit("PCS")
                             .quantity(item.getQuantity())
                             .salesUnitPrice(item.getUnitPrice()
                                     .add(item.getCustomProcessingFee())

+ 11 - 0
sd-business/src/main/java/com/sd/business/service/statement/impl/StatementOfAccountServiceImpl.java

@@ -11,6 +11,7 @@ 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;
@@ -102,6 +103,7 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         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);
@@ -536,6 +538,15 @@ public class StatementOfAccountServiceImpl extends ServiceImpl<StatementOfAccoun
         return orderService.getOrderClassifyTotalCount(idList);
     }
 
+    @Override
+    public Long getNotCheckCount() {
+        // 查询佰卓和实业的事业部id
+        List<Department> departmentList = departmentService.list(q -> q.like(Department::getName, "实业").or().eq(Department::getName, "佰卓").select(BaseIdPo::getId));
+        List<Long> departmentIds = departmentList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
+        return this.count(q -> q.in(StatementOfAccount::getDepartmentId, departmentIds)
+                .eq(StatementOfAccount::getCheckStatus, StatusConstant.NO));
+    }
+
     /**
      * 根据对账单id获取对账订单id列表
      */

+ 1 - 0
sd-business/src/main/resources/mapper/statement/StatementOfAccountMapper.xml

@@ -6,6 +6,7 @@
                soa.code,
                soa.department_id,
                soa.time_period,
+               soa.check_status,
                soa.create_time,
                d.name departmentName
         from statement_of_account soa