| | |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SnowflakeIdWorker; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.EmptyPlateOutParam; |
| | |
| | | import com.zy.asrs.entity.param.StockOutParam; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.LocDetlDto; |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.OutLocDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.*; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.service.wms.Result; |
| | | import com.zy.common.service.wms.WmsService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private WrkMastLogService wrkMastLogService; |
| | | @Autowired |
| | | private WrkDetlLogService wrkDetlLogService; |
| | | @Autowired |
| | | private WmsService wmsService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | adjDetl.setOriQty(0.0D); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetlService.save(adjDetl, userId); |
| | | // 上报erp |
| | | String docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | Integer docId = 14; // 报溢单 |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | BillDto billDto = new BillDto(); |
| | | billDto.setMatnr(adjust.getMatnr()); |
| | | billDto.setQty(Math.abs(adjust.getCount())); |
| | | dtos.add(billDto); |
| | | Result result = wmsService.erpUpload(dtos, docId, docNum); |
| | | if (result.getCode() != 200) { |
| | | throw new CoolException("库存调整失败,原因:无法上报至ERP"); |
| | | } |
| | | // 修改原库存明细 |
| | | } else { |
| | | // 如果数量修改,则更新库存明细 |
| | | if (!adjust.getCount().equals(one.getAnfme())) { |
| | | // 当数量被修改为 0 时,直接清除库存明细 |
| | | if (adjust.getCount() == 0) { |
| | | // 上报erp |
| | | String docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | Integer docId = 9; // 报损单 |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | BillDto billDto = new BillDto(); |
| | | billDto.setMatnr(adjust.getMatnr()); |
| | | billDto.setQty(Math.abs(one.getAnfme())); |
| | | dtos.add(billDto); |
| | | Result result = wmsService.erpUpload(dtos, docId, docNum); |
| | | if (result.getCode() != 200) { |
| | | throw new CoolException("库存调整失败,原因:无法上报至ERP"); |
| | | } |
| | | // 删除库存 |
| | | if (!locDetlService.delete(new EntityWrapper<>(one))) { |
| | | throw new CoolException("清除库存明细失败"); |
| | | } |
| | |
| | | .eq("matnr", adjust.getMatnr()))) { |
| | | throw new CoolException("修改库存明细失败"); |
| | | } |
| | | // 上报erp |
| | | String docNum; |
| | | Integer docId; |
| | | if (one.getAnfme() > adjust.getCount()) { |
| | | // 报损 |
| | | docNum = "CD-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 9; |
| | | } else { |
| | | // 报溢 |
| | | docNum = "CS-" + String.valueOf(snowflakeIdWorker.nextId()).substring(0, 15); |
| | | docId = 14; |
| | | } |
| | | List<BillDto> dtos = new ArrayList<>(); |
| | | BillDto billDto = new BillDto(); |
| | | billDto.setMatnr(adjust.getMatnr()); |
| | | billDto.setQty(Math.abs(one.getAnfme() - adjust.getCount())); |
| | | dtos.add(billDto); |
| | | Result result = wmsService.erpUpload(dtos, docId, docNum); |
| | | if (result.getCode() != 200) { |
| | | throw new CoolException("库存调整失败,原因:无法上报至ERP"); |
| | | } |
| | | } |
| | | // 保存调整记录 |
| | | AdjDetl adjDetl = new AdjDetl(); |