diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java index 800bb1c..a27b382 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/InventoryRepository.java @@ -36,5 +36,6 @@ public interface InventoryRepository extends JpaRepository, Jpa */ @Query(value = "SELECT * FROM data_inventory inv WHERE inv.item_key_id in (select id from data_item_key where item_id = ?1 ) and inv.quantity>0 and inv.queued_qty=0 order by inv.create_time ", nativeQuery = true) List queryInventory(long itemId); - + @Query(value = "SELECT i FROM Inventory i WHERE i.itemKey.id=?1", nativeQuery = false) + Inventory findByItemKey(Long itemKeyId); } \ No newline at end of file diff --git a/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java b/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java index 5a73511..42f8584 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/repository/ItemKeyRepository.java @@ -30,7 +30,7 @@ import java.util.List; **/ public interface ItemKeyRepository extends JpaRepository, JpaSpecificationExecutor { @Query(value = "SELECT ik FROM ItemKey ik WHERE ik.item.id=?1 and ik.propC1=?2 and ik.propC2=?3 and ik.propC3=?4 and ik.propC4=?5 and ik.propC5=?6 and ik.propC6=?7") - ItemKey getByItemKey(Long id, String propC1, String propC2, String propC3, String propC4, String propC5, String propC6); + ItemKey getByItemKey(Long itemId, String propC1, String propC2, String propC3, String propC4, String propC5, String propC6); @Query(value = "SELECT inv.itemKey FROM Inventory inv WHERE inv.id in ?1") List getByInv(List ids); diff --git a/youchain-system/src/main/java/com/youchain/businessdata/rest/TaskController.java b/youchain-system/src/main/java/com/youchain/businessdata/rest/TaskController.java index 2c62ad5..4866c7a 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/rest/TaskController.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/rest/TaskController.java @@ -77,10 +77,18 @@ public class TaskController { return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus())); } @PostMapping("/devanRfid") - @ApiOperation("解析RFID") + @ApiOperation("人工出库-解析RFID关联的库存信息") @AnonymousAccess - public ResponseEntity devanRfid(@RequestBody String rfid){ - ApiResult apiResult = taskService.devanRfid(rfid); + public ResponseEntity devanRfid(@RequestBody String data){ + JSONObject jsonObject=JSONObject.parseObject(data); + String rfid=jsonObject.getString("rfid"); + String type=jsonObject.getString("type"); + ApiResult apiResult; + if (type.equals("ASN")){ + apiResult = taskService.devanRfidAsn(rfid); + }else { + apiResult = taskService.devanRfidPT(rfid); + } return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus())); } @@ -90,8 +98,6 @@ public class TaskController { @ApiOperation("查询task") @PreAuthorize("@el.check('task:list')") public ResponseEntity queryAsnTask(TaskQueryCriteria criteria){ -// TaskQueryCriteria tq=new TaskQueryCriteria(); -// tq.setAsnDetailId(id); return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK); } @@ -129,7 +135,7 @@ public class TaskController { return new ResponseEntity<>(HttpStatus.OK); } @PostMapping("/readRfid") - @Log("读取RFID代码") + @Log("入库-读取RFID码生成ItemKey和Task任务") @AnonymousAccess public ResponseEntity readRfid(@RequestBody JSONObject body) { String rfid=body.getString("rfid"); diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java index e2eef0d..e1ee97e 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/ItemKeyService.java @@ -87,7 +87,8 @@ public interface ItemKeyService { ItemKey getItemKey(Item item, String propC1,String orderNumber); - ItemKey getItemKey(Item item, String propC1,String propC2,String propC3,String propC4,String propC5,String propC6); + /** 南瑞-RFID对象类*/ + ItemKey getItemKey(Item item, String propC1,String propC2,String propC3,String propC4,String propC5,String propC6,String propC7); ApiResult getItemKeyByInv(List ids); diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/TaskService.java b/youchain-system/src/main/java/com/youchain/businessdata/service/TaskService.java index 074853b..6af243c 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/TaskService.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/TaskService.java @@ -149,5 +149,7 @@ public interface TaskService { */ ApiResult picking(Long[] ids); - ApiResult devanRfid(String rfid); + ApiResult devanRfidAsn(String rfid); + + ApiResult devanRfidPT(String rfid); } diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java index ad7696f..27e3892 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/ItemKeyServiceImpl.java @@ -156,7 +156,7 @@ public class ItemKeyServiceImpl implements ItemKeyService { } @Override - public ItemKey getItemKey(Item item, String propC1, String propC2, String propC3, String propC4, String propC5, String propC6) { + public ItemKey getItemKey(Item item, String propC1, String propC2, String propC3, String propC4, String propC5, String propC6,String propC7) { ItemKey itemKey; itemKey = itemKeyRepository.getByItemKey(item.getId(),propC1,propC2,propC3,propC4,propC5,propC6); if (itemKey==null){ @@ -167,6 +167,7 @@ public class ItemKeyServiceImpl implements ItemKeyService { itemKey.setPropC3(propC3); itemKey.setPropC4(propC4); itemKey.setPropC5(propC5); + itemKey.setPropC7(propC7); itemKey.setPropC6(propC6.toString()); itemKeyRepository.save(itemKey); } @@ -267,7 +268,7 @@ public class ItemKeyServiceImpl implements ItemKeyService { Integer endQuan = text2PropC6.split(",").length; //拆托后-RFID票 ItemKey startItemKey=startInventory.getItemKey(); - ItemKey endItemKey=getItemKey(startItemKey.getItem(), startItemKey.getPropC1(), startItemKey.getPropC2(), startItemKey.getPropC3(), startItemKey.getPropC4(), String.format("%04X", endQuan)+"", text2PropC6); + ItemKey endItemKey=getItemKey(startItemKey.getItem(), startItemKey.getPropC1(), startItemKey.getPropC2(), startItemKey.getPropC3(), startItemKey.getPropC4(), String.format("%04X", endQuan)+"", text2PropC6,""); //更新原来的RFID票 startItemKey.setPropC5(String.format("%04X", startQuan)+""); startItemKey.setPropC6(text1PropC6); diff --git a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java index 75bc1e1..c0ed825 100644 --- a/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java +++ b/youchain-system/src/main/java/com/youchain/businessdata/service/impl/TaskServiceImpl.java @@ -309,7 +309,7 @@ public class TaskServiceImpl implements TaskService { propC6Title=rfids[7].substring(0, 6); propC6_start_d=Long.valueOf(rfids[7].substring(6, rfids[7].length()-1));//起始成品码 propC6_end_d=Long.valueOf(rfids[8].substring(6, rfids[8].length()-1));//终止成品码 - propC6.append(propC6_start_d+"-"+propC6_end_d); + propC6.append(propC6Title+propC6_start_d+"-"+propC6Title+propC6_end_d); /*for (Long i = propC6_start_d; i < propC6_end_d; i++) { if (propC6.length()<1){ propC6.append(propC6Title+i); @@ -347,7 +347,7 @@ public class TaskServiceImpl implements TaskService { return ApiResult.result(500, "重复读取", ""); }; - ItemKey itemKey=itemKeyService.getItemKey(item, propC1, propC2,propC3,propC4,propC5,propC6.toString()); + ItemKey itemKey=itemKeyService.getItemKey(item, propC1, propC2,propC3,propC4,propC5,propC6.toString(),rfid); //获取流水号 String[] lsh=itemKey.getPropC6().split(","); int taskSum=0;// 生成task数量 @@ -513,7 +513,7 @@ public class TaskServiceImpl implements TaskService { } @Override - public ApiResult devanRfid(String rfid) { + public ApiResult devanRfidAsn(String rfid) { String[] rfids=rfid.split("\\|"); JSONObject data=new JSONObject(); if (rfids.length>4){ @@ -552,4 +552,63 @@ public class TaskServiceImpl implements TaskService { } return ApiResult.fail(200,"操作成功",data); } + + @Override + public ApiResult devanRfidPT(String rfid) { + String[] rfids=rfid.split("\\|"); + JSONObject data=new JSONObject(); + if (rfids.length>4) { + String sku = rfids[0] + "";//sku + String propC1 = rfids[1] + ""; + String propC2 = rfids[2] + ""; + String propC3 = rfids[3] + "";// 系统单号 + String propC4 = rfids[4] + "";// 厂家代码 + String propC5 = rfids[5] + "";// 收货数量(16禁止) + Item item=itemRepository.findByCode(sku); + if (item==null){ + return ApiResult.fail(400,"没有找到物料",null); + } + if (item.getGoodType().equals(BizStatus.CP)){ + String propC7=rfids[7].substring(0, rfids[7].length()-1);//起始成品码 + String propC8=rfids[8].substring(0, rfids[8].length()-1);//终止成品码 + // 成品解析 + ItemKey itemKey=itemKeyRepository.getByItemKey(item.getId(),propC1,propC2,propC3,propC4,propC5,propC7+"-"+propC8); + if (itemKey==null){ + return ApiResult.fail(400,"没有找到RFID码对应的库存",null); + } + Inventory inventory=inventoryRepository.findByItemKey(itemKey.getId()); + if (inventory==null){ + return ApiResult.fail(500,"库存异常",null); + } + List taskList=taskRepository.findByItemKey(itemKey.getId(), BizStatus.ALLOCATE); + if (taskList.size()!=1){ + return ApiResult.fail(500,"Task异常",null); + } + Task task=taskList.get(0); + PickDetail pickDetail=task.getPickDetail(); + Pick pick=pickDetail.getPick(); + if (inventory.getQueuedQty()<=0){ + // 未占用库存 询问是否更改出库库存 + }else { + // 已占用库存 推荐库存 + data.put("relatedBill1",pick.getRelatedBill1()); + data.put("relatedBill2",pick.getRelatedBill2()); + data.put("billType",pick.getBillType()); + data.put("sku",sku); + data.put("lineNo",pickDetail.getLineNo()); + data.put("RFID",rfid); + data.put("taskId",task.getId()); + data.put("orderQty",pickDetail.getOrderQty()); + data.put("receivedQty",inventory.getQueuedQty()); + } + }else if (item.getGoodType().equals(BizStatus.BCP)){ + + }else if (item.getGoodType().equals(BizStatus.LX)){ + // 料箱解析 + }else { + return ApiResult.fail(400,"请维护物料类型,无法识别解析方式",null); + } + } + return ApiResult.fail(200, "操作成功", data); + } }