#
18516761980
2021-09-29 15c8f00ab3a1e3d2d96b56bae0ec11efedd60231
#
13个文件已修改
356 ■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/OutStockController.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/task/handler/WorkLogHandler.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpModeController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpService.java 180 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/ErpSqlServer.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/erp/task/ErpScheduler.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/OutStockMapper.xml 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/locNormal/locNormal.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/pakStore/outStock.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/pakStore/outStockDetail.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/pakStore/outStockNormalDetail.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/OutStockController.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.annotations.ManagerAuth;
import com.core.common.Cools;
import com.core.common.DateUtils;
@@ -18,17 +19,21 @@
import com.zy.asrs.service.WorkService;
import com.zy.asrs.utils.VersionUtils;
import com.zy.common.service.erp.ErpService;
import com.zy.common.service.erp.entity.OutStockBill;
import com.zy.common.service.erp.entity.OutStockBillEntry;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.implementation.bytecode.Throw;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -47,6 +52,7 @@
    private ErpService erpService;
    @Autowired
    private LocNormalLogService locNormalLogService;
    /**
     *
@@ -102,15 +108,27 @@
     */
    @RequestMapping(value = "/outStock/locNormal")
    @ManagerAuth
    @Transactional
    public R outStockLocNormal(@RequestBody LocNormalStockOutParam param) {
        Long modiUser = getUserId();
        Date modiTime = new Date();
        for (LocNormal locNormals:param.getList()) {
            // erp中间表更新数据
            Integer FInterI = outStockService.queryOutStockFInterID(param.getSupplier()); // 获取出库单主表主键
            if (!erpService.incrementCPakOut(FInterI, locNormals.getMatnr(), locNormals.getAnfme().doubleValue(), param.getSupplier())) {
                log.info("更新ERP成品出库数据[matnr={0}]失败", locNormals.getMatnr(), param.getSupplier());
        Integer FInterI = outStockService.queryOutStockFInterID(param.getSupplier()); // 获取出库单主表主键
        List<OutStockBillEntry>  entryList = outStockService.selectList(new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI));
        for(OutStockBillEntry one : entryList){
            String Fnumber = one.getFnumber();
            BigDecimal qty = new BigDecimal(0);
            for (LocNormal locNormals:param.getList()) {
                if(locNormals.getMatnr().equals(Fnumber)){
                    qty = qty.add(locNormals.getAnfme());
                }
            }
            if(qty.compareTo(one.getFQty()) == 1){
                return R.error("出库数量大于通知档数量[FInterID=" + FInterI + ",Fnumber=" + Fnumber + "]");
            }
        }
        for (LocNormal locNormals:param.getList()) {
            LocNormal locNormal = locNormalService.selectOne(new EntityWrapper<LocNormal>().eq("id", locNormals.getId()));
            if (!Cools.isEmpty(locNormal)) {
                if (locNormal.getAnfme().compareTo(locNormals.getAnfme()) == 1) {
@@ -150,6 +168,22 @@
                }
            }
//            Integer FInterI = outStockService.queryOutStockFInterID(param.getSupplier()); // 获取出库单主表主键
            //更新ASRS出库通知档明细出库数量
            Wrapper wrapper = new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI).eq("Fnumber",locNormals.getMatnr());
            OutStockBillEntry outStockBillEntry = outStockService.selectOne(wrapper);
            outStockBillEntry.setFAuxCommitQty(outStockBillEntry.getFAuxCommitQty().add(locNormals.getAnfme()));
            outStockBillEntry.setFAmount(outStockBillEntry.getFAmount().add(locNormals.getAnfme()));  //借用amount字段,控制下发出库任务数量
            if(!outStockService.update(outStockBillEntry,wrapper)){
                throw new CoolException("更新出库通知档明细失败[FInterID="+FInterI+",Fnumber="+locNormals.getMatnr()+"]");
            }
            // erp中间表更新数据
            if (!erpService.incrementCPakOut(FInterI, locNormals.getMatnr(), locNormals.getAnfme().doubleValue(), param.getSupplier())) {
                log.error("更新ERP成品出库数据[matnr={},FBillNo={}]失败", locNormals.getMatnr(), param.getSupplier());
            }
        }
        return R.ok("平仓出库成功");
    }
src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.StockOutParam;
@@ -49,6 +50,8 @@
    private LocNormalService locNormalService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private OutStockService outStockService;
    @Override
    public Page<OutStockBillEntry> queryOutStock(Page<OutStockBillEntry> page) {
@@ -129,6 +132,31 @@
    @Override
    @Transactional
    public void startupFullTakeStore(StockOutParam param, Long userId) {
        //判断出库熟练是否大于库存数量
        for (StockOutParam.LocDetl detl : param.getLocDetls()) {
            LocDetl locDetl = locDetlService.selectById(detl.getLocNo());
            if(locDetl != null){
                if(detl.getCount() > locDetl.getAnfme()){
                    throw new CoolException("出库数量超过了库存数量[locNo=" + detl.getLocNo() + "]");
                }
            }
        }
        //判断出库数量是否大于通知档数量
        Integer FInterI = outStockService.queryOutStockFInterID(param.getFbillNo()); // 获取出库单主表主键
        List<OutStockBillEntry>  entryList = outStockService.selectList(new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI));
        for(OutStockBillEntry one : entryList){
            String Fnumber = one.getFnumber();
            BigDecimal qty = new BigDecimal(0);
            for (StockOutParam.LocDetl detl : param.getLocDetls()) {
                if(detl.getMatnr().equals(Fnumber)){
                    qty = qty.add(BigDecimal.valueOf(detl.getCount()));
                }
            }
            if(qty.compareTo(one.getFQty()) == 1){
                throw new CoolException("出库数量大于通知档数量[FInterID=" + FInterI + ",Fnumber=" + Fnumber + "]");
            }
        }
        // 目标站点状态检测
        BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
        // 获取库位明细
@@ -238,6 +266,15 @@
                if (!wrkDetlService.insert(wrkDetl)) {
                    throw new CoolException("保存工作档明细失败");
                }
                //更新出库通知档Famount字段,防止重复下发任务 2021-09-28 TQS ADD
                Integer FInterI = outStockService.queryOutStockFInterID(fbillNo); // 获取出库单主表主键
                Wrapper wrapper1 = new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI).eq("Fnumber",detlDto.getLocDetl().getMatnr());
                OutStockBillEntry outStockBillEntry = outStockService.selectOne(wrapper1);
                outStockBillEntry.setFAmount(outStockBillEntry.getFAmount().add(BigDecimal.valueOf(anfme)));  //借用amount字段,控制下发出库任务数量
                if(!outStockService.update(outStockBillEntry,wrapper1)){
                    throw new CoolException("更新出库通知档明细FAmount失败[FInterID="+FInterI+",Fnumber="+detlDto.getLocDetl().getMatnr()+"]");
                }
            }
            // 修改库位状态:   F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中
            locMast = locMastService.selectById(dto.getLocNo());
src/main/java/com/zy/asrs/task/handler/WorkLogHandler.java
@@ -79,7 +79,7 @@
            }
            // erp关联出库订单处理
            if (wrkMast.getIoType() == 101) {
            if (wrkMast.getIoType() == 101 || wrkMast.getIoType() == 53) {
                EntityWrapper<WrkDetl> wrapper = new EntityWrapper<>();
                // 获取工作档内物料清单
                List<WrkDetl> wrkDetls = wrkDetlService.selectList(wrapper.eq("wrk_no", wrkMast.getWrkNo()).and().isNotNull("supplier"));
src/main/java/com/zy/common/service/erp/ErpModeController.java
@@ -40,7 +40,7 @@
     */
    @GetMapping("/haveReadInStock")
    public R haveReadInStock(@RequestParam String FBillNo){
        return R.ok().add(erpService.haveReadInStock(FBillNo));
        return R.ok().add(erpService.haveReadInStock(FBillNo,1));
    }
    /**
src/main/java/com/zy/common/service/erp/ErpService.java
@@ -3,6 +3,7 @@
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.service.OutStockMainService;
import com.zy.asrs.service.OutStockService;
import com.zy.common.service.erp.dto.InStockDto;
@@ -10,6 +11,7 @@
import com.zy.common.service.erp.entity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
@@ -27,6 +29,8 @@
    @Autowired
    private ErpSqlServer erpSqlServer;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    public List<StockEntryCensus> get(){
        return erpSqlServer.select("select * from StockEntryCensus where 1=1",StockEntryCensus.class);
@@ -64,6 +68,20 @@
    }
    /**
     * 查询同一单号是否存在相同物料的最大数量值,
     * @return
     */
    public Number QueryFnumberInCount(Integer FInterID) {
        String sql = "select top 1 qty from (\n" +
                "select Fnumber,count(*) as qty from InStockbill a,InStockbillEntry b\n" +
                "where a.FInterID=b.FInterID and a.FInterID=" + FInterID +
                " group by Fnumber\n" +
                ") a\n" +
                "order by qty desc";
        return erpSqlServer.executeQueryCount(sql,"qty");
    }
    /**
     * 获取入库物流明细
     * @param fInterID 单据内码
     */
@@ -75,9 +93,9 @@
    /**
     * 将未读的原材料入库单据设置为已读
     */
    public boolean haveReadInStock(String FBillNo){
        String sql = "update InStockBill set Fflag_rw = 1 where FBillNo = ''{0}''";
        sql = MessageFormat.format(sql, FBillNo);
    public boolean haveReadInStock(String FBillNo, Integer value){
        String sql = "update InStockBill set Fflag_rw = {1,number,#} where FBillNo = ''{0}''";
        sql = MessageFormat.format(sql, FBillNo, value);
        return erpSqlServer.update(sql) > 0;
    }
@@ -90,11 +108,25 @@
    }
    /**
     * 查询同一单号是否存在相同物料的最大数量值,
     * @return
     */
    public Number QueryFnumberCPICMOCount(Integer FInterID) {
        String sql = "select top 1 qty from (\n" +
                "select count(*) as qty from CPICMO\n" +
                "where FInterID=" + FInterID +
                " group by Fnumber\n" +
                ") a\n" +
                "order by qty desc";
        return erpSqlServer.executeQueryCount(sql,"qty");
    }
    /**
     * 将未读的成品入库单据设置为已读
     */
    public boolean haveReadCPICMO(String FBillNo){
        String sql = "update CPICMO set Fflag_rw = 1 where FBillNo = ''{0}''";
        sql = MessageFormat.format(sql, FBillNo);
    public boolean haveReadCPICMO(Integer FInterID, Integer value){
        String sql = "update CPICMO set Fflag_rw = {1,number,#} where FInterID = ''{0,number,#}''";
        sql = MessageFormat.format(sql, FInterID, value);
        return erpSqlServer.update(sql) > 0;
    }
    ////////////////////////////////////////////////////////////////////////////////////////
@@ -110,6 +142,20 @@
    }
    /**
     * 查询同一单号是否存在相同物料的最大数量值,
     * @return
     */
    public Number QueryFnumberOutCount(Integer FInterID) {
        String sql = "select top 1 qty from (\n" +
                "select Fnumber,count(*) as qty from OutStockbill a,OutStockbillEntry b\n" +
                "where a.FInterID=b.FInterID and a.FInterID=" + FInterID +
                " group by Fnumber\n" +
                ") a\n" +
                "order by qty desc";
        return erpSqlServer.executeQueryCount(sql,"qty");
    }
    /**
     * 查询erp中间表表体OutStockbillEntry数据
     * @param FInterID
     * @return
@@ -121,9 +167,9 @@
    /**
     * 将提取完成的成品出库通知单据设置为已读
     */
    public boolean haveReadOutBill(String FBrNo, Integer FInterID){
        String sql = "update OutStockbill set Fflag_rw = 1 where FBillNo = ''{0}'' and FInterID = {1,number,#} ";
        sql = MessageFormat.format(sql, FBrNo, FInterID);
    public boolean haveReadOutBill(String FBrNo, Integer FInterID, Integer value){
        String sql = "update OutStockbill set Fflag_rw = {2,number,#} where FBillNo = ''{0}'' and FInterID = {1,number,#} ";
        sql = MessageFormat.format(sql, FBrNo, FInterID, value);
        return erpSqlServer.update(sql) > 0;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////
@@ -146,9 +192,9 @@
    /**
     * 原材料增量入库
     */
    public boolean incrementPakIn(String FBillNo, String Fnumbers, Double increment) {
        String[] arrays = Fnumbers.split("|");
        String Fnumber="",sBillNo=""; //产品代码,生产单号
    public boolean incrementPakIn(String FBillNo, String Fnumber, Double increment) {
//        String[] arrays = Fnumbers.split("|");
//        String Fnumber="",sBillNo=""; //产品代码,生产单号
        String sql = "update ise \n" +
                "set ise.FAuxCommitQty = (ise.FAuxCommitQty + {0,number,#}) \n" +
@@ -157,15 +203,16 @@
                "where 1=1 \n" +
                "and ise.Fnumber = ''{1}''\n" +
                "and isb.FBillNo= ''{2}''\n";
        sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
        Fnumber = arrays[0];
        if(arrays.length>1){
            sBillNo = arrays[1];
            sql = sql + "and ise.FSourceBillNo= ''{3}''";
            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
        } else {
            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
        }
//        Fnumber = arrays[0];
//        if(arrays.length>1){
//            sBillNo = arrays[1];
//            sql = sql + "and ise.FSourceBillNo= ''{3}''";
//            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
//        } else {
//            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
//        }
        if (erpSqlServer.update(sql) > 0) {
//            log.error("更新ERP中间表成功===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumber,increment);
@@ -193,7 +240,7 @@
            }
            return true;
        } else {
            log.error("更新ERP中间表失败===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumbers,increment);
            log.error("更新ERP中间表失败===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumber,increment);
            return false;
        }
    }
@@ -201,29 +248,30 @@
    /**
     * 成品增量入库
     */
    public boolean incrementCPakIn(String FBillNo, String Fnumbers, Double increment) {
        String[] arrays = Fnumbers.split("|");
        String Fnumber="",sBillNo=""; //产品代码,生产单号
    public boolean incrementCPakIn(String FBillNo, String Fnumber, Double increment) {
//        String[] arrays = Fnumbers.split("|");
//        String Fnumber="",sBillNo=""; //产品代码,生产单号
        String sql = "update CPICMO set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FBillNo = ''{2}'' ";
        sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
        Fnumber = arrays[0];
        if(arrays.length>1){
            sBillNo = arrays[1];
            sql = sql + " and FSourceBillNo= ''{3}''";
            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
        } else {
            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
        }
//        Fnumber = arrays[0];
//        if(arrays.length>1){
//            sBillNo = arrays[1];
//            sql = sql + " and FSourceBillNo= ''{3}''";
//            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
//        } else {
//            sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
//        }
        if (erpSqlServer.update(sql) > 0) {
            if(arrays.length>1) {
                sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}'' and FSourceBillNo= ''{2}''";
                sql = MessageFormat.format(sql, Fnumber, FBillNo, sBillNo);
            } else {
//            if(arrays.length>1) {
//                sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}'' and FSourceBillNo= ''{2}''";
//                sql = MessageFormat.format(sql, Fnumber, FBillNo, sBillNo);
//            } else {
                sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}''";
                sql = MessageFormat.format(sql, Fnumber, FBillNo);
            }
//            }
            List<CPICMO> select = erpSqlServer.select(sql, CPICMO.class);
            CPICMO cpicmo = select.get(0);
            boolean complete = false;
@@ -237,7 +285,7 @@
                }
            }
            if (complete) {
                if (!completeCPakIn(FBillNo, Fnumber, sBillNo)) {
                if (!completeCPakIn(FBillNo, Fnumber)) {
                    log.error("{}入库单标记完成失败", FBillNo);
                }
            }
@@ -306,8 +354,8 @@
     * @param qty 数量(正表示盘盈、负表示盘亏)
     */
    public boolean checkStockEntity(String FNumber, Double qty){
        String[] arrays = FNumber.split("|");
        FNumber = arrays[0];
//        String[] arrays = FNumber.split("|");
//        FNumber = arrays[0];
        String sql = "insert [dbo].[StockCheckRecord] ([FNumber],[CheckQty],[Fflag_rw],[Fflag_finish],[sync_id]) values (''{0}'', {1,number,#}, 0, 0, -1);";
        sql = MessageFormat.format(sql, FNumber, qty);
        if (erpSqlServer.update(sql) == 0) {
@@ -336,16 +384,16 @@
    /**
     * 成品入库单标记完成
     */
    private boolean completeCPakIn(String FBillNo, String Fnumber, String sBillNo){
        if(Cools.isEmpty(sBillNo)) {
    private boolean completeCPakIn(String FBillNo, String Fnumber){
//        if(Cools.isEmpty(sBillNo)) {
            String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}''";
            sql = MessageFormat.format(sql, FBillNo, Fnumber);
            return erpSqlServer.update(sql) > 0;
        } else {
            String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}'' and FSourceBillNo= ''{2}'' ";
            sql = MessageFormat.format(sql, FBillNo, Fnumber, sBillNo);
            return erpSqlServer.update(sql) > 0;
        }
//        } else {
//            String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}'' and FSourceBillNo= ''{2}'' ";
//            sql = MessageFormat.format(sql, FBillNo, Fnumber, sBillNo);
//            return erpSqlServer.update(sql) > 0;
//        }
    }
@@ -359,29 +407,31 @@
//    }
    /* 成品增量出库 */
    public boolean incrementCPakOut(Integer FInterID, String Fnumbers, Double increment, String FBillNo) {
        String[] arrays = Fnumbers.split("|");
        String Fnumber="",sBillNo=""; //产品代码,生产单号
    public boolean incrementCPakOut(Integer FInterID, String Fnumber, Double increment, String FBillNo) {
//        String[] arrays = Fnumbers.split("|");
//        String Fnumber="",sBillNo=""; //产品代码,生产单号
        String sql = "update OutStockbillEntry set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FInterID = {2,number,#} ";
        Fnumber = arrays[0];
        if(arrays.length>1){
            sBillNo = arrays[1];
            sql = sql + " and FSourceBillNo= ''{3}''";
            sql = MessageFormat.format(sql, increment, Fnumber, FInterID, sBillNo);
        } else {
            sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
        }
        sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
//        Fnumber = arrays[0];
//        if(arrays.length>1){
//            sBillNo = arrays[1];
//            sql = sql + " and FSourceBillNo= ''{3}''";
//            sql = MessageFormat.format(sql, increment, Fnumber, FInterID, sBillNo);
//        } else {
//            sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
//        }
        try {
            if (erpSqlServer.update(sql) > 0) {
                if(arrays.length>1) {
                    sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#} and FSourceBillNo= ''{2}''";
                    sql = MessageFormat.format(sql, Fnumber, FInterID, sBillNo);
                } else {
//                if(arrays.length>1) {
//                    sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#} and FSourceBillNo= ''{2}''";
//                    sql = MessageFormat.format(sql, Fnumber, FInterID, sBillNo);
//                } else {
                    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);
@@ -399,6 +449,10 @@
                    if (!completeCPakOut(FBillNo)) {
                        log.error("{}出库单标记完成失败", FBillNo);
                    }
                    int updateCount = jdbcTemplate.update("update OutStockbill set Fflag_finish=1 where FBillNo='" + FBillNo + "'");
                    if(updateCount<=0){
                        throw new CoolException("更新出库通知档完成标记失败[FBillNo="+FBillNo+"]");
                    }
                }
                return true;
            } else {
src/main/java/com/zy/common/service/erp/ErpSqlServer.java
@@ -92,6 +92,34 @@
        }
    }
    public Number executeQueryCount(String sql, String column) {
        Number value = 0;
        Connection conn = null;
        try {
            conn = getConn();
            pstm = conn.prepareStatement(sql);
            rs = pstm.executeQuery();
//            ResultSetMetaData metaData = rs.getMetaData();
            while (rs.next()) {
                value = (Number) rs.getInt(column);
            }
            return value;
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        } finally {
            release();
            if (conn != null) {
                try {
                    conn.close();
                    conn = null;
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    private int executeUpdate(String sql) {
        Connection conn = null;
        try {
src/main/java/com/zy/common/service/erp/task/ErpScheduler.java
@@ -57,6 +57,16 @@
    public void inStockExecute(){
        List<InStockDto> readyInStock = erpService.getReadyInStock();
        for (InStockDto dto : readyInStock) {
            //同一单号存在相同物料编码数据,该单号不予处理
            Number fnumberCount = erpService.QueryFnumberInCount(dto.getInStockBill().getFInterID());
            if(fnumberCount.intValue() > 1){
                if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo(),-1)) {
                    log.error("标记原材料入库通知单已读InStockBill为-1失败[FBillNo={},FInterID={}]", dto.getInStockBill().getFBillNo(),dto.getInStockBill().getFInterID());
                }
                continue;
            }
            for (InStockBillEntry entry : dto.getInStockBillEntries()) {
                MatCode matCode = matCodeService.selectById(entry.getFnumber());
                if (null != matCode) {
@@ -100,7 +110,7 @@
                    }
                }
            }
            if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo())) {
            if (!erpService.haveReadInStock(dto.getInStockBill().getFBillNo(),1)) {
                log.error("标记原材料入库通知单已读InStockBill失败[FBillNo={}]", dto.getInStockBill().getFBillNo());
            }
        }
@@ -116,6 +126,16 @@
    public void inCPICMOExecute(){
        List<CPICMO> cpicmos = erpService.getReadyCPICMO();
        for (CPICMO cpicmo : cpicmos) {
            //同一单号存在相同物料编码数据,该单号不予处理
            Number fnumberCount = erpService.QueryFnumberCPICMOCount(cpicmo.getFInterID());
            if(fnumberCount.intValue() > 1){
                if (!erpService.haveReadCPICMO(cpicmo.getFInterID(),-1)) {
                    log.error("标记成品入库通知单已读CPICMO为-1失败[Fnumber={},FInterID={}]", cpicmo.getFnumber(),cpicmo.getFInterID());
                }
                continue;
            }
            MatCode matCode = matCodeService.selectById(cpicmo.getFnumber());
            if (null != matCode) {
                // 生成入库通知单
@@ -151,7 +171,7 @@
                        log.info("同步更新成品入库通知单CPICMO失败[FBillNo={},Fnumber={}]", waitPakin.getSupplier(), waitPakin.getMatnr());
                    }
                }
                if (!erpService.haveReadCPICMO(cpicmo.getFBillNo())) {
                if (!erpService.haveReadCPICMO(cpicmo.getFInterID(),1)) {
                    log.error("标记成品入库通知单已读CPICMO失败[FBillNo={}]", cpicmo.getFBillNo());
                }
            }
@@ -198,6 +218,16 @@
        List<OutStockBill> outStockBills = erpService.syncOutStock();
        for (Integer i = 0; i < outStockBills.size(); i++) {
            OutStockBill outStockBill = outStockBills.get(i);
            //同一单号存在相同物料编码数据,该单号不予处理
            Number fnumberCount = erpService.QueryFnumberOutCount(outStockBill.getFInterID());
            if(fnumberCount.intValue() > 1){
                if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID(),-1)) {
                    log.error("更新出库通知单读取状态为-1失败[FBrNo={},FInterID={}]", outStockBill.getFBrNo(),outStockBill.getFInterID());
                }
                continue;
            }
            OutStockBill main = outStockMainService.selectOne(new EntityWrapper<OutStockBill>().eq("FBillNo",outStockBill.getFBillNo()).and().eq("FInterID", outStockBill.getFInterID()));
            if (null == main) {
                outStockBill.setFflag_rw(1);
@@ -242,7 +272,7 @@
            }
            if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID())) {
            if (!erpService.haveReadOutBill(outStockBill.getFBillNo(),outStockBill.getFInterID(),1)) {
                log.error("更新出库通知单读取状态失败[FBrNo={},FInterID={}]", outStockBill.getFBrNo(),outStockBill.getFInterID());
            }
        }
src/main/resources/application.yml
@@ -8,7 +8,8 @@
    name: @pom.build.finalName@
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://localhost:1433;databasename=xtyasrs
    url: jdbc:sqlserver://192.168.4.208:1433;databasename=xtyasrs
#    url: jdbc:sqlserver://localhost:1433;databasename=xtyasrs
    username: sa
    password: sa@123
  mvc:
@@ -44,7 +45,8 @@
erp:
  db:
    driver_class_name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ur: jdbc:sqlserver://192.168.0.253:1433;databasename=xtyasrs_dual
#    ur: jdbc:sqlserver://192.168.0.253:1433;databasename=xtyasrs_dual
    ur: jdbc:sqlserver://192.168.4.208:1433;databasename=xtyasrs_dual
    username: sa
    password: sa@123
src/main/resources/mapper/OutStockMapper.xml
@@ -61,7 +61,7 @@
        b.FAdd,b.Fflag_finish, a.Fname, a.Fmodel
        from OutStockBillEntry a left join OutStockBill b on a.FInterID = b.FInterID
        where 1=1
        and b.Fflag_finish != 1
        and b.Fflag_finish != 1 and a.FQty > a.FAmount
        <if test="FSourceBillNo!=null and FSourceBillNo!='' ">
            and a.FSourceBillNo = #{FSourceBillNo}
        </if>
@@ -77,6 +77,13 @@
        from OutStockBillEntry a
        left join OutStockBill b on a.FInterID = b.FInterID
        where 1=1
        and b.Fflag_finish != 1 and a.FQty > a.FAmount
        <if test="FSourceBillNo!=null and FSourceBillNo!='' ">
            and a.FSourceBillNo = #{FSourceBillNo}
        </if>
        <if test="FBillNo != null and FBillNo != ''">
            and b.FBillNo = #{FBillNo}
        </if>
    </select>
    <select id="queryMatnrWithBillNo" resultMap="OutStockResultMap">
src/main/webapp/static/js/locNormal/locNormal.js
@@ -288,6 +288,14 @@
        }
        switch (obj.event) {
            case 'outLocNormal':
                var warehourse = data.warehouse;
                console.log(warehourse);
                if(warehourse !== 'cs'){
                    layer.msg("只能出材料平仓");
                    return;
                }
                layer.confirm('确定要出库[' + data.matnr + ']吗?', {
                    btn: ['确定', '取消'] //可以无限个按钮
                }, function (index, layero) {
src/main/webapp/static/js/pakStore/outStock.js
@@ -7,7 +7,7 @@
    var cols = [];
    cols.push(
        {field: 'fbillNo', merge: true, align: 'center', title: '单据编号', width: 150}
        , {field: 'fsourceBillNo', align: 'center', title: '生产单号', width: 100}
        , {field: 'fsourceBillNo', align: 'center', title: '生产单号', width: 150}
        , {field: 'fnumber', align: 'center', title: '物料编号', width: 140}
        , {field: 'fname', align: 'center', title: '物料名称'}
        , {field: 'fmodel', align: 'center', title: '规格', width: 200}
src/main/webapp/views/pakStore/outStockDetail.html
@@ -156,6 +156,7 @@
                success: function (res) {
                    if (res.code === 200){
                        parent.closeDetail(res.msg);
                        parent.tableReload();
                    } else if (res.code === 403){
                        top.location.href = baseUrl+"/";
                    } else {
src/main/webapp/views/pakStore/outStockNormalDetail.html
@@ -161,6 +161,7 @@
                success: function (res) {
                    if (res.code === 200) {
                        parent.closeDetail(res.msg);
                        parent.tableReload();
                    } else if (res.code === 403) {
                        top.location.href = baseUrl + "/";
                    } else {