| | |
| | | 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.entity.FieldsItem; |
| | | import com.vincent.rsf.server.system.service.DictDataService; |
| | | import com.vincent.rsf.server.system.service.DictTypeService; |
| | | import com.vincent.rsf.server.system.service.FieldsItemService; |
| | | import com.vincent.rsf.server.system.service.impl.FieldsItemServiceImpl; |
| | | 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.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | public class PdaCheckOrderServiceImpl implements PdaCheckOrderService { |
| | |
| | | private DictDataService dictDataService; |
| | | @Autowired |
| | | private MatnrService matnrService; |
| | | @Autowired |
| | | private FieldsItemService fieldsItemService; |
| | | |
| | | |
| | | @Override |
| | |
| | | * @version 1.0 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R confirmMatnr(Map<String, Object> map) { |
| | | if (Objects.isNull(map)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | |
| | | return R.error("任务状态不是等待确认"); |
| | | } |
| | | |
| | | List<Matnr> items = JSONArray.parseArray(JSONArray.toJSONString(map.get("matnrs")), Map<String, Object>.class); |
| | | List<CheckDiffItem> items = JSONArray.parseArray(JSONArray.toJSONString(map.get("matnrs")), CheckDiffItem.class); |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | | |
| | | TaskItem item1 = taskItemService.getOne(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()).last("limit 1")); |
| | | |
| | | items.forEach(item -> { |
| | | TaskItem taskItem = new TaskItem(); |
| | | if (!Objects.isNull(item1)) { |
| | | BeanUtils.copyProperties(item1, taskItem); |
| | | } |
| | | Matnr matnr = matnrService.getOne(new LambdaQueryWrapper<Matnr>().eq(Matnr::getCode, item.getMatnrCode())); |
| | | if (Objects.isNull(matnr)) { |
| | | throw new CoolException("物料信息不存在 !!"); |
| | | } |
| | | |
| | | // if (Objects.isNull(map.get("taskId"))) { |
| | | // throw new CoolException("任务ID不能为空!!"); |
| | | // } |
| | | // if (Objects.isNull(map.get("matnr"))) { |
| | | // throw new CoolException("物料编码不能为空!!"); |
| | | // } |
| | | // if (Objects.isNull(map.get("batch"))) { |
| | | // throw new CoolException("批次不能为空!!"); |
| | | // } |
| | | taskItem.setTaskId(task.getId()) |
| | | .setId(null) |
| | | .setFieldsIndex(null) |
| | | .setMatnrId(matnr.getId()) |
| | | .setMatnrCode(matnr.getCode()) |
| | | .setMaktx(matnr.getName()) |
| | | .setAnfme(item.getCheckQty()); |
| | | |
| | | FieldsItem fieldsItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getValue, item.getFieldsIndex()).last("limit 1")); |
| | | if (Objects.isNull(fieldsItem)) { |
| | | throw new CoolException("当前票号不存在库存中,请拿出后重新入库!!"); |
| | | } |
| | | taskItem.setFieldsIndex(fieldsItem.getUuid()); |
| | | |
| | | return null; |
| | | taskItems.add(taskItem); |
| | | }); |
| | | |
| | | if (!taskItemService.saveBatch(taskItems)) { |
| | | throw new CoolException("新增盘点物料失败!!"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |