luxiaotao1123
2021-06-09 da40f82d921daa63de501392519c6ecfbe8962a3
src/main/java/com/zy/common/service/erp/ErpService.java
@@ -1,7 +1,10 @@
package com.zy.common.service.erp;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.zy.asrs.service.OutStockMainService;
import com.zy.asrs.service.OutStockService;
import com.zy.common.service.erp.dto.InStockDto;
import com.zy.common.service.erp.dto.PInStockDto;
import com.zy.common.service.erp.entity.*;
@@ -9,6 +12,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -150,11 +154,11 @@
            CPICMO cpicmo = select.get(0);
            boolean complete = false;
            if (cpicmo.getFQty() > 0) {
                if (cpicmo.getFAuxCommitQty() >= cpicmo.getFQty()) {
                if (Double.doubleToLongBits(cpicmo.getFAuxCommitQty()) == Double.doubleToLongBits(cpicmo.getFQty())) {
                    complete = true;
                }
            } else {
                if (cpicmo.getFAuxCommitQty() >= cpicmo.getFAuxQty()) {
                if (Double.doubleToLongBits(cpicmo.getFAuxCommitQty()) == Double.doubleToLongBits(cpicmo.getFAuxQty())) {
                    complete = true;
                }
            }
@@ -281,21 +285,51 @@
        return erpSqlServer.update(sql) > 0;
    }
    /* 查询erp中年表OutStockBill数据 */
    public List<OutStockBill> syncOutStock() {
        return erpSqlServer.select("SELECT * FROM  xtyasrs_dual.dbo.OutStockBill", OutStockBill.class);
    }
    public List<OutStockBillEntry> syncOutStockDetail() {
        return erpSqlServer.select("SELECT * FROM  xtyasrs_dual.dbo.OutStockBillEntry", OutStockBillEntry.class);
    }
    /* 成品增量出库 */
    public boolean incrementCPakOut(Integer FInterID, String Fnumber, Double increment, String FBillNo) {
        String sql = "update OutStockbillEntry set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FInterID = {2,number,#}";
        sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
        if (erpSqlServer.update(sql) > 0) {
            sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#}";
            sql = MessageFormat.format(sql, Fnumber, FInterID);
            List<OutStockBillEntry> select = erpSqlServer.select(sql, OutStockBillEntry.class);
            OutStockBillEntry outStockBillEntry = select.get(0);
            boolean complete = false;
            if (outStockBillEntry.getFQty().compareTo(BigDecimal.ZERO) == 1) {
                if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFQty()) > -1) {
                    complete = true;
                }
            } else {
                if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFAuxQty()) > -1) {
                    complete = true;
                }
            }
            if (complete) {
                if (!completeCPakOut(FBillNo)) {
                    log.error("{}出库单标记完成失败", FBillNo);
                }
            }
            return true;
        } else {
            return false;
        }
    }
    /* 成品出库单标记完成 */
    private boolean completeCPakOut(String FBillNo){
        String sql = "update OutStockbill set Fflag_finish = 1 where FBillNo = ''{0}''";
        sql = MessageFormat.format(sql, FBillNo);
        return erpSqlServer.update(sql) > 0;
    }
    public boolean updateFnumber(Integer itemId, String FNumber){
@@ -310,4 +344,18 @@
        return erpSqlServer.update(sql) > 0;
    }
    public List<CPICMO> queryErpCPICMO(String fbillNo, String fsourceBillNo) {
        String sql = "select * from CPICMO";
        if (!Cools.isEmpty(fbillNo) && Cools.isEmpty(fsourceBillNo)) {
            sql = "select * from CPICMO where FBillNo = ''{0}''";
            sql = MessageFormat.format(sql, fbillNo);
        } else if (Cools.isEmpty(fbillNo) && !Cools.isEmpty(fsourceBillNo)) {
            sql = "select * from CPICMO where FSourceBillNo = ''{0}''";
            sql = MessageFormat.format(sql, fsourceBillNo);
        } else if (!Cools.isEmpty(fbillNo) && !Cools.isEmpty(fsourceBillNo)) {
            sql = "select * from CPICMO where FBillNo = ''{0}'' and FSourceBillNo = ''{1}''";
            sql = MessageFormat.format(sql, fbillNo, fsourceBillNo);
        }
        return erpSqlServer.select(sql, CPICMO.class);
    }
}