| | |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.service.erp.entity.OutStockBillEntry; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Service("outStockService") |
| | | public class OutStockServiceImpl extends ServiceImpl<OutStockMapper, OutStockBillEntry> implements OutStockService{ |
| | | // 工作号生成规则默认类型 |
| | |
| | | private WrkDetlService wrkDetlService; |
| | | @Autowired |
| | | private LocNormalService locNormalService; |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | |
| | | @Override |
| | | public Page<OutStockBillEntry> queryOutStock(Page<OutStockBillEntry> page) { |
| | |
| | | @Override |
| | | public Integer queryOutStockFInterID(String supplier) { |
| | | return baseMapper.queryOutStockFInterID(supplier); |
| | | } |
| | | |
| | | /* 成品增量出库 */ |
| | | @Override |
| | | 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 (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 = jdbcTemplate.queryForList(sql, OutStockBillEntry.class); |
| | | log.info("step 2 ======>> {}", sql); |
| | | 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); |
| | | log.info("step 3 ======>> {}", sql); |
| | | return jdbcTemplate.update(sql) > 0; |
| | | } |
| | | |
| | | @Override |
| | |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位 |
| | | wrkMast.setBarcode(locMast.getBarcode()); // 条码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | // 如果为捡料出库需要判断托盘码是否为空 |
| | | if (ioType == 103) { |
| | | String zpallet = detlDto.getLocDetl().getZpallet(); |
| | | if (Cools.isEmpty(zpallet)) { |
| | | throw new CoolException("拣料出库必须含有托盘码"); |
| | | } |
| | | } |
| | | // 出库时,数量为0的直接忽略 |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | WrkDetl wrkDetl = new WrkDetl(); |