| | |
| | | package com.zy.third.lk.task; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.DocType; |
| | | import com.zy.asrs.entity.Mat; |
| | | import com.zy.asrs.entity.Order; |
| | | import com.zy.asrs.entity.OrderDetl; |
| | | import com.zy.asrs.entity.param.OpenOrderCompleteParam; |
| | | import com.zy.asrs.entity.result.OpenOrderCompeteResult; |
| | | import com.zy.asrs.service.DocTypeService; |
| | | import com.zy.asrs.service.MatService; |
| | | import com.zy.asrs.service.OrderDetlService; |
| | | import com.zy.asrs.service.OrderService; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.service.erp.ErpSqlServer; |
| | | import com.zy.third.lk.entity.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 入库更新完成回报 |
| | |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | @Scheduled(cron = "${erp.refreshtime}") |
| | | public void pakinOrderComplete() { |
| | | log.info("开始入库更新完成回报"); |
| | | // 所有订单 |
| | | List<Order> orders = orderService.selectList(new EntityWrapper<Order>().eq("settle", 4L)); |
| | | DocType docType; |
| | | for (Order order : orders) { |
| | | System.out.println(order); |
| | | docType = docTypeService.selectById(order.getDocType()); |
| | | if (docType == null) { |
| | | log.error("该订单类型不存在:" + order.getDocType()); |
| | |
| | | * @param orderDetl |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertInDet(OrderDetl orderDetl) { |
| | | String sqlInDetTb = "select * from lk_InDetTB where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | List<InDetTB> inDets = erpSqlServer.select(sqlInDetTb, InDetTB.class); |
| | | String sqlInDetTbBak = "select * from lk_InDetTB_Bak where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | List<InDetTB> inDetBaks = erpSqlServer.select(sqlInDetTbBak, InDetTB.class); |
| | | if (inDets.size() > 0 || inDetBaks.size() > 0) { |
| | | List<InDetTBBak> inDetBaks = erpSqlServer.select(sqlInDetTbBak, InDetTBBak.class); |
| | | if (!inDets.isEmpty() || !inDetBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | | return true; |
| | | } |
| | | Mat mat = matService.selectByMatnr(orderDetl.getMatnr()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + orderDetl.getOrderNo() + "'"); |
| | | content.put("ItemId", "'" + orderDetl.getThreeCode() + "'"); |
| | | content.put("ItemCode", "'" + orderDetl.getMatnr() + "'"); |
| | | content.put("proType", "'" + orderDetl.getSpecs() + "'"); |
| | | content.put("remark", "'" + orderDetl.getMemo() + "'"); |
| | | content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | content.put("ItemBatch", "'" + orderDetl.getBatch() + "'"); |
| | | content.put("iNo", orderDetl.getId()); |
| | | content.put("DetId", orderDetl.getAutoId()); |
| | | content.put("MainNum", orderDetl.getQty()); |
| | | content.put("LKName", "'中扬二期'"); |
| | | Map<String, Object> content = getMap(orderDetl); |
| | | int insert = erpSqlServer.insert(InDetTB.class, content); |
| | | |
| | | if (insert == 1) { |
| | | log.info("入库单表身回传成功:" + content.toString()); |
| | | log.info("入库单表身回传成功:{}", content); |
| | | return true; |
| | | } else { |
| | | log.error("入库回传失败,实体类打印:" + content.toString()); |
| | | log.error("入库回传失败,实体类打印:{}", content); |
| | | return false; |
| | | } |
| | | |
| | |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertInHed(Order order) { |
| | | String sqlInHedTb = "select * from lk_InHedTB where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | List<InHedTB> outHeds = erpSqlServer.select(sqlInHedTb, InHedTB.class); |
| | | String sqlInHedTbBak = "select * from lk_InHedTB_Bak where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | List<InHedTB> inHedBaks = erpSqlServer.select(sqlInHedTbBak, InHedTB.class); |
| | | if (outHeds.size() > 0 || inHedBaks.size() > 0) { |
| | | List<InHedTBBak> inHedBaks = erpSqlServer.select(sqlInHedTbBak, InHedTBBak.class); |
| | | if (!outHeds.isEmpty() || !inHedBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | | return true; |
| | | } |
| | |
| | | content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | content.put("Remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'中扬'"); |
| | | content.put("LKName", "'中扬二期'"); |
| | | int insert = erpSqlServer.insert(InHedTB.class, content); |
| | | String sql = "UPDATE lk_InHedTB SET bPass = 1, LKName='中扬二期' WHERE BillNo = '" + order.getOrderNo() + "'"; |
| | | int update = erpSqlServer.update(sql); |
| | | if (update == 1) { |
| | | log.info("入库单表头回传成功:" + content.toString()); |
| | | log.info("入库单表头回传成功:" + content); |
| | | return true; |
| | | } else { |
| | | log.error("入库单表头回传失败:" + content.toString()); |
| | | log.error("入库单表头回传失败:" + content); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | * @param orderDetl |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertOutDet(OrderDetl orderDetl) { |
| | | String sqlInDetTb = "select * from lk_OutDetTB where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | |
| | | String sqlInDetTbBak = "select * from lk_OutDetTB_Bak where BillNo='" + orderDetl.getOrderNo() + "' and " + |
| | | " ItemId='" + orderDetl.getMatnr() + "' and ItemBatch='" + orderDetl.getBatch() + "' and proType='" + orderDetl.getSpecs() + "'"; |
| | | List<OutDetTBBak> inDetBaks = erpSqlServer.select(sqlInDetTbBak, OutDetTBBak.class); |
| | | if (inDets.size() > 0 || inDetBaks.size() > 0) { |
| | | if (!inDets.isEmpty() || !inDetBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表身已存在:" + orderDetl.getOrderNo() + "==>>" + orderDetl.getOrderNo()); |
| | | return true; |
| | | } |
| | | Mat mat = matService.selectByMatnr(orderDetl.getMatnr()); |
| | | HashMap<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + orderDetl.getOrderNo() + "'"); |
| | | content.put("ItemId", "'" + orderDetl.getThreeCode() + "'"); |
| | | content.put("ItemCode", "'" + orderDetl.getMatnr() + "'"); |
| | | content.put("proType", "'" + orderDetl.getSpecs() + "'"); |
| | | content.put("remark", "'" + orderDetl.getMemo() + "'"); |
| | | content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | content.put("ItemBatch", "'" + orderDetl.getBatch() + "'"); |
| | | content.put("iNo", orderDetl.getId()); |
| | | content.put("DetId", orderDetl.getAutoId()); |
| | | content.put("MainNum", orderDetl.getQty()); |
| | | content.put("LKName", "'中扬二期'"); |
| | | Map<String, Object> content = getMap(orderDetl); |
| | | int insert = erpSqlServer.insert(InDetTB.class, content); |
| | | |
| | | if (insert == 1) { |
| | |
| | | * @param order |
| | | * @return |
| | | */ |
| | | @Transactional |
| | | @Transactional(rollbackFor = Throwable.class) |
| | | public boolean insertOutHed(Order order) { |
| | | String sqlInHedTb = "select * from lk_OutHedTB where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | List<OutHedTB> outHeds = erpSqlServer.select(sqlInHedTb, OutHedTB.class); |
| | | String sqlInHedTbBak = "select * from lk_OutHedTB_Bak where LKName='中扬二期' and BillNo='" + order.getOrderNo() + "'"; |
| | | List<OutHedTBBak> inHedBaks = erpSqlServer.select(sqlInHedTbBak, OutHedTBBak.class); |
| | | if (outHeds.size() > 0 || inHedBaks.size() > 0) { |
| | | if (!outHeds.isEmpty() || !inHedBaks.isEmpty()) { |
| | | log.error("该单号料号中间表表头已存在:" + order.getOrderNo()); |
| | | return true; |
| | | } |
| | |
| | | content.put("ObjectId", "'" + order.getCstmr() + "'"); |
| | | content.put("ObjectName", "'" + order.getCstmrName() + "'"); |
| | | content.put("Remark", "'" + order.getMemo() + "'"); |
| | | content.put("LKName", "'中扬'"); |
| | | int insert = erpSqlServer.insert(InHedTB.class, content); |
| | | String sql = "UPDATE lk_InHedTB SET bPass = 1, LKName='中扬二期' WHERE BillNo = '" + order.getOrderNo() + "'"; |
| | | content.put("LKName", "'中扬二期'"); |
| | | int insert = erpSqlServer.insert(OutHedTB.class, content); |
| | | String sql = "UPDATE lk_OutHedTB SET bPass = 1, LKName='中扬二期' WHERE BillNo = '" + order.getOrderNo() + "'"; |
| | | int update = erpSqlServer.update(sql); |
| | | if (update == 1) { |
| | | log.info("入库单表头回传成功:" + content.toString()); |
| | | log.info("入库单表头回传成功:" + content); |
| | | return true; |
| | | } else { |
| | | log.error("入库单表头回传失败:" + content.toString()); |
| | | log.error("入库单表头回传失败:" + content); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private Map<String, Object> getMap(OrderDetl orderDetl) { |
| | | Map<String, Object> content = new HashMap<>(); |
| | | content.put("BillNo", "'" + orderDetl.getOrderNo() + "'"); |
| | | content.put("iNO", "'" + orderDetl.getINO() + "'"); |
| | | content.put("detId", orderDetl.getThreeCode()); |
| | | content.put("ItemId", "'" + orderDetl.getThreeCode() + "'"); |
| | | content.put("ItemCode", "'" + orderDetl.getMatnr() + "'"); |
| | | content.put("ItemBatch", "'" + orderDetl.getBatch() + "'"); |
| | | content.put("proType", "'" + orderDetl.getProType() + "'"); |
| | | content.put("remark", "'" + orderDetl.getMemo() + "'"); |
| | | content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'"); |
| | | content.put("MainNum", orderDetl.getQty()); |
| | | content.put("WareId", "'" + orderDetl.getWareId() + "'"); |
| | | content.put("WareName", "'" + orderDetl.getWareName() + "'"); |
| | | content.put("Packing", "'" + orderDetl.getPacking() + "'"); |
| | | content.put("LuHao", "'" + orderDetl.getLuHao() + "'"); |
| | | content.put("sPgNO", "'" + orderDetl.getSPgNO() + "'"); |
| | | content.put("temp1", "'" + orderDetl.getTemp1() + "'"); |
| | | content.put("temp2", "'" + orderDetl.getTemp2() + "'"); |
| | | content.put("temp3", "'" + orderDetl.getTemp3() + "'"); |
| | | content.put("LKName", "'中扬二期'"); |
| | | return content; |
| | | } |
| | | } |