领料接口优化
This commit is contained in:
parent
97d555617b
commit
308f17789a
|
|
@ -5,7 +5,8 @@ import lombok.Getter;
|
|||
@Getter
|
||||
public enum MaTypeManageTypeEnum {
|
||||
CODE_DEVICE(0, "编码设备"),
|
||||
NUMBER_DEVICE(1, "数量设备"),;
|
||||
NUMBER_DEVICE(1, "数量设备"),
|
||||
SET_DEVICE(2, "成套设备");
|
||||
|
||||
private final Integer typeId;
|
||||
private final String typeName;
|
||||
|
|
|
|||
|
|
@ -135,10 +135,10 @@ public class LeaseApplyInfoController extends BaseController {
|
|||
@PreventRepeatSubmit
|
||||
//@RequiresPermissions("lease:info:add")
|
||||
@SysLog(title = "领料出库", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->领料出库")
|
||||
@PostMapping("/submitOut")
|
||||
public AjaxResult submitOut(@NotNull(message = "领料出库信息不能为空") @RequestBody LeaseOutRequestVo leaseOutRequestVo) {
|
||||
@PostMapping("/leaseOut")
|
||||
public AjaxResult leaseOut(@NotNull(message = "领料出库信息不能为空") @RequestBody LeaseOutRequestVo leaseOutRequestVo) {
|
||||
try {
|
||||
return leaseApplyInfoService.submitOut(leaseOutRequestVo);
|
||||
return leaseApplyInfoService.leaseOut(leaseOutRequestVo);
|
||||
} catch (Exception e) {
|
||||
return error("系统错误, " + e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public interface ILeaseApplyInfoService {
|
|||
* @param leaseOutRequestVo 领料:出库
|
||||
* @return 结果
|
||||
*/
|
||||
AjaxResult submitOut(LeaseOutRequestVo leaseOutRequestVo);
|
||||
AjaxResult leaseOut(LeaseOutRequestVo leaseOutRequestVo);
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -60,5 +60,6 @@ public interface ILeaseOutDetailsService {
|
|||
*/
|
||||
int deleteLeaseOutDetailsById(Long id);
|
||||
|
||||
public AjaxResult submitOut(LeaseOutDetails record);
|
||||
public AjaxResult leaseOut(LeaseOutDetails record);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,9 +247,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult submitOut(LeaseOutRequestVo leaseOutRequestVo) {
|
||||
public AjaxResult leaseOut(LeaseOutRequestVo leaseOutRequestVo) {
|
||||
for (LeaseOutDetails bean : leaseOutRequestVo.getLeaseOutDetailsList()) {
|
||||
AjaxResult ajaxResult = leaseOutDetailsService.submitOut(bean);
|
||||
AjaxResult ajaxResult = leaseOutDetailsService.leaseOut(bean);
|
||||
if (ajaxResult.isError()) {
|
||||
return ajaxResult;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
package com.bonus.material.lease.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.utils.HttpHelper;
|
||||
import com.bonus.common.biz.enums.MaTypeManageTypeEnum;
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.utils.DateUtils;
|
||||
import com.bonus.common.core.utils.StringUtils;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.material.ma.domain.Machine;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
|
|
@ -73,7 +69,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
@Override
|
||||
public AjaxResult insertLeaseOutDetails(List<LeaseOutDetails> leaseOutDetailsList) {
|
||||
for (LeaseOutDetails bean : leaseOutDetailsList) {
|
||||
AjaxResult ajaxResult = submitOut(bean);
|
||||
AjaxResult ajaxResult = leaseOut(bean);
|
||||
if (ajaxResult.isError()) {
|
||||
return ajaxResult;
|
||||
}
|
||||
|
|
@ -127,18 +123,19 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult submitOut(LeaseOutDetails record) {
|
||||
public AjaxResult leaseOut(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
try {
|
||||
// 1、判断是否重复提交
|
||||
res = checkRepeatSubmit(record);
|
||||
// 1、判断库存是否足够
|
||||
boolean isEnough = checkStorageIsEnough(record);
|
||||
//record.setPreStoreNum(getStorageNum(record));
|
||||
if (res > 0) {
|
||||
if ((record.getManageType() == 1 || record.getManageType() == 2) && record.getInputNum() != null) {
|
||||
if (isEnough) {
|
||||
if ((record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId() ||
|
||||
record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) && record.getInputNum() != null) {
|
||||
record.setOutNum(record.getInputNum());
|
||||
}
|
||||
//2、判断成套机具出库库存是否足够
|
||||
if (record.getManageType() == 2) {
|
||||
if (record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) {
|
||||
res = checkStorageNumCt(record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,库存不足");
|
||||
|
|
@ -177,29 +174,23 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
return AjaxResult.success("出库成功");
|
||||
}
|
||||
|
||||
private int checkRepeatSubmit(LeaseOutDetails record) {
|
||||
String maStatus = "15";
|
||||
int res = 0;
|
||||
if (record.getManageType() == 1 || record.getManageType() == 2) {
|
||||
// 如果是数量出库校验待出库数量
|
||||
// 判断库存是否足够
|
||||
private boolean checkStorageIsEnough(LeaseOutDetails record) {
|
||||
String maStatus = "1";
|
||||
if (record.getManageType() == MaTypeManageTypeEnum.NUMBER_DEVICE.getTypeId() || record.getManageType() == MaTypeManageTypeEnum.SET_DEVICE.getTypeId()) {
|
||||
LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record);
|
||||
if (details == null) {
|
||||
return res;
|
||||
} else {
|
||||
res = 1;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// 如果是编码出库判断是否在库
|
||||
} else if (record.getManageType() == MaTypeManageTypeEnum.CODE_DEVICE.getTypeId()) {
|
||||
if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) {
|
||||
String status = leaseOutDetailsMapper.getMachineStatus(record);
|
||||
if (!maStatus.equals(status)) {
|
||||
return res;
|
||||
} else {
|
||||
res = 1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
return true;
|
||||
}
|
||||
|
||||
private int checkStorageNumCt(LeaseOutDetails record) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue