no message
parent
e84239bee7
commit
1905f8d8e3
|
|
@ -122,7 +122,7 @@ public class Point extends BaseEntity implements Serializable {
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "`stock_id`")
|
@JoinColumn(name = "`stock_id`")
|
||||||
@ApiModelProperty(value = "容器")
|
@ApiModelProperty(value = "容器")
|
||||||
private Stock stock;
|
private transient Stock stock;
|
||||||
public void copy(Point source){
|
public void copy(Point source){
|
||||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -64,8 +64,7 @@ public class Inventory extends BaseEntity implements Serializable {
|
||||||
private ItemKey itemKey;
|
private ItemKey itemKey;
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "`point_id`", nullable = false)
|
@JoinColumn(name = "`point_id`")
|
||||||
@NotNull
|
|
||||||
@ApiModelProperty(value = "点位")
|
@ApiModelProperty(value = "点位")
|
||||||
private Point point;
|
private Point point;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,12 +157,9 @@ public class AsnDetailController {
|
||||||
}
|
}
|
||||||
asnDetailService.create(asnDetail);
|
asnDetailService.create(asnDetail);
|
||||||
|
|
||||||
//添加订单数量
|
//刷新
|
||||||
if (asnDetail.getOrderQty() != null && asnDetail.getOrderQty() != 0) {
|
asnDetailService.updateAsnStatus(asnDetail.getAsn());
|
||||||
Asn asn = asnDetail.getAsn();
|
|
||||||
asn.setOrderQuantity(asn.getOrderQuantity() + asnDetail.getOrderQty());
|
|
||||||
asnService.update(asn);
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,9 +171,9 @@ public class AsnDetailController {
|
||||||
public ResponseEntity<Object> updateAsnDetail(@Validated @RequestBody AsnDetail resources) {
|
public ResponseEntity<Object> updateAsnDetail(@Validated @RequestBody AsnDetail resources) {
|
||||||
AsnDetailDto byId = asnDetailService.findById(resources.getId());
|
AsnDetailDto byId = asnDetailService.findById(resources.getId());
|
||||||
AsnDto byId1 = asnService.findById(resources.getAsn().getId());
|
AsnDto byId1 = asnService.findById(resources.getAsn().getId());
|
||||||
byId1.setOrderQuantity((byId1.getOrderQuantity() - byId.getOrderQty()) + resources.getOrderQty());
|
|
||||||
asnDetailService.update(resources);
|
asnDetailService.update(resources);
|
||||||
asnService.update(asnMapper.toEntity(byId1));
|
asnService.update(asnMapper.toEntity(byId1));
|
||||||
|
asnDetailService.updateAsnStatus(resources.getAsn());
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@ 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.service.dto.StockDto;
|
import com.youchain.basicdata.service.dto.StockDto;
|
||||||
|
import com.youchain.businessdata.domain.Asn;
|
||||||
import com.youchain.businessdata.domain.AsnDetail;
|
import com.youchain.businessdata.domain.AsnDetail;
|
||||||
import com.youchain.businessdata.domain.XppRecord;
|
import com.youchain.businessdata.domain.XppRecord;
|
||||||
import com.youchain.businessdata.inputJson.Zhengli;
|
import com.youchain.businessdata.inputJson.Zhengli;
|
||||||
|
|
@ -135,4 +136,10 @@ public interface AsnDetailService {
|
||||||
* @param zhengli
|
* @param zhengli
|
||||||
*/
|
*/
|
||||||
void zhengli(Zhengli zhengli);
|
void zhengli(Zhengli zhengli);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数量和状态
|
||||||
|
* @param asn
|
||||||
|
*/
|
||||||
|
void updateAsnStatus(Asn asn);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ import com.youchain.basicdata.domain.Area;
|
||||||
import com.youchain.basicdata.domain.Item;
|
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.StockRepository;
|
||||||
import com.youchain.basicdata.service.StockService;
|
import com.youchain.basicdata.service.StockService;
|
||||||
import com.youchain.businessdata.domain.*;
|
import com.youchain.businessdata.domain.*;
|
||||||
import com.youchain.businessdata.inputJson.Zhengli;
|
import com.youchain.businessdata.inputJson.Zhengli;
|
||||||
|
|
@ -61,6 +63,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
||||||
private final AsnDetailRepository asnDetailRepository;
|
private final AsnDetailRepository asnDetailRepository;
|
||||||
private final TaskRepository taskRepository;
|
private final TaskRepository taskRepository;
|
||||||
private final XppRecordRepository xppRecordRepository;
|
private final XppRecordRepository xppRecordRepository;
|
||||||
|
private final StockRepository stockRepository;
|
||||||
|
private final PointRepository pointRepository;
|
||||||
private final AsnDetailMapper asnDetailMapper;
|
private final AsnDetailMapper asnDetailMapper;
|
||||||
private final EntityManager entityMapper;
|
private final EntityManager entityMapper;
|
||||||
private final AsnService asnService;
|
private final AsnService asnService;
|
||||||
|
|
@ -159,8 +163,7 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
||||||
asn.setReceivedQuantity(asn.getReceivedQuantity() - t.getPlanQty());
|
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(),
|
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(), "取消上架");
|
||||||
null, ewm, BizStatus.ASN, inventory.getId(), inventory.getId(), "取消上架");
|
|
||||||
taskRepository.delete(t);
|
taskRepository.delete(t);
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
this.delete(d.getId());
|
this.delete(d.getId());
|
||||||
|
|
@ -227,6 +230,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
||||||
public void zhengli(Zhengli zhengli) {
|
public void zhengli(Zhengli zhengli) {
|
||||||
AsnDetail asnDetail = asnDetailRepository.findById(zhengli.getId()).get();
|
AsnDetail asnDetail = asnDetailRepository.findById(zhengli.getId()).get();
|
||||||
Item item = asnDetail.getItem();
|
Item item = asnDetail.getItem();
|
||||||
|
Stock stock = zhengli.getStock();
|
||||||
|
Point point = zhengli.getPoint();
|
||||||
if (item.getIsInspection()) {
|
if (item.getIsInspection()) {
|
||||||
throw new BadRequestException("该商品需要质检,请先完成质检!");
|
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());
|
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 task = taskService.storeTask(asnDetail, null, zhengli.getArea(), itemKey, null, point, zhengli.getReceivedQty());
|
||||||
task.setSrcStockCode(zhengli.getStock().getCode());
|
task.setSrcStockCode(stock.getCode());
|
||||||
task.setSrcStock(zhengli.getStock());
|
task.setSrcStock(stock);
|
||||||
taskRepository.save(task);
|
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("待入库");
|
inventory.setStatus("待入库");
|
||||||
inventoryService.update(inventory);
|
inventoryService.update(inventory);
|
||||||
|
|
||||||
|
|
@ -260,11 +265,24 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
||||||
asnDetail.setReceivedQty(asnDetail.getReceivedQty() + zhengli.getReceivedQty());
|
asnDetail.setReceivedQty(asnDetail.getReceivedQty() + zhengli.getReceivedQty());
|
||||||
asnDetailRepository.save(asnDetail);
|
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());
|
updateAsnStatus(asnDetail.getAsn());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateAsnStatus(Asn asn) {
|
@Override
|
||||||
|
public void updateAsnStatus(Asn asn) {
|
||||||
double orderQty = 0;
|
double orderQty = 0;
|
||||||
double receivedQty = 0;
|
double receivedQty = 0;
|
||||||
List<AsnDetail> asnDetails = asnDetailRepository.queryByAsnId(asn.getId());
|
List<AsnDetail> asnDetails = asnDetailRepository.queryByAsnId(asn.getId());
|
||||||
|
|
@ -272,6 +290,8 @@ public class AsnDetailServiceImpl implements AsnDetailService {
|
||||||
orderQty += detail.getOrderQty();
|
orderQty += detail.getOrderQty();
|
||||||
receivedQty += detail.getReceivedQty();
|
receivedQty += detail.getReceivedQty();
|
||||||
}
|
}
|
||||||
|
asn.setOrderQuantity(orderQty);
|
||||||
|
asn.setReceivedQuantity(receivedQty);
|
||||||
if (orderQty == receivedQty) {
|
if (orderQty == receivedQty) {
|
||||||
asn.setStatus(BizStatus.RECEIVED);
|
asn.setStatus(BizStatus.RECEIVED);
|
||||||
} else if (receivedQty > 0 && receivedQty < orderQty) {
|
} else if (receivedQty > 0 && receivedQty < orderQty) {
|
||||||
|
|
|
||||||
|
|
@ -396,23 +396,23 @@ public class InventoryServiceImpl implements InventoryService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Inventory getInventory(ItemKey itemKey, Point point, Stock stock, Dept dept, String type) {
|
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;
|
Inventory inventory = null;
|
||||||
if (inventoryList.size() > 0) {
|
if (inventoryList.size() > 0) {
|
||||||
inventory = inventoryList.get(0);
|
inventory = inventoryList.get(0);
|
||||||
} else {
|
} else {
|
||||||
//创建Inventory
|
//创建Inventory
|
||||||
if (type.equals(BizStatus.ASN)) {
|
|
||||||
inventory = new Inventory();
|
inventory = new Inventory();
|
||||||
inventory.setItemKey(itemKey);
|
inventory.setItemKey(itemKey);
|
||||||
|
if (point != null) {
|
||||||
inventory.setPoint(point);
|
inventory.setPoint(point);
|
||||||
inventory.setPointCode(point.getCode());
|
inventory.setPointCode(point.getCode());
|
||||||
|
}
|
||||||
inventory.setStock(stock);
|
inventory.setStock(stock);
|
||||||
inventory.setStockCode(stock.getCode());
|
inventory.setStockCode(stock.getCode());
|
||||||
inventory.setDept(dept);
|
inventory.setDept(dept);
|
||||||
inventoryRepository.save(inventory);
|
inventoryRepository.save(inventory);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ public class TaskServiceImpl implements TaskService {
|
||||||
t.setTaskStatus(BizStatus.OPEN);
|
t.setTaskStatus(BizStatus.OPEN);
|
||||||
t.setItemKey(ik);
|
t.setItemKey(ik);
|
||||||
t.setArea(area);
|
t.setArea(area);
|
||||||
t.setDept(srcPoint.getDept());
|
t.setDept(ik.getItem().getDept());
|
||||||
if (srcPoint != null) {
|
if (srcPoint != null) {
|
||||||
t.setSrcPoint(srcPoint);
|
t.setSrcPoint(srcPoint);
|
||||||
t.setSrcPointCode(srcPoint.getCode());
|
t.setSrcPointCode(srcPoint.getCode());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue