| | |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.CheckTaskListParam; |
| | | import com.zy.asrs.enums.CheckStatusEnum; |
| | | import com.zy.asrs.mapper.CheckOrderMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service("checkOrderService") |
| | |
| | | } |
| | | |
| | | for (CheckOrderDetl checkOrderDetl: checkTaskListParam.getCheckOrderDetlList()){ |
| | | checkOrderDetl.setDiffQty(checkOrderDetl.getWorkQty().subtract(checkOrderDetl.getAnfme())); |
| | | checkOrderDetl.setStatus(3); |
| | | if (!checkOrderDetlService.updateById(checkOrderDetl)){ |
| | | throw new CoolException("更新盘点状态失败"); |
| | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void adjustOrderComplete(Long orderId, Long userId) { |
| | | CheckOrder checkOrder = this.selectById(orderId); |
| | | if (Cools.isEmpty(checkOrder)) { |
| | | throw new CoolException("数据错误"); |
| | | } |
| | | List<CheckOrderDetl> selectList = checkOrderDetlService.selectList(new EntityWrapper<CheckOrderDetl>().eq("order_id", orderId)); |
| | | for (CheckOrderDetl checkOrderDetl : selectList) { |
| | | |
| | | LocDetl locDetl = locDetlService.selectById(checkOrderDetl.getLocDetlId()); |
| | | if (Cools.isEmpty(locDetl)) { |
| | | throw new CoolException("未找到库存数据,数据错误"); |
| | | } |
| | | if (checkOrderDetl.getStatus().equals(CheckStatusEnum.ALLOW.type)) { |
| | | BigDecimal decimal = locDetl.getBookQty().add(checkOrderDetl.getDiffQty()); |
| | | locDetl.setAnfme(decimal.doubleValue()); |
| | | }else if (checkOrderDetl.getStatus().equals(CheckStatusEnum.FORBID.type)) { |
| | | if (locDetl.getDiffQty().compareTo(BigDecimal.ZERO) < 0) { |
| | | BigDecimal subtract = new BigDecimal(locDetl.getAnfme().toString()).subtract(locDetl.getDiffQty()); |
| | | locDetl.setAnfme(subtract.doubleValue()); |
| | | } |
| | | } |
| | | |
| | | locDetl.setDiffQty(BigDecimal.ZERO); |
| | | locDetl.setModiTime(new Date()); |
| | | if (!locDetlService.updateById(locDetl)){ |
| | | throw new CoolException("更新库存数据失败"); |
| | | } |
| | | } |
| | | |
| | | checkOrder.setSettle(4L); |
| | | checkOrder.setUpdateTime(new Date()); |
| | | if (!this.updateById(checkOrder)){ |
| | | throw new CoolException("更新调整单状态失败"); |
| | | } |
| | | } |
| | | } |