领料库存变化数量
This commit is contained in:
parent
f4e4bd379c
commit
2437d23fb5
|
|
@ -72,4 +72,16 @@ public class LeaseOutDetails extends BaseEntity {
|
|||
|
||||
@ApiModelProperty(value = "0工程1长期")
|
||||
private String leaseType;
|
||||
|
||||
/** 操作前库存 */
|
||||
private BigDecimal preStoreNum;
|
||||
|
||||
/** 操作后库存 */
|
||||
private BigDecimal postStoreNum;
|
||||
|
||||
/** 类型名称 */
|
||||
private String typeName;
|
||||
|
||||
/** 规格型号 */
|
||||
private String typeModelName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.lease.mapper;
|
|||
import java.util.List;
|
||||
|
||||
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
|
||||
/**
|
||||
* 领料出库详细Mapper接口
|
||||
|
|
@ -67,4 +68,17 @@ public interface LeaseOutDetailsMapper {
|
|||
*/
|
||||
public int deleteLeaseOutDetailsByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询实时库存
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
int getCountOfCodeMachine(LeaseOutDetails record);
|
||||
|
||||
/**
|
||||
* 根据类型id查询类型
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
Type selectByTypeId(LeaseOutDetails record);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
try {
|
||||
// 1、判断库存是否足够
|
||||
boolean isEnough = checkStorageIsEnough(record);
|
||||
//record.setPreStoreNum(getStorageNum(record));
|
||||
record.setPreStoreNum(getStorageNum(record));
|
||||
if (isEnough) {
|
||||
if ((record.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) && record.getInputNum() != null) {
|
||||
record.setOutNum(record.getInputNum());
|
||||
|
|
@ -180,7 +180,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
//record.setPostStoreNum(getStorageNum(record));
|
||||
record.setPostStoreNum(getStorageNum(record));
|
||||
} else {
|
||||
return AjaxResult.error("领料出库失败,机具库存不足");
|
||||
}
|
||||
|
|
@ -194,6 +194,27 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
return AjaxResult.success("出库成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询操作前后库存
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
private BigDecimal getStorageNum(LeaseOutDetails record) {
|
||||
if (StringUtils.isNull(record)) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
//判断(ma_type 设备规格表)中的库存够不够出库的
|
||||
Type maType = leaseOutDetailsMapper.selectByTypeId(record);
|
||||
if (maType != null) {
|
||||
if ("1".equals(maType.getManageType())) {
|
||||
return maType.getStorageNum();
|
||||
} else {
|
||||
return BigDecimal.valueOf(leaseOutDetailsMapper.getCountOfCodeMachine(record));
|
||||
}
|
||||
}
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
|
||||
// 判断库存是否足够
|
||||
private boolean checkStorageIsEnough(LeaseOutDetails record) {
|
||||
if (record.getManageType().equals(MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId())) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getCountOfCodeMachine" resultType="java.lang.Integer">
|
||||
select count(mm.ma_id)
|
||||
FROM ma_type mt
|
||||
left join ma_machine mm on mm.type_id=mt.type_id
|
||||
WHERE
|
||||
mm.type_id = #{typeId}
|
||||
and mm.ma_code is not null
|
||||
and mm.ma_status in (1)
|
||||
and mt.`level` = 4
|
||||
and mt.del_flag = '0'
|
||||
</select>
|
||||
|
||||
<select id="selectByTypeId" resultType="com.bonus.material.ma.domain.Type">
|
||||
select type_id as typeId,
|
||||
manage_type as manageType,
|
||||
storage_num as storageNum
|
||||
from ma_type
|
||||
where type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<insert id="insertLeaseOutDetails" parameterType="com.bonus.common.biz.domain.lease.LeaseOutDetails" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into lease_out_details
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
|
|
|
|||
Loading…
Reference in New Issue