no message

main
HUOJIN\92525 2024-09-24 18:00:33 +08:00
parent e84239bee7
commit 1905f8d8e3
7 changed files with 100 additions and 77 deletions

View File

@ -122,7 +122,7 @@ public class Point extends BaseEntity implements Serializable {
@OneToOne
@JoinColumn(name = "`stock_id`")
@ApiModelProperty(value = "容器")
private Stock stock;
private transient Stock stock;
public void copy(Point source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}

View File

@ -64,8 +64,7 @@ public class Inventory extends BaseEntity implements Serializable {
private ItemKey itemKey;
@OneToOne
@JoinColumn(name = "`point_id`", nullable = false)
@NotNull
@JoinColumn(name = "`point_id`")
@ApiModelProperty(value = "点位")
private Point point;

View File

@ -157,12 +157,9 @@ public class AsnDetailController {
}
asnDetailService.create(asnDetail);
//添加订单数量
if (asnDetail.getOrderQty() != null && asnDetail.getOrderQty() != 0) {
Asn asn = asnDetail.getAsn();
asn.setOrderQuantity(asn.getOrderQuantity() + asnDetail.getOrderQty());
asnService.update(asn);
}
//刷新
asnDetailService.updateAsnStatus(asnDetail.getAsn());
return new ResponseEntity<>(HttpStatus.OK);
}
@ -174,9 +171,9 @@ public class AsnDetailController {
public ResponseEntity<Object> updateAsnDetail(@Validated @RequestBody AsnDetail resources) {
AsnDetailDto byId = asnDetailService.findById(resources.getId());
AsnDto byId1 = asnService.findById(resources.getAsn().getId());
byId1.setOrderQuantity((byId1.getOrderQuantity() - byId.getOrderQty()) + resources.getOrderQty());
asnDetailService.update(resources);
asnService.update(asnMapper.toEntity(byId1));
asnDetailService.updateAsnStatus(resources.getAsn());
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

View File

@ -19,6 +19,7 @@ import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.service.dto.StockDto;
import com.youchain.businessdata.domain.Asn;
import com.youchain.businessdata.domain.AsnDetail;
import com.youchain.businessdata.domain.XppRecord;
import com.youchain.businessdata.inputJson.Zhengli;
@ -135,4 +136,10 @@ public interface AsnDetailService {
* @param zhengli
*/
void zhengli(Zhengli zhengli);
/**
*
* @param asn
*/
void updateAsnStatus(Asn asn);
}

View File

@ -19,6 +19,8 @@ import com.youchain.basicdata.domain.Area;
import com.youchain.basicdata.domain.Item;
import com.youchain.basicdata.domain.Point;
import com.youchain.basicdata.domain.Stock;
import com.youchain.basicdata.repository.PointRepository;
import com.youchain.basicdata.repository.StockRepository;
import com.youchain.basicdata.service.StockService;
import com.youchain.businessdata.domain.*;
import com.youchain.businessdata.inputJson.Zhengli;
@ -61,6 +63,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
private final AsnDetailRepository asnDetailRepository;
private final TaskRepository taskRepository;
private final XppRecordRepository xppRecordRepository;
private final StockRepository stockRepository;
private final PointRepository pointRepository;
private final AsnDetailMapper asnDetailMapper;
private final EntityManager entityMapper;
private final AsnService asnService;
@ -159,8 +163,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
asn.setReceivedQuantity(asn.getReceivedQuantity() - t.getPlanQty());
}
InventoryLog log = inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, t.getArea(), t.getItemKey(), t.getDstPoint(), t.getSrcPoint(), null, null, srcQty, t.getPlanQty(),
null, ewm, BizStatus.ASN, inventory.getId(), inventory.getId(), "取消上架");
InventoryLog log = inventoryLogService.storeInventoryLog(BizStatus.RECEIVING_CANCEL, BizStatus.REDUCE, null, t.getArea(), t.getItemKey(), t.getDstPoint(), t.getSrcPoint(), null, null, srcQty, t.getPlanQty(), null, ewm, BizStatus.ASN, inventory.getId(), inventory.getId(), "取消上架");
taskRepository.delete(t);
if (d != null) {
this.delete(d.getId());
@ -227,6 +230,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
public void zhengli(Zhengli zhengli) {
AsnDetail asnDetail = asnDetailRepository.findById(zhengli.getId()).get();
Item item = asnDetail.getItem();
Stock stock = zhengli.getStock();
Point point = zhengli.getPoint();
if (item.getIsInspection()) {
throw new BadRequestException("该商品需要质检,请先完成质检!");
}
@ -235,13 +240,13 @@ public class AsnDetailServiceImpl implements AsnDetailService {
ItemKey itemKey = itemKeyService.getItemKey(item, asnDetail.getPropC1(), asnDetail.getPropC3(), asnDetail.getPropC4(), asnDetail.getPropC5(), asnDetail.getPropC6(), asnDetail.getPropD1());
//生成入库记录
Task task = taskService.storeTask(asnDetail, null, zhengli.getArea(), itemKey, null, zhengli.getPoint(), zhengli.getReceivedQty());
task.setSrcStockCode(zhengli.getStock().getCode());
task.setSrcStock(zhengli.getStock());
Task task = taskService.storeTask(asnDetail, null, zhengli.getArea(), itemKey, null, point, zhengli.getReceivedQty());
task.setSrcStockCode(stock.getCode());
task.setSrcStock(stock);
taskRepository.save(task);
//生成库存记录
Inventory inventory = inventoryService.getInventory(itemKey, asnDetail.getPoint(), zhengli.getStock(), item.getDept(), BizStatus.ASN);
Inventory inventory = inventoryService.getInventory(itemKey, point, stock, item.getDept(), BizStatus.ASN);
inventory.setStatus("待入库");
inventoryService.update(inventory);
@ -260,11 +265,24 @@ public class AsnDetailServiceImpl implements AsnDetailService {
asnDetail.setReceivedQty(asnDetail.getReceivedQty() + zhengli.getReceivedQty());
asnDetailRepository.save(asnDetail);
//容器绑定
stock.setPoint(point);
stock.setStatus(BaseStatus.USED);
stock.setDept(item.getDept());
stockRepository.save(stock);
if (point != null) {
point.setStatus(BaseStatus.USED);
pointRepository.save(point);
}
//刷新单头状态
updateAsnStatus(asnDetail.getAsn());
}
private void updateAsnStatus(Asn asn) {
@Override
public void updateAsnStatus(Asn asn) {
double orderQty = 0;
double receivedQty = 0;
List<AsnDetail> asnDetails = asnDetailRepository.queryByAsnId(asn.getId());
@ -272,6 +290,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
orderQty += detail.getOrderQty();
receivedQty += detail.getReceivedQty();
}
asn.setOrderQuantity(orderQty);
asn.setReceivedQuantity(receivedQty);
if (orderQty == receivedQty) {
asn.setStatus(BizStatus.RECEIVED);
} else if (receivedQty > 0 && receivedQty < orderQty) {

View File

@ -396,23 +396,23 @@ public class InventoryServiceImpl implements InventoryService {
@Override
@Transactional(rollbackFor = Exception.class)
public Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type) {
List<Inventory> inventoryList = inventoryRepository.findByInventory(itemKey.getId(), point.getId(), stock.getId(), dept.getId());
List<Inventory> inventoryList = inventoryRepository.findByInventory(itemKey.getId(), point==null?null:point.getId(), stock.getId(), dept.getId());
Inventory inventory = null;
if (inventoryList.size() > 0) {
inventory = inventoryList.get(0);
} else {
//创建Inventory
if (type.equals(BizStatus.ASN)) {
inventory = new Inventory();
inventory.setItemKey(itemKey);
if (point != null) {
inventory.setPoint(point);
inventory.setPointCode(point.getCode());
}
inventory.setStock(stock);
inventory.setStockCode(stock.getCode());
inventory.setDept(dept);
inventoryRepository.save(inventory);
}
}
return inventory;
}
}

View File

@ -180,7 +180,7 @@ public class TaskServiceImpl implements TaskService {
t.setTaskStatus(BizStatus.OPEN);
t.setItemKey(ik);
t.setArea(area);
t.setDept(srcPoint.getDept());
t.setDept(ik.getItem().getDept());
if (srcPoint != null) {
t.setSrcPoint(srcPoint);
t.setSrcPointCode(srcPoint.getCode());