| | |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import zy.cloud.wms.manager.entity.DiffLog; |
| | | import zy.cloud.wms.manager.entity.DocLog; |
| | | import zy.cloud.wms.manager.service.DiffLogService; |
| | | import zy.cloud.wms.manager.service.DocLogService; |
| | | import zy.cloud.wms.manager.service.MatService; |
| | | |
| | | import java.util.Date; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | |
| | | public class DetectionScheduler { |
| | | |
| | | @Autowired |
| | | private MatService matService; |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | @Autowired |
| | | private DocLogService docLogService; |
| | | @Autowired |
| | | private DiffLogService diffLogService; |
| | | |
| | | /** |
| | | * 订单转历史档处理器 |
| | | */ |
| | | @Scheduled(cron = "0/10 * * * * ? ") |
| | | @Scheduled(cron = "0 0 1 * * ?") |
| | | public void orderBeLogExecute(){ |
| | | Date now = new Date(); |
| | | List<String> matnrList = jdbcTemplate.queryForList("select distinct matnr from man_mat", String.class); |
| | | for (String matnr : matnrList) { |
| | | // 查找立库库存 |
| | |
| | | for (DocLog docLog : docLogs) { |
| | | // 防止重复单据 |
| | | if (set.contains(docLog.getDocNum())) { |
| | | break; |
| | | continue; |
| | | } |
| | | set.add(docLog.getDocNum()); |
| | | int docId = Math.toIntExact(docLog.getDocId()); |
| | | // 计算库存 |
| | | switch (docId) { |
| | | case 6: |
| | | |
| | | break; |
| | | case 9: |
| | | break; |
| | | case 11: |
| | | stock = stock - docLog.getQua(); |
| | | break; |
| | | case 14: |
| | | break; |
| | | case 34: |
| | | stock = stock + docLog.getQua(); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | } |
| | | // 比较差异值 |
| | | if (stock != total) { |
| | | // todo |
| | | DiffLog diffLog = new DiffLog( |
| | | matnr, // 商品编号[非空] |
| | | stock, // erp数量 |
| | | total, // wms数量 |
| | | asrsAnfme, // 立库 |
| | | wmsAnfme, // 平仓 |
| | | Math.abs(total-stock), // 差异值 |
| | | now, // 添加事件 |
| | | null // 备注 |
| | | ); |
| | | if (!diffLogService.insert(diffLog)) { |
| | | log.error("{}商品数量差异!且保存失败!", matnr); |
| | | } |
| | | } |
| | | |
| | | |