mrzhssss
2021-12-16 36b08172e90b5b03878145e5496edf1eb4a1af6d
src/main/java/com/zy/common/service/erp/task/ErpScheduler.java
@@ -16,6 +16,7 @@
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.dto.InStockDto;
import com.zy.common.service.erp.entity.*;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
@@ -23,6 +24,7 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -52,10 +54,13 @@
    /**
     * 原材料入库单
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Scheduled(cron = "0/30 * * * * ? ")
    @Synchronized
//    @PostConstruct
    public void inStockExecute(){
//        inStock的表头和表身
        List<InStockDto> readyInStock = erpService.getReadyInStock();
        for (InStockDto dto : readyInStock) {
            //同一单号存在相同物料编码数据,该单号不予处理
@@ -66,11 +71,16 @@
                }
                continue;
            }
            log.info("走到一号位置");
            if (Cools.isEmpty(dto) || Cools.isEmpty(dto.getInStockBillEntries())) {
                continue;
            }
            log.info("走到二号位置");
            for (InStockBillEntry entry : dto.getInStockBillEntries()) {
                MatCode matCode = matCodeService.selectById(entry.getFnumber());
                if (null != matCode) {
                    // 生成入库通知单
                    log.info("走到三号位置");
                    WaitPakin waitPakin = new WaitPakin();
                    waitPakin.setMemo("原材料");
                    waitPakin.setStatus("Y");    // 状态
@@ -105,6 +115,7 @@
                            }
                        }
                    } catch (Exception e) {
                        log.error("fail", e);
                        e.printStackTrace();
                        System.out.println(JSON.toJSON(waitPakin));
                    }
@@ -121,7 +132,8 @@
    /**
     * 成品入库单
     */
    @Scheduled(cron = "0/5 * * * * ? ")
    @Scheduled(cron = "0/20 * * * * ? ")
    @Synchronized
//    @PostConstruct
    public void inCPICMOExecute(){
        List<CPICMO> cpicmos = erpService.getReadyCPICMO();
@@ -178,7 +190,8 @@
        }
    }
    @Scheduled(cron = "0/5 * * * * ? ")
    @Scheduled(cron = "0/30 * * * * ? ")
    @Synchronized
    public void syncMat(){
        List<M_item> items = erpService.getItem();
        for (M_item item : items) {
@@ -213,6 +226,7 @@
     * 成品出库 发货通知单表头,表明细
     */
    @Scheduled(cron = "0/15 * * * * ? ")
    @Synchronized
    @Transactional
    public void syncOutStock(){
        List<OutStockBill> outStockBills = erpService.syncOutStock();
@@ -244,6 +258,7 @@
                    if (null == one) {
//                        String Fnumber = (Cools.isEmpty(outStockBillEntry.getFSourceBillNo())) ? outStockBillEntry.getFnumber() : outStockBillEntry.getFnumber()+"|"+outStockBillEntry.getFSourceBillNo();
//                        outStockBillEntry.setFnumber(Fnumber);  //产品代码|生产单号
                        outStockBillEntry.setFAmount(new BigDecimal(0));
                        if (!outStockService.insert(outStockBillEntry)) {
                            log.info("提取出库通知明细表OutStockBillEntry失败[FBrNo={},FInterID={},FEntryID={}]",outStockBillEntry.getFBrNo(),
                                    outStockBillEntry.getFInterID(),outStockBillEntry.getFEntryID());
@@ -256,6 +271,7 @@
                    } else {
                        // 数量有变化进行更新
                        if (Double.doubleToLongBits(one.getFAuxQty().doubleValue()) != Double.doubleToLongBits(outStockBillEntry.getFAuxQty().doubleValue())) {
                            outStockBillEntry.setFAmount(new BigDecimal(0));
                            if (!outStockService.update(outStockBillEntry, wrapper)) {
                                log.info("同步更新通知明细表OutStockBillEntry失败[FBrNo={},FInterID={},FEntryID={}]",outStockBillEntry.getFBrNo(),
                                        outStockBillEntry.getFInterID(),outStockBillEntry.getFEntryID());