自动化立体仓库 - WMS系统
#
18516761980
2023-02-26 449761eaa6121e464a65a197c582a5cfcd6b17d0
src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java
@@ -1,12 +1,10 @@
package com.zy.ints.task.scheduler;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SnowflakeIdWorker;
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.*;
import com.zy.asrs.service.*;
import com.zy.ints.entity.ErpDetTb;
import com.zy.ints.entity.ErpDetTbBak;
@@ -59,7 +57,7 @@
    @Scheduled(cron = "${erp.refreshtime}")
    public void InOrOutOrder() {
        if (!erpEnabledErpDetTb) return;
        String sqlSelectErpDetTb = "select BIL_NO as billNo,prd_no as prdNo,ITM as itm,ADD_ID as addId2,QTY as qty,PRD_MARK as prdMark,WH as wh,BIL_DATE as billdate,STATUS as status,Temp1 as temp1,Temp2 as temp2,Temp3 as temp3 from ERP_DETTB where 1=1";
        String sqlSelectErpDetTb = "select BIL_NO as billNo,prd_no as prdNo,ITM as itm,ADD_ID as addId2,QTY as qty,PRD_MARK as prdMark,WH as wh,STATUS as status,Temp1 as temp1,Temp2 as temp2,Temp3 as temp3 from ERP_DETTB where 1=1";
        String sqlUpDateErpDetTbOne = "update ERP_DETTB set STATUS=1 where 1=1 and PRD_NO=";
        String sqlUpDateErpDetTbTwo = "update ERP_DETTB set STATUS=2 ";
@@ -132,7 +130,8 @@
                            }
                            Order order1 = orderService.selectByNo(erpDetTb.getBillNo());
                            if (!Cools.isEmpty(order1)) {
                                OrderDetl orderDetl = orderDetlService.selectItem(order1.getId(), erpDetTb.getBillNo(), erpDetTb.getPrdMark());
//                                OrderDetl orderDetl = orderDetlService.selectItem(order1.getId(), erpDetTb.getBillNo(), erpDetTb.getPrdMark());
                                OrderDetl orderDetl = orderDetlService.selectOne(new EntityWrapper<OrderDetl>().eq("order_no",erpDetTb.getBillNo()).eq("matnr",erpDetTb.getPrdNo()));
                                if (Cools.isEmpty(orderDetl)) {
                                    orderDetl = new OrderDetl();
                                    orderDetl.setOrderId(order1.getId());
@@ -144,6 +143,7 @@
                                    orderDetl.setBatch(erpDetTb.getPrdMark());
                                    orderDetl.setSpecs(mat.getSpecs());
                                    orderDetl.setUnit(mat.getUnit());
                                    orderDetl.setOrigin(erpDetTb.getItm().toString());
                                    orderDetl.setStatus(1);
                                    orderDetl.setCreateBy(9999L);
@@ -163,6 +163,30 @@
                                            callApiLogSave(erpDetTb, "ERP_DETTB", "ERP下发订单接收失败!!", false);
                                        }
                                    }
                                }else if (!erpDetTb.getItm().toString().equals(orderDetl.getOrigin())){
                                    orderDetl.setAnfme(orderDetl.getAnfme()+erpDetTb.getQty());
                                    EntityWrapper<OrderDetl> wrapper = new EntityWrapper<>();
                                    wrapper.eq("id", orderDetl.getId());
                                    if (orderDetlService.update(orderDetl,wrapper)) {
                                        erpSqlServer.update(sqlUpDateErpDetTbOne + "'" + erpDetTb.getPrdNo() + "'");
                                        callApiLogSave(erpDetTb, "ERP_DETTB", "接收ERP下发订单接收成功!!", true);
                                    } else {
                                        if (Cools.isEmpty(erpDetTb.getTemp2())){
                                            erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp2='更新订单明细档失败!!!'" + "where 1=1 "
                                                    +" and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'"
                                                    +" and ITM=" + "'" + erpDetTb.getItm() + "'"
                                                    +" and BIL_NO=" + "'" + erpDetTb.getBillNo() + "'");
                                            callApiLogSave(erpDetTb, "ERP_DETTB", "ERP下发订单接收失败!!", false);
                                        }
                                    }
                                }else {
                                    if (Cools.isEmpty(erpDetTb.getTemp3())){
                                        erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp3='更新订单明细档失败!!!订单明细已存在!!'" + "where 1=1 "
                                                +" and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'"
                                                +" and ITM=" + "'" + erpDetTb.getItm() + "'"
                                                +" and BIL_NO=" + "'" + erpDetTb.getBillNo() + "'");
                                        callApiLogSave(erpDetTb, "ERP_DETTB", "ERP下发订单接收失败!!", false);
                                    }
                                }
                            }
                        }