拆托-拆分库存

main
bbl\baobl 2024-03-15 14:10:26 +08:00
parent de24babbc7
commit 80922c0dc9
5 changed files with 75 additions and 25 deletions

View File

@ -62,6 +62,7 @@ public class Inventory extends BaseEntity implements Serializable {
@OneToOne @OneToOne
@JoinColumn(name = "`point_id`") @JoinColumn(name = "`point_id`")
@ApiModelProperty(value = "点位") @ApiModelProperty(value = "点位")
@NotFound(action= NotFoundAction.IGNORE)
private Point point; private Point point;
@Column(name = "`point_code`") @Column(name = "`point_code`")

View File

@ -25,6 +25,8 @@ import com.youchain.businessdata.service.dto.InventoryDto;
import com.youchain.businessdata.service.dto.InventoryQueryCriteria; import com.youchain.businessdata.service.dto.InventoryQueryCriteria;
import com.youchain.modules.system.domain.Dept; import com.youchain.modules.system.domain.Dept;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
import java.io.IOException; import java.io.IOException;
@ -105,6 +107,9 @@ public interface InventoryService {
*/ */
Inventory asnAddInventory(List<Map<String,Object>> taskListMap); Inventory asnAddInventory(List<Map<String,Object>> taskListMap);
@Transactional
Inventory getInventory(Double qty, Long ikID, Long pointId, String logType);
/** /**
* *
* @param taskList * @param taskList

View File

@ -15,8 +15,6 @@
*/ */
package com.youchain.businessdata.service.impl; package com.youchain.businessdata.service.impl;
import com.sun.jna.platform.win32.WinDef;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point; import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock; import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.repository.PointRepository; import com.youchain.basicdata.repository.PointRepository;
@ -42,9 +40,6 @@ import java.util.Map;
import java.io.IOException; import java.io.IOException;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.Query; import javax.persistence.Query;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -222,17 +217,7 @@ public class InventoryServiceImpl implements InventoryService {
String taskIds=taskMap.get("taskIds")+""; String taskIds=taskMap.get("taskIds")+"";
Long ikID=Long.valueOf(taskMap.get("ikID")+""); Long ikID=Long.valueOf(taskMap.get("ikID")+"");
Long pointId=Long.valueOf(taskMap.get("pointId")+""); Long pointId=Long.valueOf(taskMap.get("pointId")+"");
Inventory inventory =new Inventory(); Inventory inventory = getInventory(qty, ikID, pointId,BizStatus.RECEIVING_UP);
inventory.setQuantity(qty);
ItemKey itemKey=itemKeyRepository.getById(ikID);
inventory.setItemKey(itemKey);
Point point=pointRepository.getById(pointId);
inventory.setPoint(point);
inventory.setDept(UserUtils.getDept());
inventory.setStatus(BizStatus.OPEN);
inventoryRepository.save(inventory);
//添加库存日志
inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_UP,BizStatus.ADD,itemKey.getPropC3(),itemKey,null,inventory.getPoint(),null,null,0d,inventory.getQuantity(), itemKey.getPropC6(),null,inventory.getId(),"");
String[] arrTaskIds=taskIds.split(","); String[] arrTaskIds=taskIds.split(",");
for (int j = 0; j < arrTaskIds.length; j++) { for (int j = 0; j < arrTaskIds.length; j++) {
@ -245,6 +230,25 @@ public class InventoryServiceImpl implements InventoryService {
} }
return null; return null;
} }
@Override
@Transactional
public Inventory getInventory(Double qty, Long ikID, Long pointId, String logType) {
Inventory inventory =new Inventory();
inventory.setQuantity(qty);
ItemKey itemKey=itemKeyRepository.getById(ikID);
inventory.setItemKey(itemKey);
if (pointId!=null) {
Point point=pointRepository.getById(pointId);
inventory.setPoint(point);
}
inventory.setDept(UserUtils.getDept());
inventory.setStatus(BizStatus.OPEN);
inventoryRepository.save(inventory);
//添加库存日志
inventoryLogService.storeInventoryLog(logType,BizStatus.ADD,itemKey.getPropC3(),itemKey,null,inventory.getPoint(),null,null,0d,inventory.getQuantity(), itemKey.getPropC6(),null,inventory.getId(),"");
return inventory;
}
@Override @Override
public void pickDelInventory(List<Task> taskList) { public void pickDelInventory(List<Task> taskList) {

View File

@ -18,14 +18,14 @@ package com.youchain.businessdata.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.youchain.basicdata.domain.Item; import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.businessdata.domain.Inventory; import com.youchain.businessdata.domain.Inventory;
import com.youchain.businessdata.domain.ItemKey; import com.youchain.businessdata.domain.ItemKey;
import com.youchain.businessdata.domain.Task; import com.youchain.businessdata.domain.Task;
import com.youchain.businessdata.repository.InventoryRepository;
import com.youchain.businessdata.service.InventoryService;
import com.youchain.exception.handler.ApiResult; import com.youchain.exception.handler.ApiResult;
import com.youchain.utils.FileUtil; import com.youchain.utils.*;
import com.youchain.utils.PageUtil;
import com.youchain.utils.QueryHelp;
import com.youchain.utils.ValidationUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import com.youchain.businessdata.repository.ItemKeyRepository; import com.youchain.businessdata.repository.ItemKeyRepository;
import com.youchain.businessdata.service.ItemKeyService; import com.youchain.businessdata.service.ItemKeyService;
@ -54,6 +54,8 @@ import javax.servlet.http.HttpServletResponse;
public class ItemKeyServiceImpl implements ItemKeyService { public class ItemKeyServiceImpl implements ItemKeyService {
private final ItemKeyRepository itemKeyRepository; private final ItemKeyRepository itemKeyRepository;
private final InventoryRepository inventoryRepository;
private final InventoryService inventoryService;
private final ItemKeyMapper itemKeyMapper; private final ItemKeyMapper itemKeyMapper;
private final EntityManager entityManager; private final EntityManager entityManager;
@ -208,12 +210,26 @@ public class ItemKeyServiceImpl implements ItemKeyService {
JSONObject data=new JSONObject(); JSONObject data=new JSONObject();
data.put("textPropC6",arrPropC6); data.put("textPropC6",arrPropC6);
data.put("text1PropC6",arr1PropC6); StringBuffer sb1PropC6 = getStringBuffer(arr1PropC6);
data.put("text2PropC6",arr2PropC6); StringBuffer sb2PropC6 = getStringBuffer(arr2PropC6);
data.put("text1PropC6",sb1PropC6);
data.put("text2PropC6",sb2PropC6);
System.out.println("返回:"+data); System.out.println("返回:"+data);
return ApiResult.fail(200, "操作成功", data); return ApiResult.fail(200, "操作成功", data);
} }
private static StringBuffer getStringBuffer(List<String> arr1PropC6) {
StringBuffer sb1PropC6=new StringBuffer();
for (int i = 0; i < arr1PropC6.size(); i++) {
if (sb1PropC6.length()<1){
sb1PropC6.append(arr1PropC6.get(i));
}else {
sb1PropC6.append(","+ arr1PropC6.get(i));
}
}
return sb1PropC6;
}
@Override @Override
public ApiResult devanPropC6(JSONObject req) { public ApiResult devanPropC6(JSONObject req) {
String startPropC6=req.getString("startPropC6"); String startPropC6=req.getString("startPropC6");
@ -237,8 +253,32 @@ public class ItemKeyServiceImpl implements ItemKeyService {
@Override @Override
public ApiResult devanning(JSONObject req) { public ApiResult devanning(JSONObject req) {
System.out.println("req:"+req); JSONArray invIds=req.getJSONArray("invIds");//invIds
return null; String text1PropC6=req.getString("text1PropC6");
String text2PropC6=req.getString("text2PropC6");
for (int i = 0; i < invIds.size(); i++) {
Long invId=invIds.getLong(i);
Inventory startInventory=inventoryRepository.getById(invId);
//拆托后-库位位置
Point startPoint=startInventory.getPoint();
Point endPoint=null;
//拆托后-库存数量
Integer startQuan = text1PropC6.split(",").length;
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);
//更新原来的RFID票
startItemKey.setPropC5(String.format("%04X", startQuan)+"");
startItemKey.setPropC6(text1PropC6);
itemKeyRepository.save(startItemKey);
//更新原库存
startInventory.setQuantity(Double.valueOf(startQuan));
inventoryRepository.save(startInventory);
//生成拆托库存
Inventory inventory = inventoryService.getInventory(Double.valueOf(endQuan), endItemKey.getId(), null, BizStatus.MODIFY_LOT);
}
return ApiResult.fail(200, "操作成功", null);
} }

View File

@ -106,7 +106,7 @@ public interface BizStatus {
*/ */
public static String INVENTORY_ADJUST = "INVENTORY_ADJUST"; public static String INVENTORY_ADJUST = "INVENTORY_ADJUST";
/** /**
* - * -
*/ */
public static String MODIFY_LOT = "MODIFY_LOT"; public static String MODIFY_LOT = "MODIFY_LOT";
/** /**