package com.zy.nc.task; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.zy.asrs.service.StoreTypeService; import com.zy.asrs.task.core.ReturnT; import com.zy.nc.entity.*; import com.zy.nc.service.*; import com.zy.nc.task.handler.PlanOrderHandler; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import java.util.List; @Slf4j @Component public class PlanOrderTask { @Autowired private PlanOrderHandler planOrderHandler; @Autowired private NccSaleXsfhmxWmsService nccSaleXsfhmxWmsService; @Autowired private NccScZkmxbWmsService nccScZkmxbWmsService; @Autowired private NccCgCgdhdWmsService nccCgCgdhdWmsService; @Autowired private NccSaleDbddWmsService nccSaleDbddWmsService; @Autowired private NccCkPddWmsService nccCkPddWmsService; @Autowired private StoreTypeService storeTypeService; /** * 发货 * * @return */ @Scheduled(cron = "0/3 * * * * ? ") public void execute1() { List warehouseIds = storeTypeService.listOwn(); List Ids = nccSaleXsfhmxWmsService.selectXsfh(warehouseIds); for (String id : Ids) { List wmsFlag = nccSaleXsfhmxWmsService.selectList(new EntityWrapper() .eq("vbillcode", id) .ne("wms_flag", 1) .eq("fstatusflag", 2) .eq("hdr", 0) .eq("bdr", 0) .in("fhckbm",warehouseIds) ); if (wmsFlag == null || wmsFlag.isEmpty()) { continue; } ReturnT returnT = planOrderHandler.start1(wmsFlag); if (!returnT.isSuccess()) { for (NccSaleXsfhmxWms wms : wmsFlag) { wms.setWmsMemo(returnT.getMsg()); wms.setWmsFlag(0); nccSaleXsfhmxWmsService.updateById(wms); } log.error(returnT.getMsg()); } // if (wmsFlag.get(0).getNastnum().doubleValue() > 0) { // returnT = planOrderHandler.start1(wmsFlag); // } else { // returnT = planOrderHandler.start1In(wmsFlag); // } } } /** * 转库 * * @return */ @Scheduled(cron = "0/3 * * * * ? ") public void execute2_1() { List ids = storeTypeService.listOwn(); //String s = "一期成品库-内贸(立体库)、一期成品库-福莱国际外贸(立体库)、一期成品库-外购(立体库)、一期成品库-福达/工厂外贸(立体库)、一期辅料库-包材(立体库)"; List strings = nccScZkmxbWmsService.selectZkIn(ids); for (String string : strings) { List wmsFlag = nccScZkmxbWmsService.selectList(new EntityWrapper().eq("vbillcode", string).ne("wms_flag", 1).eq("dr", 0).eq("bdr", 0)); if (wmsFlag == null || wmsFlag.isEmpty()) { continue; } ReturnT returnT = planOrderHandler.start2In(wmsFlag); if (!returnT.isSuccess()) { for (NccScZkmxbWms wms : wmsFlag) { wms.setWmsMemo(returnT.getMsg()); wms.setWmsFlag(0); nccScZkmxbWmsService.updateById(wms); } log.error(returnT.getMsg()); } } } /** * 转库-出库 * 不同步,转库出库由WMS直接发起 * * @return */ // @Scheduled(cron = "0/3 * * * * ? ") public void execute2_2() { List ids = storeTypeService.listOwn(); List strings = nccScZkmxbWmsService.selectZkOut(ids); for (String string : strings) { List wmsFlag = nccScZkmxbWmsService.selectList(new EntityWrapper().eq("vbillcode", string).ne("wms_flag", 1).eq("dr", 0).eq("bdr", 0)); if (wmsFlag == null || wmsFlag.isEmpty()) { continue; } ReturnT returnT = planOrderHandler.start2Out(wmsFlag); if (!returnT.isSuccess()) { for (NccScZkmxbWms wms : wmsFlag) { wms.setWmsMemo(returnT.getMsg()); wms.setWmsFlag(0); nccScZkmxbWmsService.updateById(wms); } log.error(returnT.getMsg()); } } } /** * 采购到货单 * * @return */ @Scheduled(cron = "0/3 * * * * ? ") public void execute3() { List strings = nccCgCgdhdWmsService.selectCg(); for (String string : strings) { List wmsFlag = nccCgCgdhdWmsService.selectList(new EntityWrapper().eq("vbillcode", string).ne("wms_flag", 1).eq("hdr", 0).eq("bdr", 0)); if (wmsFlag == null || wmsFlag.isEmpty()) { continue; } ReturnT returnT = planOrderHandler.start3(wmsFlag); if (!returnT.isSuccess()) { for (NccCgCgdhdWms wms : wmsFlag) { wms.setWmsMemo(returnT.getMsg()); wms.setWmsFlag(0); nccCgCgdhdWmsService.updateById(wms); } log.error(returnT.getMsg()); } } } /** * 调拨出库 * * @return */ @Scheduled(cron = "0/3 * * * * ? ") public void execute5() { List ids = storeTypeService.listOwn(); List strings = nccSaleDbddWmsService.selectDbdd(ids); for (String string : strings) { List wmsFlag = nccSaleDbddWmsService.selectList(new EntityWrapper().eq("vbillcode", string).ne("wms_flag", 1).eq("dr", 0).eq("bdr", 0)); if (wmsFlag == null || wmsFlag.isEmpty()) { continue; } ReturnT returnT = planOrderHandler.start5(wmsFlag); if (!returnT.isSuccess()) { for (NccSaleDbddWms wms : wmsFlag) { wms.setWmsMemo(returnT.getMsg()); wms.setWmsFlag(0); nccSaleDbddWmsService.updateById(wms); } log.error(returnT.getMsg()); } } } /** * 盘点单 * * @return */ // @Scheduled(cron = "0/3 * * * * ? ") // public void execute4() { // List strings = nccCkPddWmsService.selectPdd(); // for (String string : strings) { // List wmsFlag = nccCkPddWmsService.selectList(new EntityWrapper().eq("vbillcode", string).ne("wms_flag", 1).eq("FBILLFLAG", 4).eq("hdr", 0).eq("bdr", 0)); // ReturnT returnT = planOrderHandler.start4(wmsFlag); // if (!returnT.isSuccess()) { // for (NccCkPddWms wms : wmsFlag) { // wms.setWmsMemo(returnT.getMsg()); // wms.setWmsFlag(0); // nccCkPddWmsService.updateById(wms); // } // log.error(returnT.getMsg()); // } // } // } }