#
18516761980
2021-09-29 15c8f00ab3a1e3d2d96b56bae0ec11efedd60231
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) {
@@ -94,11 +97,9 @@
        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 (jdbcTemplate.update(sql) > 0) {
            log.info("step 1 ======>> {}", sql);
            sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#}";
            sql = MessageFormat.format(sql, Fnumber, FInterID);
            List<OutStockBillEntry> select = this.selectList(new EntityWrapper<OutStockBillEntry>().eq("Fnumber", Fnumber).eq("FInterID", FInterID));
            log.info("step 2 ======>> {}", sql);
            OutStockBillEntry outStockBillEntry = select.get(0);
            boolean complete = false;
            if (outStockBillEntry.getFQty().compareTo(BigDecimal.ZERO) == 1) {
@@ -125,13 +126,37 @@
    private boolean completeCPakOut(String FBillNo){
        String sql = "update OutStockbill set Fflag_finish = 1 where FBillNo = ''{0}''";
        sql = MessageFormat.format(sql, FBillNo);
        log.info("step 3 ======>> {}", sql);
        return jdbcTemplate.update(sql) > 0;
    }
    @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());
        // 获取库位明细
@@ -241,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());