自动化立体仓库 - WMS系统
1
zc
2024-09-21 f97266870e6ad8f964f10937e5588b5b5fa222eb
src/main/java/com/zy/third/lk/task/LKInTBScheduler.java
@@ -2,18 +2,16 @@
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.DateUtils;
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;
@@ -22,9 +20,10 @@
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 入库更新完成回报
@@ -48,13 +47,15 @@
    @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) {
            docType = docTypeService.selectById(order.getDocType());
            if (docType == null) {
                log.error("该订单类型不存在:" + order.getDocType());
@@ -64,12 +65,14 @@
            if (docType.getPakin() == 1) {
                //入库单
                for (OrderDetl orderDetl : orderDetls) {
                    log.info("该入库单对象:" + orderDetl);
                    insertInDet(orderDetl);
                }
                insertInHed(order);
            } else {
                //出库单
                for (OrderDetl orderDetl : orderDetls) {
                    log.info("该出库单对象:" + orderDetl);
                    insertOutDet(orderDetl);
                }
                insertOutHed(order);
@@ -88,38 +91,26 @@
     * @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;
        }
@@ -131,31 +122,38 @@
     * @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;
        }
        DocType docType = docTypeService.selectById(order.getDocType());
        HashMap<String, Object> content = new HashMap<>();
        content.put("BillNo", "'" + order.getOrderNo() + "'");
        content.put("IoKindID", "'" + order.getDocType() + "'");
        content.put("ObjectId", "'" + order.getCstmr() + "'");
        content.put("ObjectName", "'" + order.getCstmrName() + "'");
        content.put("Remark", "'" + order.getMemo() + "'");
        content.put("LKName", "'中扬'");
        content.put("BillDate", "'" + DateUtils.convert(new Date()) + "'");
        if (!Cools.isEmpty(docType.getDocCode())) content.put("IoKindID", "'" + docType.getDocCode() + "'");
        if (!Cools.isEmpty(docType.getDocName())) content.put("IoKindName", "'" + docType.getDocName() + "'");
        if (!Cools.isEmpty(order.getWareId())) content.put("wareId", "'" + order.getWareId() + "'");
        if (!Cools.isEmpty(order.getWareName())) content.put("wareName", "'" + order.getWareName() + "'");
        if (!Cools.isEmpty(order.getTemp1())) content.put("temp1", "'" + order.getTemp1() + "'");
        if (!Cools.isEmpty(order.getTemp2())) content.put("temp2", "'" + order.getTemp2() + "'");
        if (!Cools.isEmpty(order.getTemp3())) content.put("temp3", "'" + order.getTemp3() + "'");
        if (!Cools.isEmpty(order.getCstmr())) content.put("ObjectId", "'" + order.getCstmr() + "'");
        if (!Cools.isEmpty(order.getCstmrName())) content.put("ObjectName", "'" + order.getCstmrName() + "'");
        if (!Cools.isEmpty(order.getMemo())) content.put("Remark", "'" + order.getMemo() + "'");
        content.put("LKName", "'中扬二期'");
        content.put("bPass", "1");
        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());
        if (insert == 1) {
            log.info("入库单表头回传成功:" + content);
            return true;
        } else {
            log.error("入库单表头回传失败:" + content.toString());
            log.error("入库单表头回传失败:" + content);
            return false;
        }
    }
@@ -166,7 +164,7 @@
     * @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() + "'";
@@ -174,24 +172,12 @@
        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", "'中扬二期'");
        int insert = erpSqlServer.insert(InDetTB.class, content);
        Map<String, Object> content = getMap(orderDetl);
        int insert = erpSqlServer.insert(OutDetTB.class, content);
        if (insert == 1) {
            log.info("入库单表身回传成功:" + content.toString());
@@ -209,32 +195,65 @@
     * @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;
        }
        DocType docType = docTypeService.selectById(order.getDocType());
        HashMap<String, Object> content = new HashMap<>();
        content.put("BillNo", "'" + order.getOrderNo() + "'");
        content.put("IoKindID", "'" + order.getDocType() + "'");
        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() + "'";
        int update = erpSqlServer.update(sql);
        if (update == 1) {
            log.info("入库单表头回传成功:" + content.toString());
        content.put("BillDate", "'" + DateUtils.convert(new Date()) + "'");
        if (!Cools.isEmpty(docType.getDocCode())) content.put("IoKindID", "'" + docType.getDocCode() + "'");
        if (!Cools.isEmpty(docType.getDocName())) content.put("IoKindName", "'" + docType.getDocName() + "'");
        if (!Cools.isEmpty(order.getWareId())) content.put("wareId", "'" + order.getWareId() + "'");
        if (!Cools.isEmpty(order.getWareName())) content.put("wareName", "'" + order.getWareName() + "'");
        if (!Cools.isEmpty(order.getTemp1())) content.put("temp1", "'" + order.getTemp1() + "'");
        if (!Cools.isEmpty(order.getTemp2())) content.put("temp2", "'" + order.getTemp2() + "'");
        if (!Cools.isEmpty(order.getTemp3())) content.put("temp3", "'" + order.getTemp3() + "'");
        if (!Cools.isEmpty(order.getCstmr())) content.put("ObjectId", "'" + order.getCstmr() + "'");
        if (!Cools.isEmpty(order.getCstmrName())) content.put("ObjectName", "'" + order.getCstmrName() + "'");
        if (!Cools.isEmpty(order.getMemo())) content.put("Remark", "'" + order.getMemo() + "'");
        content.put("LKName", "'中扬二期'");
        content.put("bPass", "1");
        int insert = erpSqlServer.insert(OutHedTB.class, content);
        if (insert == 1) {
            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<>();
        if (!Cools.isEmpty(orderDetl.getOrderNo())) content.put("BillNo", "'" + orderDetl.getOrderNo() + "'");
        if (!Cools.isEmpty(orderDetl.getINo())) content.put("iNo", "'" + orderDetl.getINo() + "'");
        if (!Cools.isEmpty(orderDetl.getThreeCode())) content.put("detId", orderDetl.getThreeCode());
        if (!Cools.isEmpty(orderDetl.getMatnr())) content.put("ItemId", "'" + orderDetl.getMatnr() + "'");
        if (!Cools.isEmpty(orderDetl.getModel())) content.put("ItemCode", "'" + orderDetl.getModel() + "'");
        if (!Cools.isEmpty(orderDetl.getBatch())) content.put("ItemBatch", "'" + orderDetl.getBatch() + "'");
        if (!Cools.isEmpty(orderDetl.getProType())) content.put("proType", "'" + orderDetl.getProType() + "'");
        if (!Cools.isEmpty(orderDetl.getMemo())) content.put("remark", "'" + orderDetl.getMemo() + "'");
        if (!Cools.isEmpty(orderDetl.getOutOrderNo())) content.put("OrderNo", "'" + orderDetl.getOutOrderNo() + "'");
        if (!Cools.isEmpty(orderDetl.getQty())) content.put("MainNum", orderDetl.getQty());
        if (!Cools.isEmpty(orderDetl.getWareId())) content.put("WareId", "'" + orderDetl.getWareId() + "'");
        if (!Cools.isEmpty(orderDetl.getWareName())) content.put("WareName", "'" + orderDetl.getWareName() + "'");
        if (!Cools.isEmpty(orderDetl.getPacking())) content.put("Packing", "'" + orderDetl.getPacking() + "'");
        if (!Cools.isEmpty(orderDetl.getLuHao())) content.put("LuHao", "'" + orderDetl.getLuHao() + "'");
        if (!Cools.isEmpty(orderDetl.getSPgNO())) content.put("sPgNO", "'" + orderDetl.getSPgNO() + "'");
        if (!Cools.isEmpty(orderDetl.getTemp1())) content.put("temp1", "'" + orderDetl.getTemp1() + "'");
        if (!Cools.isEmpty(orderDetl.getTemp2())) content.put("temp2", "'" + orderDetl.getTemp2() + "'");
        if (!Cools.isEmpty(orderDetl.getTemp3())) content.put("temp3", "'" + orderDetl.getTemp3() + "'");
        content.put("LKName", "'中扬二期'");
        return content;
    }
}