New file |
| | |
| | | package zy.cloud.wms.common.service.task; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.manager.entity.DocLog; |
| | | import zy.cloud.wms.manager.service.DocLogService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * Created by vincent on 2021/9/3 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class DetectionScheduler { |
| | | |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | @Autowired |
| | | private DocLogService docLogService; |
| | | |
| | | /** |
| | | * 订单转历史档处理器 |
| | | */ |
| | | @Scheduled(cron = "0/10 * * * * ? ") |
| | | public void orderBeLogExecute(){ |
| | | List<String> matnrList = jdbcTemplate.queryForList("select distinct matnr from man_mat", String.class); |
| | | for (String matnr : matnrList) { |
| | | // 查找立库库存 |
| | | double asrsAnfme = jdbcTemplate.queryForObject("select isnull(sum(anfme), 0) from asr_loc_detl where matnr ='" + matnr + "'", Double.class); |
| | | // 查找平仓库存 |
| | | double wmsAnfme = jdbcTemplate.queryForObject("select isnull(sum(anfme), 0) from man_loc_detl where matnr ='" + matnr + "'", Double.class); |
| | | double total = asrsAnfme + wmsAnfme; |
| | | // 单据库存 |
| | | List<DocLog> docLogs = docLogService.selectList(new EntityWrapper<DocLog>().eq("matnr", matnr)); |
| | | |
| | | double stock = 0.0D; |
| | | Set<String> set = new HashSet<>(); |
| | | for (DocLog docLog : docLogs) { |
| | | // 防止重复单据 |
| | | if (set.contains(docLog.getDocNum())) { |
| | | break; |
| | | } |
| | | set.add(docLog.getDocNum()); |
| | | int docId = Math.toIntExact(docLog.getDocId()); |
| | | // 计算库存 |
| | | switch (docId) { |
| | | case 6: |
| | | |
| | | break; |
| | | case 9: |
| | | break; |
| | | case 11: |
| | | break; |
| | | case 14: |
| | | break; |
| | | case 34: |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | // 比较差异值 |
| | | if (stock != total) { |
| | | // todo |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | } |