WMS:api接口申请领料支持agv仓库
master
xins 8 months ago
parent 7de8f4c03c
commit 552138b94b

@ -157,6 +157,7 @@ public class WmsRawOutstockDetail extends BaseEntity {
private String auditStatus;
private String palletInfoCode;
public void setRawOutstockDetailId(Long rawOutstockDetailId) {
this.rawOutstockDetailId = rawOutstockDetailId;
}
@ -381,6 +382,14 @@ public class WmsRawOutstockDetail extends BaseEntity {
this.auditStatus = auditStatus;
}
public String getPalletInfoCode() {
return palletInfoCode;
}
public void setPalletInfoCode(String palletInfoCode) {
this.palletInfoCode = palletInfoCode;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -45,6 +45,9 @@ public class WmsRawStock extends BaseEntity
@Excel(name = "入库批次号")
private String instockBatch;
/**托盘码*/
private String palletInfoCode;
/** 入库时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入库时间", width = 30, dateFormat = "yyyy-MM-dd")
@ -156,6 +159,15 @@ public class WmsRawStock extends BaseEntity
{
return instockBatch;
}
public String getPalletInfoCode() {
return palletInfoCode;
}
public void setPalletInfoCode(String palletInfoCode) {
this.palletInfoCode = palletInfoCode;
}
public void setInstockDate(Date instockDate)
{
this.instockDate = instockDate;

@ -95,4 +95,11 @@ public interface WmsRawOutstockMapper
public List<WmsRawOutstock> selectWmsRawOutstockJoinList(WmsRawOutstock wmsRawOutstock);
/**
*
*
* @param wmsRawOutstockList
* @return
*/
public int batchWmsRawOutstock(List<WmsRawOutstock> wmsRawOutstockList);
}

@ -422,7 +422,6 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//判断仓库类型,出库记录保存对应操作类型,出库记录明细保存对应出库方式
WmsBaseWarehouse warehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
String warehouseType = warehouse.getWarehouseType();
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
String outstockWay = WmsConstants.OUTSTOCK_WAY_MAP.get(warehouseType);
String queryQualityStatus = WmsConstants.WMS_QUALITY_STATUS_PASS;
@ -430,8 +429,10 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
List<WmsRawOutstockDetail> toUpdatedRawOutstockDetails = new ArrayList<>();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
//传入的申请领料list遍历
rawOutstockDetails.forEach(rawOutstockDetail -> {
BigDecimal planAmount = rawOutstockDetail.getPlanAmount() == null ? BigDecimal.ZERO : rawOutstockDetail.getPlanAmount();
BigDecimal planAmount = rawOutstockDetail.getPlanAmount() == null ?
BigDecimal.ZERO : rawOutstockDetail.getPlanAmount();//申请数量
Long materialId = rawOutstockDetail.getMaterialId();
if (planAmount.compareTo(BigDecimal.ZERO) > 0) {
BigDecimal realRawStock = BigDecimal.ZERO;//实际库存总量
@ -459,12 +460,12 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawStock.setUpdateDate(currentDate);
wmsRawStock.setUpdateBy(userName);
//如果同一个物料有多条记录的处理(最好避免前端可以传多条同一个物料的申请),
// 提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
//提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
//原材料出库记录明细(有break以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
planAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = planAmount.subtract(availableAmount);
@ -476,10 +477,11 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
//原材料出库记录明细(有break以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
availableAmount, currentDate, userName, outstockWay);
planAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
} else if (planAmount.compareTo(availableAmount) < 0) {
@ -490,10 +492,11 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
//如果同一个物料有多条记录的处理,提前更新(主要是更新数量等信息,避免在下一次判断中还使用上次的数量),放在事务中
wmsRawStockMapper.updateWmsRawStock(wmsRawStock);
//原材料出库记录明细
//原材料出库记录明细(有break以下方法需要写在下面)
WmsRawOutstockDetail wmsRawOutstockDetail = getWmsRawOutstockDetail(wmsRawStock, materialId,
planAmount, currentDate, userName, outstockWay);
toUpdatedRawOutstockDetails.add(wmsRawOutstockDetail);
planAmount = BigDecimal.ZERO;
break;
}
@ -501,37 +504,16 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
}
//以上将申请的数量跟库存数量比对如果库存数量足够则planAmount减去库存会=0,如果不够则剩余的planAmount会>0
if (planAmount.compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException("物料编号为[" + materialId + "]库存不足,只有" + realRawStock);
throw new ServiceException("物料名称为[" + rawOutstockDetail.getMaterialName() + "]库存不足,只有" + realRawStock);
}
}
});
handleRawOutstock(wmsRawOutstock,warehouse,userName,currentDate,toUpdatedRawOutstockDetails);
//出库要求 0申请出库1申请审核出库2直接出库
String outRequirement = warehouse.getOutRequirement();
String auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
if (outRequirement.equals(WmsConstants.WMS_WAREHOUSE_OUT_REQUIREMENT_APPLY_AUDIT)) {
wmsRawOutstock.setAuditStatus(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
} else {
wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
}
wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode));
wmsRawOutstock.setStationId(SecurityUtils.getStationId());
wmsRawOutstock.setOperationType(operationType);
wmsRawOutstock.setApplyBy(userName);
wmsRawOutstock.setApplyDate(currentDate);
int rows = wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock);
wmsRawOutstock.setWmsRawOutstockDetailList(toUpdatedRawOutstockDetails);
insertWmsRawOutstockDetail(wmsRawOutstock);
return rows;
return 1;
}
@ -555,6 +537,7 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wmsRawOutstockDetail.setPlanAmount(availableAmount);
wmsRawOutstockDetail.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
wmsRawOutstockDetail.setOutstockWay(outstockWay);
wmsRawOutstockDetail.setPalletInfoCode(wmsRawStock.getPalletInfoCode());
wmsRawOutstockDetail.setQualityStatus(wmsRawStock.getQualityStatus());
wmsRawOutstockDetail.setCreateDate(currentDate);
wmsRawOutstockDetail.setCreateBy(userName);
@ -563,6 +546,59 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
}
public void handleRawOutstock(WmsRawOutstock wmsRawOutstock, WmsBaseWarehouse warehouse,
String userName, Date currentDate,List<WmsRawOutstockDetail> toUpdatedRawOutstockDetails) {
//出库要求 0申请出库1申请审核出库2直接出库
String outRequirement = warehouse.getOutRequirement();
String warehouseType = warehouse.getWarehouseType();
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {
if (outRequirement.equals(WmsConstants.WMS_WAREHOUSE_OUT_REQUIREMENT_APPLY_AUDIT)) {
wmsRawOutstock.setAuditStatus(WmsConstants.RAW_OUTSTOCK_AUDIT_STATUS_TOAUDIT);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
} else {
wmsRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
wmsRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
}
wmsRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode));
wmsRawOutstock.setStationId(SecurityUtils.getStationId());
wmsRawOutstock.setOperationType(operationType);
wmsRawOutstock.setApplyBy(userName);
wmsRawOutstock.setApplyDate(currentDate);
wmsRawOutstockMapper.insertWmsRawOutstock(wmsRawOutstock);
wmsRawOutstock.setWmsRawOutstockDetailList(toUpdatedRawOutstockDetails);
insertWmsRawOutstockDetail(wmsRawOutstock);
} else {
List<WmsRawOutstock> toInsertedRawOutstocks = new ArrayList<>();
toUpdatedRawOutstockDetails.forEach(wmsRawOutstockDetail -> {
WmsRawOutstock toInsertedRawOutstock = new WmsRawOutstock();
toInsertedRawOutstock.setTaskCode(Seq.getId(Seq.rawOutstockSeqType, Seq.rawOutstockSeqCode));
toInsertedRawOutstock.setWarehouseId(wmsRawOutstock.getWarehouseId());
toInsertedRawOutstock.setLocationCode(wmsRawOutstockDetail.getLocationCode());
toInsertedRawOutstock.setStationId(SecurityUtils.getStationId());
toInsertedRawOutstock.setPalletInfoCode(wmsRawOutstockDetail.getPalletInfoCode());
toInsertedRawOutstock.setOperationType(operationType);
toInsertedRawOutstock.setApplyBy(userName);
toInsertedRawOutstock.setApplyDate(currentDate);
toInsertedRawOutstock.setEndStationCode(SecurityUtils.getStationCode());
toInsertedRawOutstock.setPlanCode(wmsRawOutstock.getPlanCode());
toInsertedRawOutstock.setPlanDetailCode(wmsRawOutstock.getPlanDetailCode());
toInsertedRawOutstock.setMaterialBatch(wmsRawOutstockDetail.getInstockBatch());
toInsertedRawOutstock.setOutstockAmount(wmsRawOutstockDetail.getPlanAmount());
toInsertedRawOutstock.setTaskType(WmsConstants.WMS_RAW_OUTSTOCK_TASK_TYPE_PRODUCTION_PICKING);
toInsertedRawOutstock.setAuditStatus(WmsConstants.WMS_AUDIT_STATUS_PASS);
toInsertedRawOutstock.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
toInsertedRawOutstocks.add(toInsertedRawOutstock);
});
wmsRawOutstockMapper.batchWmsRawOutstock(toInsertedRawOutstocks);
}
}
/**
* AGV
*

@ -237,4 +237,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="batchWmsRawOutstock">
insert into wms_raw_outstock(raw_outstock_id, task_code,warehouse_id,location_code,order_id,plan_code,plan_detail_code,station_id,product_id,material_batch,pallet_info_code,outstock_amount,end_station_code,operation_type,task_type,audit_status,execute_status,apply_by,apply_date) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.rawOutstockId}, #{item.taskCode}, #{item.warehouseId}, #{item.locationCode}, #{item.orderId}, #{item.planCode}, #{item.planDetailCode}, #{item.stationId}, #{item.productId}, #{item.materialBatch}, #{item.palletInfoCode}, #{item.outstockAmount}, #{item.endStationCode}, #{item.operationType}, #{item.taskType}, #{item.auditStatus}, #{item.executeStatus}, #{item.applyBy}, #{item.applyDate})
</foreach>
</insert>
</mapper>

@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="stockType" column="stock_type" />
<result property="materialId" column="material_id" />
<result property="instockBatch" column="instock_batch" />
<result property="palletInfoCode" column="pallet_info_code" />
<result property="instockDate" column="instock_date" />
<result property="lastOutstockTime" column="last_outstock_time" />
<result property="qualityStatus" column="quality_status" />
@ -28,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectWmsRawStockVo">
select raw_stock_id, warehouse_id, location_code, stock_type, material_id, instock_batch, instock_date, last_outstock_time, quality_status, complete_flag,total_amount, frozen_amount, occupy_amount, supplier_id, create_by, create_date, update_by, update_date, active_flag from wms_raw_stock
select raw_stock_id, warehouse_id, location_code, stock_type, material_id, instock_batch,pallet_info_code, instock_date, last_outstock_time, quality_status, complete_flag,total_amount, frozen_amount, occupy_amount, supplier_id, create_by, create_date, update_by, update_date, active_flag from wms_raw_stock
</sql>
<select id="selectWmsRawStockList" parameterType="WmsRawStock" resultMap="WmsRawStockResult">

Loading…
Cancel
Save