| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | private ErpService erpService; |
| | | @Autowired |
| | | private LocNormalLogService locNormalLogService; |
| | | |
| | | |
| | | /** |
| | | * |
| | |
| | | */ |
| | | @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) { |
| | |
| | | } |
| | | } |
| | | |
| | | // 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())); //借用famount字段,控制下发出库任务数量 |
| | | outStockBillEntry.setFAuxQty(outStockBillEntry.getFAuxQty().subtract(locNormals.getAnfme())); |
| | | 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()); |
| | | throw new CoolException("更新ERP成品出库数据[matnr=" + locNormals.getMatnr() + ",FBillNo=" + param.getSupplier() + "]失败"); |
| | | } |
| | | |
| | | } |
| | | return R.ok("平仓出库成功"); |
| | | } |