| | |
| | | import com.vincent.rsf.server.api.service.PdaCheckOrderService; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.CheckDiffExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.enums.OrderWorkType; |
| | | import com.vincent.rsf.server.manager.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.system.constant.DictTypeCode; |
| | | import com.vincent.rsf.server.system.entity.DictData; |
| | | import com.vincent.rsf.server.system.service.DictDataService; |
| | | import com.vincent.rsf.server.system.service.DictTypeService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | @Service |
| | | public class PdaCheckOrderServiceImpl implements PdaCheckOrderService { |
| | |
| | | private DictTypeService dictTypeService; |
| | | @Autowired |
| | | private DictDataService dictDataService; |
| | | @Autowired |
| | | private MatnrService matnrService; |
| | | @Autowired |
| | | private CheckOrderService checkOrderService; |
| | | |
| | | @Override |
| | | public R getCheckList(String code) { |
| | | LambdaQueryWrapper<CheckDiff> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(!Cools.isEmpty(code),CheckDiff::getOrderCode,code); |
| | | lambdaQueryWrapper.eq(!Cools.isEmpty(code), CheckDiff::getOrderCode, code); |
| | | List<CheckDiff> waveList = checkDiffService.list(lambdaQueryWrapper); |
| | | return R.ok(waveList); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public R getCheckTaskItemList(String barcode,String checkCode) { |
| | | public R getCheckTaskItemList(String barcode, String checkCode) { |
| | | |
| | | List<CheckDiffItem> checkDiffItems = checkDiffItemService.list(new LambdaQueryWrapper<CheckDiffItem>() |
| | | .eq(CheckDiffItem::getBarcode, barcode) |
| | | .eq(CheckDiffItem::getOrderCode, checkCode) |
| | | ); |
| | | if (checkDiffItems.isEmpty()){ |
| | | if (checkDiffItems.isEmpty()) { |
| | | throw new CoolException("此条码不在当前盘点单中"); |
| | | } |
| | | LambdaQueryWrapper<Task> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | lambdaQueryWrapper.eq(Task::getBarcode, barcode); |
| | | Task task = taskService.getOne(lambdaQueryWrapper); |
| | | if (null == task){ |
| | | if (null == task) { |
| | | throw new CoolException("未找到容器号对应任务"); |
| | | } |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)){ |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | } |
| | | |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveCheckDiff(SaveCheckDiffParams params,Long loginUserId) { |
| | | public R saveCheckDiff(SaveCheckDiffParams params, Long loginUserId) { |
| | | CheckDiff checkDiff = checkDiffService.getById(params.getCheckId()); |
| | | if (null == checkDiff){ |
| | | if (null == checkDiff) { |
| | | return R.error("未找到盘点差异单"); |
| | | } |
| | | if (checkDiff.getExceStatus().equals(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_END.val)){ |
| | | if (checkDiff.getExceStatus().equals(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_END.val)) { |
| | | return R.error("该盘点单已完成"); |
| | | } |
| | | for (CheckDiffItem checkDiffItem: params.getCheckDiffItems()){ |
| | | CheckDiffItem diffItem = checkDiffItemService.getById(checkDiffItem.getId()); |
| | | if (null == diffItem){ |
| | | return R.error("数据错误,未找到差异单明细"); |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, params.getContainer())); |
| | | if (null == task) { |
| | | throw new CoolException("数据错误,未找到容器码对应盘点任务"); |
| | | } |
| | | for (CheckDiffItem checkDiffItem : params.getCheckDiffItems()) { |
| | | CheckDiffItem diffItem = new CheckDiffItem(); |
| | | if (Objects.isNull(checkDiffItem.getId())) { |
| | | BeanUtils.copyProperties(checkDiffItem, diffItem); |
| | | diffItem.setCheckId(params.getCheckId()); |
| | | |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, diffItem.getMatnrCode())); |
| | | if (Objects.isNull(matnr)) { |
| | | throw new CoolException("单据物料名称不存在!!"); |
| | | } |
| | | |
| | | if (!checkDiffItemService.save(diffItem)) { |
| | | throw new CoolException("新增明细保存失败!!"); |
| | | } |
| | | //新增任务明细信息 |
| | | TaskItem taskItem = new TaskItem(); |
| | | BeanUtils.copyProperties(diffItem, diffItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .setOrderType(OrderType.ORDER_CHECK.type) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_STOCK_CHECK.type)) |
| | | .setAnfme(diffItem.getAnfme()) |
| | | .setWorkQty(0.0) |
| | | .setBatch(diffItem.getBatch()) |
| | | .setMaktx(matnr.getName()) |
| | | .setMatnrCode(diffItem.getMatnrCode()) |
| | | .setSpec(diffItem.getSpec()) |
| | | .setModel(diffItem.getModel()) |
| | | .setMatnrId(matnr.getId()) |
| | | .setCreateBy(loginUserId) |
| | | //漏盘库存,新增没有盘点单明细ID |
| | | .setSource(diffItem.getId()) |
| | | .setSourceId(params.getCheckId()) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateBy(loginUserId) |
| | | .setMemo("不在库明细,盘漏新增") |
| | | .setUpdateTime(new Date()) |
| | | .setId(null) |
| | | //盘点单ID |
| | | .setOrderId(checkDiff.getOrderId()); |
| | | if (!taskItemService.save(taskItem)) { |
| | | throw new CoolException("新增盘点明细保存失败!!"); |
| | | } |
| | | } else { |
| | | diffItem = checkDiffItemService.getById(checkDiffItem.getId()); |
| | | if (null == diffItem) { |
| | | return R.error("数据错误,未找到差异单明细"); |
| | | } |
| | | } |
| | | |
| | | checkDiffItem.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | if(!checkDiffItemService.updateById(checkDiffItem)){ |
| | | if (!checkDiffItemService.updateById(checkDiffItem)) { |
| | | throw new CoolException("更新差异单明细失败"); |
| | | } |
| | | checkDiff.setCheckQty(checkDiff.getCheckQty()+checkDiffItem.getCheckQty()); |
| | | Double checkQty = Math.round((checkDiff.getCheckQty() + checkDiffItem.getCheckQty()) * 10000) / 10000.0; |
| | | checkDiff.setCheckQty(checkQty); |
| | | } |
| | | checkDiff.setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_HOLD.val); |
| | | |
| | | if(!checkDiffService.updateById(checkDiff)){ |
| | | if (!checkDiffService.updateById(checkDiff)) { |
| | | throw new CoolException("更新差异单失败"); |
| | | } |
| | | Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, params.getContainer())); |
| | | if (null == task){ |
| | | throw new CoolException("数据错误,未找到容器码对应盘点任务"); |
| | | } |
| | | |
| | | task.setTaskStatus(TaskStsType.COMPLETE_OUT.id); |
| | | task.setUpdateBy(loginUserId); |
| | | task.setUpdateTime(new Date()); |
| | | if (!taskService.updateById(task)){ |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("更新任务失败"); |
| | | } |
| | | return R.ok("盘点完成"); |