领料接口优化

This commit is contained in:
sxu 2024-11-12 14:39:02 +08:00
parent 156b6f07a9
commit 663a871b56
6 changed files with 129 additions and 12 deletions

View File

@ -1,6 +1,8 @@
package com.bonus.material.basic.domain; package com.bonus.material.basic.domain;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel; import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@ -119,4 +121,7 @@ public class BmAgreementInfo extends BaseEntity
@ApiModelProperty(value = "关键词") @ApiModelProperty(value = "关键词")
private String keyWord; private String keyWord;
@ApiModelProperty(value = "附件列表")
private List<BmFileInfo> bmFileInfos;
} }

View File

@ -3,11 +3,13 @@ package com.bonus.material.basic.service.impl;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import com.bonus.common.biz.constant.MaterialConstants; import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.security.utils.SecurityUtils; import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.basic.mapper.BmFileInfoMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
@ -15,6 +17,8 @@ import com.bonus.material.basic.domain.BmAgreementInfo;
import com.bonus.material.basic.service.IBmAgreementInfoService; import com.bonus.material.basic.service.IBmAgreementInfoService;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
/** /**
* 协议管理Service业务层处理 * 协议管理Service业务层处理
* *
@ -27,6 +31,9 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService
@Autowired @Autowired
private BmAgreementInfoMapper bmAgreementInfoMapper; private BmAgreementInfoMapper bmAgreementInfoMapper;
@Resource
private BmFileInfoMapper bmFileInfoMapper;
/** /**
* 查询协议管理 * 查询协议管理
* *
@ -68,7 +75,21 @@ public class BmAgreementInfoServiceImpl implements IBmAgreementInfoService
bmAgreementInfo.setCreateTime(DateUtils.getNowDate()); bmAgreementInfo.setCreateTime(DateUtils.getNowDate());
bmAgreementInfo.setCreateBy(SecurityUtils.getUsername()); bmAgreementInfo.setCreateBy(SecurityUtils.getUsername());
bmAgreementInfo.setAgreementCode(getAgreementCode()); bmAgreementInfo.setAgreementCode(getAgreementCode());
return AjaxResult.success(bmAgreementInfoMapper.insertBmAgreementInfo(bmAgreementInfo)); int count = bmAgreementInfoMapper.insertBmAgreementInfo(bmAgreementInfo);
if (count > 0) {
if (CollectionUtils.isEmpty(bmAgreementInfo.getBmFileInfos())) {
return AjaxResult.success("新增任务成功,无营业执照附件");
}
AtomicBoolean addFileInfoResult = new AtomicBoolean(false);
bmAgreementInfo.getBmFileInfos().forEach(bmFileInfo -> {
bmFileInfo.setModelId(bmAgreementInfo.getAgreementId());
bmFileInfo.setCreateTime(DateUtils.getNowDate());
addFileInfoResult.set(bmFileInfoMapper.insertBmFileInfo(bmFileInfo) > 0);
});
return addFileInfoResult.get() ? AjaxResult.success("新增任务成功") : AjaxResult.error("新增任务失败,附件表插入0条");
} else {
return AjaxResult.error("新建任务失败,插入0条");
}
} catch (Exception e) { } catch (Exception e) {
throw new ServiceException("错误信息描述"); throw new ServiceException("错误信息描述");
} }

View File

@ -81,9 +81,9 @@ public class LeaseOutDetailsController extends BaseController {
@RequiresPermissions("lease:details:add") @RequiresPermissions("lease:details:add")
@SysLog(title = "领料出库详细", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增领料出库详细") @SysLog(title = "领料出库详细", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增领料出库详细")
@PostMapping @PostMapping
public AjaxResult add(@RequestBody LeaseOutDetails leaseOutDetails) { public AjaxResult add(@RequestBody List<LeaseOutDetails> leaseOutDetailsList) {
try { try {
return toAjax(leaseOutDetailsService.insertLeaseOutDetails(leaseOutDetails)); return leaseOutDetailsService.insertLeaseOutDetails(leaseOutDetailsList);
} catch (Exception e) { } catch (Exception e) {
return error("系统错误, " + e.getMessage()); return error("系统错误, " + e.getMessage());
} }

View File

@ -62,5 +62,7 @@ public class LeaseOutDetails extends BaseEntity {
@ApiModelProperty(value = "是否推送到智慧工程01:是") @ApiModelProperty(value = "是否推送到智慧工程01:是")
private Long pushNotifications; private Long pushNotifications;
@ApiModelProperty(value = "出库类型 0编码出库 1数量出库 2成套出库")
private Integer manageType;
} }

View File

@ -1,6 +1,8 @@
package com.bonus.material.lease.service; package com.bonus.material.lease.service;
import java.util.List; import java.util.List;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.material.lease.domain.LeaseOutDetails; import com.bonus.material.lease.domain.LeaseOutDetails;
/** /**
@ -29,10 +31,10 @@ public interface ILeaseOutDetailsService {
/** /**
* 新增领料出库详细 * 新增领料出库详细
* *
* @param leaseOutDetails 领料出库详细 * @param leaseOutDetailsList 领料出库详细
* @return 结果 * @return 结果
*/ */
public int insertLeaseOutDetails(LeaseOutDetails leaseOutDetails); public AjaxResult insertLeaseOutDetails(List<LeaseOutDetails> leaseOutDetailsList);
/** /**
* 修改领料出库详细 * 修改领料出库详细

View File

@ -3,11 +3,13 @@ package com.bonus.material.lease.service.impl;
import java.util.List; import java.util.List;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.DateUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bonus.material.lease.mapper.LeaseOutDetailsMapper; import com.bonus.material.lease.mapper.LeaseOutDetailsMapper;
import com.bonus.material.lease.domain.LeaseOutDetails; import com.bonus.material.lease.domain.LeaseOutDetails;
import com.bonus.material.lease.service.ILeaseOutDetailsService; import com.bonus.material.lease.service.ILeaseOutDetailsService;
import org.springframework.transaction.annotation.Transactional;
/** /**
* 领料出库详细Service业务层处理 * 领料出库详细Service业务层处理
@ -45,17 +47,19 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
/** /**
* 新增领料出库详细 * 新增领料出库详细
* *
* @param leaseOutDetails 领料出库详细 * @param leaseOutDetailsList 领料出库详细
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertLeaseOutDetails(LeaseOutDetails leaseOutDetails) { public AjaxResult insertLeaseOutDetails(List<LeaseOutDetails> leaseOutDetailsList) {
leaseOutDetails.setCreateTime(DateUtils.getNowDate()); for (LeaseOutDetails bean : leaseOutDetailsList) {
try { // AjaxResult ajaxResult = submitOut(bean);
return leaseOutDetailsMapper.insertLeaseOutDetails(leaseOutDetails); // if (ajaxResult.isError()) {
} catch (Exception e) { // return ajaxResult;
throw new ServiceException("错误信息描述"); // }
leaseOutDetailsMapper.insertLeaseOutDetails(bean);
} }
return AjaxResult.success();
} }
/** /**
@ -95,4 +99,87 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
public int deleteLeaseOutDetailsById(Long id) { public int deleteLeaseOutDetailsById(Long id) {
return leaseOutDetailsMapper.deleteLeaseOutDetailsById(id); return leaseOutDetailsMapper.deleteLeaseOutDetailsById(id);
} }
/**
* 领料出库处理
*
* @param record 出库对象
* @return 结果
*/
//@Override
// @Transactional(rollbackFor = Exception.class)
// public AjaxResult submitOut(LeaseOutDetails record) {
// int res = 0;
// try {
// // 1判断是否重复提交
// res = checkRepeatSubmit(record);
// //record.setPreStoreNum(getStorageNum(record));
// if (res > 0) {
// if ((record.getManageType() == 1 || record.getManageType() == 2) && record.getInputNum() != null) {
// record.setOutNum(record.getInputNum());
// }
// //2判断成套机具出库库存是否足够
// if (record.getManageType() == 2) {
// res = checkStorageNumCt(record);
// if (res == 0) {
// throw new RuntimeException("出库失败,库存不足");
// }
// } else {
// res = checkStorageNum(record);
// }
//
// if (res > 0) {
// // 3插入出库记录修改库存修改机具状态
// res = insertRecords(record);
// if (res == 0) {
// throw new RuntimeException("出库失败,更新设备规格库存数量时出错!");
// }
// // 4修改任务状态tm_task
// res = updateTaskStatus(record);
// if (res == 0) {
// throw new RuntimeException("出库失败,修改任务状态失败");
// }
// // 5插入结算记录
// String taskId = leaseOutDetailsMapper.getTaskId(record.getParentId());
// res = insSltInfo(taskId, record);
// if (res == 0) {
// throw new RuntimeException("出库失败,插入结算记录失败");
// }
// record.setPostStoreNum(getStorageNum(record));
// } else {
// return AjaxResult.error("领料出库失败,机具库存不足");
// }
// } else {
// return AjaxResult.error("已领数量大于预领数量或该机具未在库");
// }
// } catch (Exception e) {
// return AjaxResult.error("出库失败");
// }
// return AjaxResult.success("出库成功");
// }
//
// private int checkRepeatSubmit(LeaseOutDetails record) {
// String maStatus = "15";
// int res = 0;
// if (record.getManageType() == 1 || record.getManageType() == 2) {
// // 如果是数量出库校验待出库数量
// LeaseApplyDetails details = leaseOutDetailsMapper.getOutboundNum(record);
// if (details == null) {
// return res;
// } else {
// res = 1;
// }
// } else {
// // 如果是编码出库判断是否在库
// if (!(Objects.equals(0, record.getMaId()) || record.getMaId() == null)) {
// String status = leaseOutDetailsMapper.getMachineStatus(record);
// if (!maStatus.equals(status)) {
// return res;
// } else {
// res = 1;
// }
// }
// }
// return res;
// }
} }