| | |
| | | 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) { |
| | |
| | | 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 |
| | | @Transactional |
| | | public void startupFullTakeStore(StockOutParam param, Long userId) { |