人工出库-成品-出库推荐(已分配)库存
parent
4c9347d787
commit
086f825430
|
|
@ -36,5 +36,6 @@ public interface InventoryRepository extends JpaRepository<Inventory, Long>, 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)
|
@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<Inventory> queryInventory(long itemId);
|
List<Inventory> queryInventory(long itemId);
|
||||||
|
@Query(value = "SELECT i FROM Inventory i WHERE i.itemKey.id=?1", nativeQuery = false)
|
||||||
|
Inventory findByItemKey(Long itemKeyId);
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
||||||
**/
|
**/
|
||||||
public interface ItemKeyRepository extends JpaRepository<ItemKey, Long>, JpaSpecificationExecutor<ItemKey> {
|
public interface ItemKeyRepository extends JpaRepository<ItemKey, Long>, JpaSpecificationExecutor<ItemKey> {
|
||||||
@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")
|
@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")
|
@Query(value = "SELECT inv.itemKey FROM Inventory inv WHERE inv.id in ?1")
|
||||||
List<ItemKey> getByInv(List<Long> ids);
|
List<ItemKey> getByInv(List<Long> ids);
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,18 @@ public class TaskController {
|
||||||
return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus()));
|
return new ResponseEntity<>(ApiResult.success(apiResult.getMessage(),apiResult.getData()), HttpStatus.valueOf(apiResult.getStatus()));
|
||||||
}
|
}
|
||||||
@PostMapping("/devanRfid")
|
@PostMapping("/devanRfid")
|
||||||
@ApiOperation("解析RFID")
|
@ApiOperation("人工出库-解析RFID关联的库存信息")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> devanRfid(@RequestBody String rfid){
|
public ResponseEntity<Object> devanRfid(@RequestBody String data){
|
||||||
ApiResult apiResult = taskService.devanRfid(rfid);
|
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()));
|
return new ResponseEntity<>(apiResult, HttpStatus.valueOf(apiResult.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,8 +98,6 @@ public class TaskController {
|
||||||
@ApiOperation("查询task")
|
@ApiOperation("查询task")
|
||||||
@PreAuthorize("@el.check('task:list')")
|
@PreAuthorize("@el.check('task:list')")
|
||||||
public ResponseEntity<Object> queryAsnTask(TaskQueryCriteria criteria){
|
public ResponseEntity<Object> queryAsnTask(TaskQueryCriteria criteria){
|
||||||
// TaskQueryCriteria tq=new TaskQueryCriteria();
|
|
||||||
// tq.setAsnDetailId(id);
|
|
||||||
return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK);
|
return new ResponseEntity<>(taskService.queryAll(criteria),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +135,7 @@ public class TaskController {
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@PostMapping("/readRfid")
|
@PostMapping("/readRfid")
|
||||||
@Log("读取RFID代码")
|
@Log("入库-读取RFID码生成ItemKey和Task任务")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
public ResponseEntity<Object> readRfid(@RequestBody JSONObject body) {
|
public ResponseEntity<Object> readRfid(@RequestBody JSONObject body) {
|
||||||
String rfid=body.getString("rfid");
|
String rfid=body.getString("rfid");
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,8 @@ public interface ItemKeyService {
|
||||||
|
|
||||||
ItemKey getItemKey(Item item, String propC1,String orderNumber);
|
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<Long> ids);
|
ApiResult getItemKeyByInv(List<Long> ids);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -149,5 +149,7 @@ public interface TaskService {
|
||||||
*/
|
*/
|
||||||
ApiResult picking(Long[] ids);
|
ApiResult picking(Long[] ids);
|
||||||
|
|
||||||
ApiResult devanRfid(String rfid);
|
ApiResult devanRfidAsn(String rfid);
|
||||||
|
|
||||||
|
ApiResult devanRfidPT(String rfid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ public class ItemKeyServiceImpl implements ItemKeyService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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 itemKey;
|
||||||
itemKey = itemKeyRepository.getByItemKey(item.getId(),propC1,propC2,propC3,propC4,propC5,propC6);
|
itemKey = itemKeyRepository.getByItemKey(item.getId(),propC1,propC2,propC3,propC4,propC5,propC6);
|
||||||
if (itemKey==null){
|
if (itemKey==null){
|
||||||
|
|
@ -167,6 +167,7 @@ public class ItemKeyServiceImpl implements ItemKeyService {
|
||||||
itemKey.setPropC3(propC3);
|
itemKey.setPropC3(propC3);
|
||||||
itemKey.setPropC4(propC4);
|
itemKey.setPropC4(propC4);
|
||||||
itemKey.setPropC5(propC5);
|
itemKey.setPropC5(propC5);
|
||||||
|
itemKey.setPropC7(propC7);
|
||||||
itemKey.setPropC6(propC6.toString());
|
itemKey.setPropC6(propC6.toString());
|
||||||
itemKeyRepository.save(itemKey);
|
itemKeyRepository.save(itemKey);
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +268,7 @@ public class ItemKeyServiceImpl implements ItemKeyService {
|
||||||
Integer endQuan = text2PropC6.split(",").length;
|
Integer endQuan = text2PropC6.split(",").length;
|
||||||
//拆托后-RFID票
|
//拆托后-RFID票
|
||||||
ItemKey startItemKey=startInventory.getItemKey();
|
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票
|
//更新原来的RFID票
|
||||||
startItemKey.setPropC5(String.format("%04X", startQuan)+"");
|
startItemKey.setPropC5(String.format("%04X", startQuan)+"");
|
||||||
startItemKey.setPropC6(text1PropC6);
|
startItemKey.setPropC6(text1PropC6);
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
propC6Title=rfids[7].substring(0, 6);
|
propC6Title=rfids[7].substring(0, 6);
|
||||||
propC6_start_d=Long.valueOf(rfids[7].substring(6, rfids[7].length()-1));//起始成品码
|
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_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++) {
|
/*for (Long i = propC6_start_d; i < propC6_end_d; i++) {
|
||||||
if (propC6.length()<1){
|
if (propC6.length()<1){
|
||||||
propC6.append(propC6Title+i);
|
propC6.append(propC6Title+i);
|
||||||
|
|
@ -347,7 +347,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
return ApiResult.result(500, "重复读取", "");
|
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(",");
|
String[] lsh=itemKey.getPropC6().split(",");
|
||||||
int taskSum=0;// 生成task数量
|
int taskSum=0;// 生成task数量
|
||||||
|
|
@ -513,7 +513,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult devanRfid(String rfid) {
|
public ApiResult devanRfidAsn(String rfid) {
|
||||||
String[] rfids=rfid.split("\\|");
|
String[] rfids=rfid.split("\\|");
|
||||||
JSONObject data=new JSONObject();
|
JSONObject data=new JSONObject();
|
||||||
if (rfids.length>4){
|
if (rfids.length>4){
|
||||||
|
|
@ -552,4 +552,63 @@ public class TaskServiceImpl implements TaskService {
|
||||||
}
|
}
|
||||||
return ApiResult.fail(200,"操作成功",data);
|
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<Task> 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue