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 @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));
} }

View File

@ -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;

View File

@ -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);
} }

View File

@ -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);
} }

View File

@ -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);
@ -257,14 +262,27 @@ public class AsnDetailServiceImpl implements AsnDetailService {
//回写收货数量 //回写收货数量
asnDetail.setStock(zhengli.getStock()); asnDetail.setStock(zhengli.getStock());
asnDetail.setPoint(zhengli.getPoint()); asnDetail.setPoint(zhengli.getPoint());
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) {

View File

@ -125,65 +125,65 @@ public class InventoryServiceImpl implements InventoryService {
@Override @Override
public void download(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void download(List<InventoryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"Inventory"); List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "Inventory");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override @Override
public void downloadXb(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void downloadXb(List<InventoryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"InvXb"); List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "InvXb");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override @Override
public void downloadXt(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void downloadXt(List<InventoryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"InvXt"); List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "InvXt");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override @Override
public void downloadZz(List<InventoryDto> all, HttpServletResponse response) throws Exception { public void downloadZz(List<InventoryDto> all, HttpServletResponse response) throws Exception {
List<Map<String, Object>> list=ExcelDownUtils.CreateMap(all,"InvZz"); List<Map<String, Object>> list = ExcelDownUtils.CreateMap(all, "InvZz");
FileUtil.downloadExcel(list, response); FileUtil.downloadExcel(list, response);
} }
@Override @Override
public List<Inventory> queryInventoryAllocate(long itemId, long areaId,Long zzkwId) { public List<Inventory> queryInventoryAllocate(long itemId, long areaId, Long zzkwId) {
String hql = " from Inventory inv where 1=1 " + String hql = " from Inventory inv where 1=1 " +
" and inv.itemKey.item.id=" + itemId + " " + " and inv.itemKey.item.id=" + itemId + " " +
" and inv.area.id=" + areaId + " " + " and inv.area.id=" + areaId + " " +
" and inv.quantity-inv.queuedQty>0 "; " and inv.quantity-inv.queuedQty>0 ";
if(zzkwId!=null){ if (zzkwId != null) {
hql+=" and inv.zzkw.id="+zzkwId; hql += " and inv.zzkw.id=" + zzkwId;
hql+="and inv.point.type in ('"+BaseStatus.HCKW+"','"+BaseStatus.ZZKW+"')"; hql += "and inv.point.type in ('" + BaseStatus.HCKW + "','" + BaseStatus.ZZKW + "')";
}else{ } else {
hql+="and inv.point.type='"+BaseStatus.CH+"'"; hql += "and inv.point.type='" + BaseStatus.CH + "'";
} }
hql+= " order by inv.itemKey.propC1 asc "; hql += " order by inv.itemKey.propC1 asc ";
Query query = entityManager.createQuery(hql); Query query = entityManager.createQuery(hql);
List<Inventory> inventoryList = query.getResultList(); List<Inventory> inventoryList = query.getResultList();
return inventoryList; return inventoryList;
} }
public Double getInvQty(long itemId, long areaId,Long zzkwId) { public Double getInvQty(long itemId, long areaId, Long zzkwId) {
String hql = "select sum(inv.quantity-inv.queuedQty) from Inventory inv where 1=1 " + String hql = "select sum(inv.quantity-inv.queuedQty) from Inventory inv where 1=1 " +
" and inv.itemKey.item.id=" + itemId + " " + " and inv.itemKey.item.id=" + itemId + " " +
" and inv.area.id=" + areaId + " " + " and inv.area.id=" + areaId + " " +
" and inv.quantity>0 "; " and inv.quantity>0 ";
if(zzkwId!=null){ if (zzkwId != null) {
hql+=" and inv.zzkw.id="+zzkwId; hql += " and inv.zzkw.id=" + zzkwId;
hql+="and inv.point.type in ('"+BaseStatus.HCKW+"','"+BaseStatus.ZZKW+"')"; hql += "and inv.point.type in ('" + BaseStatus.HCKW + "','" + BaseStatus.ZZKW + "')";
}else{ } else {
hql+="and inv.point.type='"+BaseStatus.CH+"'"; hql += "and inv.point.type='" + BaseStatus.CH + "'";
} }
Query query = entityManager.createQuery(hql); Query query = entityManager.createQuery(hql);
List inventoryList = query.getResultList(); List inventoryList = query.getResultList();
if(inventoryList.size()>0){ if (inventoryList.size() > 0) {
Object obj=inventoryList.get(0); Object obj = inventoryList.get(0);
if(obj==null){ if (obj == null) {
return 0d; return 0d;
}else{ } else {
return (Double)obj; return (Double) obj;
} }
} }
return 0d; return 0d;
@ -195,22 +195,22 @@ public class InventoryServiceImpl implements InventoryService {
public Inventory getInventory(ItemKey itemKey, Area area, Point point, Point zzkw, Dept dept, String type) { public Inventory getInventory(ItemKey itemKey, Area area, Point point, Point zzkw, Dept dept, String type) {
//生成Inventory //生成Inventory
String hql = " from Inventory inv where 1=1 "; String hql = " from Inventory inv where 1=1 ";
if(type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.ZZKW_TL)){ if (type.equals(BizStatus.SL_ALL) || type.equals(BizStatus.ZZKW_TL)) {
if(zzkw==null){ if (zzkw == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "制造库位必填"); throw new BadRequestException(HttpStatus.NOT_FOUND, "制造库位必填");
} }
if(!area.getBexb()){ if (!area.getBexb()) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "接收库区必须为线边仓"); throw new BadRequestException(HttpStatus.NOT_FOUND, "接收库区必须为线边仓");
} }
// if(area.getPoint()==null){ // if(area.getPoint()==null){
if(area.getPointId()==null){ if (area.getPointId() == null) {
throw new BadRequestException(HttpStatus.NOT_FOUND, "接收库区线边库位必填"); throw new BadRequestException(HttpStatus.NOT_FOUND, "接收库区线边库位必填");
} }
} }
if(type.equals(BizStatus.SL_ALL)){ if (type.equals(BizStatus.SL_ALL)) {
//取库区默认 //取库区默认
hql += " and inv.point.id=" + area.getPointId() + " "; hql += " and inv.point.id=" + area.getPointId() + " ";
}else{ } else {
if (point != null) { if (point != null) {
hql += " and inv.point.id=" + point.getId() + " "; hql += " and inv.point.id=" + point.getId() + " ";
} }
@ -222,10 +222,10 @@ public class InventoryServiceImpl implements InventoryService {
if (dept != null) { if (dept != null) {
hql += " and inv.dept.id=" + dept.getId() + " "; hql += " and inv.dept.id=" + dept.getId() + " ";
} }
if(area.getBexb()) { if (area.getBexb()) {
if (zzkw != null) { if (zzkw != null) {
hql += " and inv.zzkw.id=" + zzkw.getId() + " "; hql += " and inv.zzkw.id=" + zzkw.getId() + " ";
}else{ } else {
throw new BadRequestException(HttpStatus.NOT_FOUND, "线边仓制造库位必填"); throw new BadRequestException(HttpStatus.NOT_FOUND, "线边仓制造库位必填");
} }
} }
@ -237,13 +237,13 @@ public class InventoryServiceImpl implements InventoryService {
inventory = inventoryList.get(0); inventory = inventoryList.get(0);
} else { } else {
//创建Inventory //创建Inventory
if (type.equals(BizStatus.ZZKW_TL) ||type.equals(BizStatus.RECEIVING_UP) || type.equals(BizStatus.MOVE)||type.equals(BizStatus.PICK_DOWN)||type.equals(BizStatus.PICK_CANCEL)||type.equals(BizStatus.SL_ALL)||type.equals(BizStatus.MOVE)) { if (type.equals(BizStatus.ZZKW_TL) || type.equals(BizStatus.RECEIVING_UP) || type.equals(BizStatus.MOVE) || type.equals(BizStatus.PICK_DOWN) || type.equals(BizStatus.PICK_CANCEL) || type.equals(BizStatus.SL_ALL) || type.equals(BizStatus.MOVE)) {
inventory = new Inventory(); inventory = new Inventory();
inventory.setItemKey(itemKey); inventory.setItemKey(itemKey);
inventory.setPoint(point); inventory.setPoint(point);
inventory.setPointCode(point.getCode()); inventory.setPointCode(point.getCode());
if(zzkw==null){ if (zzkw == null) {
zzkw=pointService.getPoint("ZZKW",null,null,null); zzkw = pointService.getPoint("ZZKW", null, null, null);
} }
inventory.setZzkw(zzkw); inventory.setZzkw(zzkw);
// inventory.setStock(stock); // inventory.setStock(stock);
@ -258,9 +258,9 @@ public class InventoryServiceImpl implements InventoryService {
@Override @Override
public List<Inventory> getXbHyInv(Item item, Area area, String gw, Point zzkw,String type) { public List<Inventory> getXbHyInv(Item item, Area area, String gw, Point zzkw, String type) {
//生成Inventory //生成Inventory
String hql = " from Inventory inv where 1=1 and inv.point.type not in ('"+BaseStatus.BHZC+"','"+BaseStatus.SHZC+"')"; String hql = " from Inventory inv where 1=1 and inv.point.type not in ('" + BaseStatus.BHZC + "','" + BaseStatus.SHZC + "')";
if (item != null) { if (item != null) {
hql += " and inv.itemKey.item.id=" + item.getId() + " "; hql += " and inv.itemKey.item.id=" + item.getId() + " ";
} }
@ -268,21 +268,21 @@ public class InventoryServiceImpl implements InventoryService {
if (zzkw != null) { if (zzkw != null) {
hql += " and inv.zzkw.id=" + zzkw.getId(); hql += " and inv.zzkw.id=" + zzkw.getId();
} }
if(type.equals("耗用")){//目前只能从暂存库位耗用 if (type.equals("耗用")) {//目前只能从暂存库位耗用
hql += " and inv.point.id=" + area.getPointId(); hql += " and inv.point.id=" + area.getPointId();
} }
hql+=" order by inv.itemKey.propC1 asc"; hql += " order by inv.itemKey.propC1 asc";
Query query = entityManager.createQuery(hql); Query query = entityManager.createQuery(hql);
List<Inventory> inventoryList = query.getResultList(); List<Inventory> inventoryList = query.getResultList();
return inventoryList; return inventoryList;
} }
@Override @Override
public List<Inventory> getInventoryXbTl(Item item, Area area,Point point,Point zzkw) { public List<Inventory> getInventoryXbTl(Item item, Area area, Point point, Point zzkw) {
//生成Inventory //生成Inventory
String hql = " from Inventory inv where 1=1 and inv.point.id ="+point.getId(); String hql = " from Inventory inv where 1=1 and inv.point.id =" + point.getId();
hql += " and inv.itemKey.item.id=" + item.getId() + " "; hql += " and inv.itemKey.item.id=" + item.getId() + " ";
hql += " and inv.area.id="+area.getId(); hql += " and inv.area.id=" + area.getId();
hql += " and inv.zzkw.id=" + zzkw.getId(); hql += " and inv.zzkw.id=" + zzkw.getId();
Query query = entityManager.createQuery(hql); Query query = entityManager.createQuery(hql);
List<Inventory> inventoryList = query.getResultList(); List<Inventory> inventoryList = query.getResultList();
@ -339,10 +339,10 @@ public class InventoryServiceImpl implements InventoryService {
Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE); Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE);
//生成移除的日志 //生成移除的日志
invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber,
null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); null, null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription());
//生成目标点位的日志 //生成目标点位的日志
invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber,
null,null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); null, null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription());
//减库存 //减库存
inventoryOld.setQuantity(rmNum); inventoryOld.setQuantity(rmNum);
this.update(inventoryOld); this.update(inventoryOld);
@ -356,10 +356,10 @@ public class InventoryServiceImpl implements InventoryService {
Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE); Inventory inventory = this.getInventory(inventoryOld.getItemKey(), inventoryOld.getArea(), inventoryYW.getDstPoint(), inventoryOld.getZzkw(), inventoryOld.getDept(), BizStatus.MOVE);
//生成移除的日志 //生成移除的日志
invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.REDUCE, null, inventoryOld.getArea(), inventoryOld.getItemKey(), inventoryOld.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventoryOld.getStock(), inventoryOld.getQuantity(), rmNumber,
null,null,BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); null, null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription());
//生成目标点位的日志 //生成目标点位的日志
invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber, invLogService.storeInventoryLog(BizStatus.MOVE, BizStatus.ADD, null, inventory.getArea(), inventory.getItemKey(), inventory.getPoint(), inventoryYW.getDstPoint(), inventoryOld.getStock(), inventory.getStock(), inventory.getQuantity(), rmNumber,
null,null,BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription()); null, null, BizStatus.MOVE, inventoryOld.getId(), inventoryOld.getId(), inventoryOld.getDescription());
inventoryRepository.delete(inventoryOld); inventoryRepository.delete(inventoryOld);
//加库存 //加库存
inventory.setQuantity(inventory.getQuantity() + rmNumber); inventory.setQuantity(inventory.getQuantity() + rmNumber);
@ -381,38 +381,38 @@ public class InventoryServiceImpl implements InventoryService {
"left join base_item it on it.id=ik.item_id\n" + "left join base_item it on it.id=ik.item_id\n" +
"left join base_point p on p.id=inv.point_id \n" + "left join base_point p on p.id=inv.point_id \n" +
"left join base_area area on area.id=inv.area_id\n" + "left join base_area area on area.id=inv.area_id\n" +
"where 1=1 and area.besh=1 and p.code!='BH_ZC' and inv.quantity!=0 and it.code='"+code+"'\n" + "where 1=1 and area.besh=1 and p.code!='BH_ZC' and inv.quantity!=0 and it.code='" + code + "'\n" +
"order by it.code"; "order by it.code";
List ts= entityManager.createNativeQuery(sql) List ts = entityManager.createNativeQuery(sql)
.unwrap(SQLQuery.class) .unwrap(SQLQuery.class)
.setResultTransformer( .setResultTransformer(
AliasToEntityMapResultTransformer.INSTANCE AliasToEntityMapResultTransformer.INSTANCE
) )
.list(); .list();
List<RInvQuery> list = JSON.parseArray(JSON.toJSONString(ts),RInvQuery.class); List<RInvQuery> list = JSON.parseArray(JSON.toJSONString(ts), RInvQuery.class);
return list; return list;
} }
@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;
} }
} }

View File

@ -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());