领料优化
This commit is contained in:
parent
bcad052493
commit
8043bc0c14
|
|
@ -27,6 +27,9 @@ public class LeaseApplyInfo extends BaseEntity{
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty(value = "是否出库 0 否,1 是")
|
||||
private Integer isOut;
|
||||
|
||||
/** ID */
|
||||
private Long id;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
package com.bonus.common.biz.domain.lease;
|
||||
|
||||
import com.bonus.common.biz.domain.BmFileInfo;
|
||||
import com.bonus.common.core.web.domain.BaseEntity;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 领料出库机具编码集合
|
||||
* @Author ma_sh
|
||||
|
|
@ -19,18 +15,30 @@ public class LeaseMaCodeDto {
|
|||
@ApiModelProperty(value = "主键id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "物资类型")
|
||||
private String materialType;
|
||||
|
||||
@ApiModelProperty(value = "机具名称")
|
||||
@Excel(name = "机具名称")
|
||||
private String materialName;
|
||||
|
||||
@ApiModelProperty(value = "规格型号")
|
||||
@Excel(name = "规格型号")
|
||||
private String materialModel;
|
||||
|
||||
@ApiModelProperty(value = "设备编码")
|
||||
@Excel(name = "设备编码")
|
||||
private String maCode;
|
||||
|
||||
@ApiModelProperty(value = "机具id")
|
||||
private Long maId;
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 机具编码
|
||||
*/
|
||||
@ApiModelProperty(value = "机具编码")
|
||||
private String maCode;
|
||||
|
||||
private String typeId;
|
||||
|
||||
private String maStatus;
|
||||
|
||||
@ApiModelProperty(value = "出库方式 0 编码,1 数量,2 二维码,3 RFID, 4 OCR")
|
||||
private Integer outType;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public class LeaseOutDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "协议id")
|
||||
private Long agreementId;
|
||||
|
||||
@ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)")
|
||||
private Integer isFinished;
|
||||
|
||||
/**
|
||||
* 领料出库机具编码集合
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public enum MaMachineStatusEnum {
|
|||
SCRAP_AUDIT(8, "已报废审核"),
|
||||
BACK_TO_STORE(9, "退料待入库"),
|
||||
SCRAP_TO_AUDIT(10, "报废待审核"),
|
||||
RETURNED_MATERIAL(11, "退料暂存");
|
||||
RETURNED_MATERIAL(11, "领料出库暂存");
|
||||
|
||||
private final Integer status;
|
||||
private final String statusName;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.bonus.material.lease.domain;
|
||||
|
||||
import com.bonus.common.biz.domain.lease.LeaseMaCodeDto;
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -106,6 +107,9 @@ public class LeaseApplyDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "已领数量")
|
||||
private BigDecimal alNum;
|
||||
|
||||
@ApiModelProperty(value = "在用数量")
|
||||
private BigDecimal useNum;
|
||||
|
||||
/**
|
||||
* 此数量是剩余需要出库的数量(preNum - alNum)
|
||||
*/
|
||||
|
|
@ -165,6 +169,11 @@ public class LeaseApplyDetails extends BaseEntity {
|
|||
@ApiModelProperty(value = "租赁工程")
|
||||
private String leaseProject;
|
||||
|
||||
/**
|
||||
* 领料出库机具编码集合
|
||||
*/
|
||||
private List<LeaseMaCodeDto> maCodeList;
|
||||
|
||||
public LeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) {
|
||||
this.id = id;
|
||||
this.parentId = parentId;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.lease.mapper;
|
|||
import java.util.List;
|
||||
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeaseMaCodeDto;
|
||||
import com.bonus.material.back.domain.vo.MaCodeVo;
|
||||
import com.bonus.material.basic.domain.BmQrcodeInfo;
|
||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||
|
|
@ -99,7 +100,7 @@ public interface LeaseApplyDetailsMapper {
|
|||
* @param typeId
|
||||
* @return
|
||||
*/
|
||||
List<MaCodeVo> getCodeList(@Param("id") Long id, @Param("typeId") Long typeId);
|
||||
List<LeaseMaCodeDto> getCodeList(@Param("id") Long id, @Param("typeId") Long typeId);
|
||||
|
||||
/**
|
||||
* 获取领料出库单详情
|
||||
|
|
|
|||
|
|
@ -88,4 +88,11 @@ public interface LeaseOutDetailsMapper {
|
|||
* @return
|
||||
*/
|
||||
int deleteLeaseOutDetails(LeaseOutDetails leaseOutDetails);
|
||||
|
||||
/**
|
||||
* 删除lease_out_details
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
int deleteById(Long[] ids);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||
import com.bonus.common.biz.config.PoiOutPage;
|
||||
import com.bonus.common.biz.constant.MaterialConstants;
|
||||
import com.bonus.common.biz.domain.BmFileInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeaseMaCodeDto;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
||||
import com.bonus.common.biz.enums.MaMachineStatusEnum;
|
||||
|
|
@ -38,7 +39,13 @@ import com.bonus.common.biz.domain.lease.LeaseOutRequestVo;
|
|||
import com.bonus.material.lease.domain.vo.LeaseOutVo;
|
||||
import com.bonus.material.lease.domain.vo.LeaseTotalInfo;
|
||||
import com.bonus.material.lease.mapper.LeaseApplyDetailsMapper;
|
||||
import com.bonus.material.lease.mapper.LeaseOutDetailsMapper;
|
||||
import com.bonus.material.lease.service.ILeaseOutDetailsService;
|
||||
import com.bonus.material.ma.domain.Type;
|
||||
import com.bonus.material.ma.mapper.MachineMapper;
|
||||
import com.bonus.material.ma.mapper.TypeMapper;
|
||||
import com.bonus.material.settlement.domain.SltAgreementInfo;
|
||||
import com.bonus.material.settlement.mapper.SltAgreementInfoMapper;
|
||||
import com.bonus.material.task.domain.TmTask;
|
||||
import com.bonus.material.task.domain.TmTaskAgreement;
|
||||
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
|
||||
|
|
@ -87,6 +94,18 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
@Resource
|
||||
private BmAgreementInfoMapper bmAgreementInfoMapper;
|
||||
|
||||
@Resource
|
||||
private LeaseOutDetailsMapper leaseOutDetailsMapper;
|
||||
|
||||
@Resource
|
||||
private MachineMapper machineMapper;
|
||||
|
||||
@Resource
|
||||
private TypeMapper typeMapper;
|
||||
|
||||
@Resource
|
||||
private SltAgreementInfoMapper sltAgreementInfoMapper;
|
||||
|
||||
/**
|
||||
* 查询领料任务
|
||||
*
|
||||
|
|
@ -117,19 +136,29 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
if (!CollectionUtils.isEmpty(details)) {
|
||||
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
|
||||
for (LeaseApplyDetails detail : details) {
|
||||
// 根据协议id及typeId查询在用量
|
||||
Type type = new Type();
|
||||
type.setAgreementId(info.getAgreementId());
|
||||
type.setTypeId(detail.getTypeId());
|
||||
Type dto = typeMapper.getNumList(type);
|
||||
if (dto != null) {
|
||||
detail.setUseNum(dto.getUseNum());
|
||||
} else {
|
||||
detail.setUseNum(BigDecimal.ZERO);
|
||||
}
|
||||
// 获取编码详情
|
||||
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
List<LeaseMaCodeDto> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
if (!CollectionUtils.isEmpty(maCodeVoList)) {
|
||||
detail.setMaCodeVoList(maCodeVoList);
|
||||
detail.setMaCodeList(maCodeVoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(outDetailsList)) {
|
||||
leaseApplyRequestVo.setLeaseOutDetailsList(outDetailsList);
|
||||
for (LeaseApplyDetails detail : outDetailsList) {
|
||||
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
List<LeaseMaCodeDto> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
if (!CollectionUtils.isEmpty(maCodeVoList)) {
|
||||
detail.setOutMaCodeVoList(maCodeVoList);
|
||||
detail.setMaCodeList(maCodeVoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -214,21 +243,35 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult insertLeaseApplyInfo(LeaseApplyRequestVo leaseApplyRequestVo) {
|
||||
String nickName = SecurityUtils.getLoginUser().getSysUser().getNickName();
|
||||
System.err.println("nickName:" + nickName);
|
||||
if (null == leaseApplyRequestVo.getLeaseApplyInfo()) {
|
||||
return AjaxResult.error("请先填写领料任务信息");
|
||||
}
|
||||
if (CollectionUtil.isEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) {
|
||||
return AjaxResult.error("请先添加领料任务物资明细");
|
||||
}
|
||||
int res = checkStorageNum(leaseApplyRequestVo.getLeaseApplyDetailsList());
|
||||
if (res == 0) {
|
||||
return AjaxResult.error("领料出库数量不能大于库存数量");
|
||||
}
|
||||
leaseApplyRequestVo.getLeaseApplyInfo().setCreateTime(DateUtils.getNowDate());
|
||||
leaseApplyRequestVo.getLeaseApplyInfo().setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
try {
|
||||
int thisMonthMaxOrder = tmTaskMapper.getMonthMaxOrderByDate(DateUtils.getCurrentYear(), DateUtils.getCurrentMonth(), TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId());
|
||||
String taskCode = genderTaskCode(thisMonthMaxOrder);
|
||||
TmTask tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
||||
TmTask tmTask = new TmTask();
|
||||
if (leaseApplyRequestVo.getLeaseApplyInfo().getIsOut() == 1) {
|
||||
tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
||||
LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus(),
|
||||
leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode);
|
||||
} else {
|
||||
tmTask = new TmTask(null, TmTaskTypeEnum.TM_TASK_LEASE.getTaskTypeId(),
|
||||
LeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus(),
|
||||
leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode);
|
||||
}
|
||||
tmTask.setCreateTime(DateUtils.getNowDate());
|
||||
tmTask.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
tmTaskMapper.insertTmTask(tmTask);
|
||||
|
|
@ -265,9 +308,10 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
leaseApplyRequestVo.getLeaseApplyInfo().setLeaseStyle("1");
|
||||
int count = leaseApplyInfoMapper.insertLeaseApplyInfo(leaseApplyRequestVo.getLeaseApplyInfo());
|
||||
if (!CollectionUtils.isEmpty(leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos())) {
|
||||
TmTask finalTmTask = tmTask;
|
||||
leaseApplyRequestVo.getLeaseApplyInfo().getBmFileInfos().forEach(bmFileInfo -> {
|
||||
bmFileInfo.setTaskType(2);
|
||||
bmFileInfo.setTaskId(tmTask.getTaskId());
|
||||
bmFileInfo.setTaskId(finalTmTask.getTaskId());
|
||||
bmFileInfo.setModelId(leaseApplyRequestVo.getLeaseApplyInfo().getId());
|
||||
bmFileInfo.setFileType(5L);
|
||||
bmFileInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
|
|
@ -276,7 +320,7 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
});
|
||||
}
|
||||
if (count > 0) {
|
||||
return insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyRequestVo.getLeaseApplyInfo().getId());
|
||||
return insertPurchaseCheckDetails(tmTask.getTaskId(),leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyRequestVo.getLeaseApplyInfo().getId(), leaseApplyRequestVo.getLeaseApplyInfo().getIsOut());
|
||||
} else {
|
||||
return AjaxResult.error("新增任务失败,lease_apply_info表插入0条");
|
||||
}
|
||||
|
|
@ -287,6 +331,34 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验出库数量是否大于库存数量
|
||||
* @param leaseApplyDetailsList
|
||||
* @return
|
||||
*/
|
||||
private int checkStorageNum(List<LeaseApplyDetails> leaseApplyDetailsList) {
|
||||
for (LeaseApplyDetails leaseApplyDetails : leaseApplyDetailsList) {
|
||||
if (StringUtils.isNull(leaseApplyDetails)) {
|
||||
return 0;
|
||||
}
|
||||
if (leaseApplyDetails.getOutNum() == null) {
|
||||
leaseApplyDetails.setOutNum(BigDecimal.valueOf(0L));
|
||||
}
|
||||
//判断(ma_type 设备规格表)中的库存够不够出库的
|
||||
LeaseOutDetails leaseOutDetails = new LeaseOutDetails();
|
||||
leaseOutDetails.setTypeId(leaseApplyDetails.getTypeId());
|
||||
Type maType = typeMapper.selectByTypeId(leaseOutDetails);
|
||||
if (maType != null) {
|
||||
if ("1".equals(maType.getManageType())) {
|
||||
if (maType.getStorageNum() == null || maType.getStorageNum().compareTo(leaseApplyDetails.getOutNum()) < 0) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理任务
|
||||
* @param leaseApplyRequestVo
|
||||
|
|
@ -483,9 +555,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
|
||||
for (LeaseApplyDetails detail : details) {
|
||||
// 获取编码详情
|
||||
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(dto.getId(), detail.getTypeId());
|
||||
List<LeaseMaCodeDto> maCodeVoList = leaseApplyDetailsMapper.getCodeList(dto.getId(), detail.getTypeId());
|
||||
if (!CollectionUtils.isEmpty(maCodeVoList)) {
|
||||
detail.setMaCodeVoList(maCodeVoList);
|
||||
detail.setMaCodeList(maCodeVoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -732,12 +804,81 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private AjaxResult insertPurchaseCheckDetails(List<LeaseApplyDetails> leaseApplyDetailsList, Long parentId) {
|
||||
private AjaxResult insertPurchaseCheckDetails(Long taskId, List<LeaseApplyDetails> leaseApplyDetailsList, Long parentId, Integer isOut) {
|
||||
if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) {
|
||||
for (LeaseApplyDetails details : leaseApplyDetailsList) {
|
||||
details.setParentId(parentId); // 设置info.parentId
|
||||
details.setCreateTime(DateUtils.getNowDate());
|
||||
details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
LeaseOutDetails record = new LeaseOutDetails();
|
||||
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
record.setIsFinished(isOut == 1 ? 1 : 0);
|
||||
// 领料出库
|
||||
if (isOut == 1) {
|
||||
if (!CollectionUtils.isEmpty(details.getMaCodeList())) {
|
||||
for (LeaseMaCodeDto leaseMaCodeDto : details.getMaCodeList()) {
|
||||
record.setMaId(leaseMaCodeDto.getMaId());
|
||||
record.setOutNum(BigDecimal.valueOf(1));
|
||||
record.setParentId(parentId);
|
||||
record.setOutType(leaseMaCodeDto.getOutType());
|
||||
record.setTypeId(Long.parseLong(leaseMaCodeDto.getTypeId()));
|
||||
int res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
// 更新 (ma_machine 设备表)的状态
|
||||
machineMapper.updateMaMachineStatus(record, MaMachineStatusEnum.IN_USE.getStatus());
|
||||
if (res > 0) {
|
||||
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
||||
res = typeMapper.updateMaTypeStockNum(record);
|
||||
if (res == 0) {
|
||||
return AjaxResult.error("更新ma_type表数据失败");
|
||||
}
|
||||
}
|
||||
res = insSltInfo(taskId, record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
record.setTypeId(details.getTypeId());
|
||||
record.setOutNum(details.getOutNum());
|
||||
record.setParentId(parentId);
|
||||
record.setOutType(1);
|
||||
int res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
if (res > 0) {
|
||||
// 普通机具减少 (ma_type 设备规格表)的库存数量
|
||||
res = typeMapper.updateMaTypeStockNum(record);
|
||||
if (res == 0) {
|
||||
return AjaxResult.error("更新ma_type表数据失败");
|
||||
}
|
||||
}
|
||||
res = insSltInfo(taskId, record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,插入结算记录失败");
|
||||
}
|
||||
}
|
||||
// 出库暂存
|
||||
} else if (isOut == 0) {
|
||||
if (!CollectionUtils.isEmpty(details.getMaCodeList())) {
|
||||
for (LeaseMaCodeDto leaseMaCodeDto : details.getMaCodeList()) {
|
||||
record.setMaId(leaseMaCodeDto.getMaId());
|
||||
record.setOutNum(BigDecimal.valueOf(1));
|
||||
record.setParentId(parentId);
|
||||
record.setOutType(leaseMaCodeDto.getOutType());
|
||||
record.setTypeId(Long.parseLong(leaseMaCodeDto.getTypeId()));
|
||||
int res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
// 更新 (ma_machine 设备表)的状态
|
||||
machineMapper.updateMaMachineStatus(record, MaMachineStatusEnum.RETURNED_MATERIAL.getStatus());
|
||||
}
|
||||
} else {
|
||||
record.setTypeId(details.getTypeId());
|
||||
record.setOutNum(details.getOutNum());
|
||||
record.setParentId(parentId);
|
||||
record.setOutType(1);
|
||||
int res = leaseOutDetailsMapper.insertLeaseOutDetails(record);
|
||||
if (res == 0) {
|
||||
return AjaxResult.error("插入lease_out_details表数据失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 批量插入详情数据
|
||||
int count = leaseApplyDetailsMapper.insertLeaseApplyDetailsList(leaseApplyDetailsList);
|
||||
|
|
@ -751,6 +892,30 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入结算记录
|
||||
* @param taskId
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
private int insSltInfo(Long taskId, LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
SltAgreementInfo sltAgreementInfo = sltAgreementInfoMapper.getSltAgreementInfo(record);
|
||||
if (sltAgreementInfo != null) {
|
||||
BigDecimal num = sltAgreementInfo.getNum();
|
||||
BigDecimal outNum = record.getOutNum();
|
||||
sltAgreementInfo.setNum(num.add(outNum));
|
||||
res = sltAgreementInfoMapper.updSltInfo(sltAgreementInfo);
|
||||
record.setAgreementId(sltAgreementInfo.getAgreementId());
|
||||
} else {
|
||||
String agreementId = tmTaskAgreementMapper.getAgreementId(taskId.toString());
|
||||
Type maType = typeMapper.getMaType(record.getTypeId());
|
||||
maType.setFinalPrice(maType.getLeasePrice());
|
||||
res = sltAgreementInfoMapper.insSltInfo(record, agreementId, maType);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成任务编号并构造Tm_Task任务对象
|
||||
* @param thisMonthMaxOrder 当月最大单号
|
||||
|
|
@ -808,12 +973,26 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(leaseApplyRequestVo.getLeaseApplyDetailsList())) {
|
||||
// 业务逻辑代码
|
||||
// 业务逻辑代码,删除lease_apply_details
|
||||
leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids);
|
||||
insertPurchaseCheckDetails(leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyInfo.getId());
|
||||
// 业务逻辑代码,删除lease_out_details
|
||||
leaseOutDetailsMapper.deleteById(ids);
|
||||
for (LeaseApplyDetails leaseApplyDetails : leaseApplyRequestVo.getLeaseApplyDetailsList()) {
|
||||
if (!CollectionUtils.isEmpty(leaseApplyDetails.getMaCodeList())) {
|
||||
for (LeaseMaCodeDto leaseMaCodeDto : leaseApplyDetails.getMaCodeList()) {
|
||||
// 根据maId将设备改为在库状态
|
||||
machineMapper.updateStatus(leaseMaCodeDto.getMaId(), MaMachineStatusEnum.IN_STORE.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
insertPurchaseCheckDetails(leaseApplyInfo.getTaskId(), leaseApplyRequestVo.getLeaseApplyDetailsList(), leaseApplyInfo.getId(), leaseApplyRequestVo.getLeaseApplyInfo().getIsOut());
|
||||
}
|
||||
// 修改外层info
|
||||
leaseApplyInfoMapper.updateLeaseApplyInfo(leaseApplyInfo);
|
||||
// 根据任务id修改任务状态
|
||||
if (leaseApplyRequestVo.getLeaseApplyInfo().getIsOut() == 1) {
|
||||
tmTaskMapper.updateTaskStatus(leaseApplyInfo.getTaskId().toString(), LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -917,7 +1096,9 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService {
|
|||
int result = leaseApplyInfoMapper.deleteLeaseApplyInfoByIds(ids);
|
||||
if (result > 0) {
|
||||
// 删除lease_apply_details表数据
|
||||
result = leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids);
|
||||
result += leaseApplyDetailsMapper.deleteLeaseApplyDetailsByParentIds(ids);
|
||||
// 业务逻辑代码,删除lease_out_details
|
||||
result += leaseOutDetailsMapper.deleteById(ids);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,8 +169,6 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
public AjaxResult leaseOut(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
try {
|
||||
// 1、判断库存是否足够
|
||||
//boolean isEnough = checkStorageIsEnough(record);
|
||||
// 针对于app进行判断,出库新增时判断此设备是否已经领料申请过
|
||||
if (record.getIsNew() != null && record.getIsNew() == 0){
|
||||
// 根据typeId去lease_apply_details表查询设备是否存在
|
||||
|
|
@ -221,11 +219,6 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,修改任务状态失败");
|
||||
}
|
||||
/*// 修改任务为待提交状态
|
||||
res = updateTaskStatus(record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("出库失败,修改任务状态失败");
|
||||
}*/
|
||||
// 5、插入结算记录
|
||||
String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId());
|
||||
record.setTaskId(taskId);
|
||||
|
|
@ -437,12 +430,6 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
|||
|
||||
private int insertRecords(LeaseOutDetails record) {
|
||||
int res = 0;
|
||||
/*// 首先更新领料任务详情表的领料数及状态(lease_apply_details)
|
||||
res = leaseApplyDetailsMapper.updateLeaseApplyDetailsOutNum(record);
|
||||
LeaseApplyDetails leaseApplyDetails = leaseApplyDetailsMapper.getLeaseApplyDetails(record);
|
||||
if (leaseApplyDetails.getPreNum().equals(leaseApplyDetails.getAlNum()) || leaseApplyDetails.getAuditNum().equals(leaseApplyDetails.getAlNum())) {
|
||||
leaseApplyDetailsMapper.updateLeaseApplyDetailsByLeaseOutRecord(record);
|
||||
}*/
|
||||
// 插入领料出库明细表(lease_out_details)
|
||||
record.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
|
||||
if (!CollectionUtils.isEmpty(record.getMaCodeList())) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.bonus.common.biz.constant.MaterialConstants;
|
|||
import com.bonus.common.biz.domain.BmFileInfo;
|
||||
import com.bonus.common.biz.domain.LeaseRecordInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||
import com.bonus.common.biz.domain.lease.LeaseMaCodeDto;
|
||||
import com.bonus.common.biz.domain.lease.LeasePublishInfo;
|
||||
import com.bonus.common.biz.enums.HttpCodeEnum;
|
||||
import com.bonus.common.biz.enums.LeaseTaskStatusEnum;
|
||||
|
|
@ -264,9 +265,9 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService {
|
|||
leaseApplyRequestVo.setLeaseApplyDetailsList(details);
|
||||
for (LeaseApplyDetails detail : details) {
|
||||
// 获取编码详情
|
||||
List<MaCodeVo> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
List<LeaseMaCodeDto> maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId());
|
||||
if (!CollectionUtils.isEmpty(maCodeVoList)) {
|
||||
detail.setMaCodeVoList(maCodeVoList);
|
||||
detail.setMaCodeList(maCodeVoList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -453,6 +453,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
|
||||
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
|
||||
WHERE lod.is_finished = '1'
|
||||
GROUP BY mt.type_id) AS subquery1
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
|
|
|
|||
|
|
@ -283,25 +283,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getCodeList" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
||||
SELECT
|
||||
mt.type_id as typeId,
|
||||
mt1.type_name as materialName,
|
||||
mt.type_name as typeName,
|
||||
mm.ma_id as maId,
|
||||
mm.ma_code as maCode
|
||||
FROM
|
||||
lease_out_details lod
|
||||
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
WHERE
|
||||
lod.parent_id = #{id}
|
||||
and mt.type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
<select id="selectLeaseOutDetailsList" resultType="com.bonus.material.lease.domain.vo.LeaseOutVo">
|
||||
SELECT
|
||||
mt1.type_name AS typeName,
|
||||
|
|
@ -757,4 +738,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
lod.type_id
|
||||
</select>
|
||||
|
||||
<select id="getCodeList" resultType="com.bonus.common.biz.domain.lease.LeaseMaCodeDto">
|
||||
SELECT
|
||||
mt.type_id as typeId,
|
||||
mt1.type_name as materialName,
|
||||
mt.type_name as materialModel,
|
||||
mm.ma_id as maId,
|
||||
mm.ma_code as maCode,
|
||||
sd.dict_label as maStatus
|
||||
FROM
|
||||
lease_out_details lod
|
||||
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
||||
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
||||
AND mt.del_flag = '0'
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
||||
AND mt1.del_flag = '0'
|
||||
LEFT JOIN sys_dict_data sd ON mm.ma_status = sd.dict_value
|
||||
and sd.dict_type = 'ma_machine_status'
|
||||
WHERE
|
||||
lod.parent_id = #{id}
|
||||
and mt.type_id = #{typeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<result property="agreementCode" column="agreement_code" />
|
||||
<result property="leaseSignUrl" column="lease_sign_url" />
|
||||
<result property="leaseSignType" column="lease_sign_type" />
|
||||
<result property="agreementId" column="agreement_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectLeaseApplyInfoVo">
|
||||
|
|
@ -53,10 +54,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
IFNULL(sum(lad.al_num),0) as alNum,
|
||||
GROUP_CONCAT(DISTINCT mt1.type_name) as maTypeNames,
|
||||
bp.contract_part as contractPart,
|
||||
sd.dept_name as impUnitName
|
||||
sd.dept_name as impUnitName,
|
||||
tta.agreement_id
|
||||
from
|
||||
lease_apply_info lai
|
||||
left join tm_task tt on lai.task_id = tt.task_id
|
||||
left join tm_task_agreement tta ON tt.task_id = tta.task_id
|
||||
left join lease_apply_details lad on lai.id = lad.parent_id
|
||||
left join bm_project bp on bp.pro_id = lai.pro_id
|
||||
left join bm_team bt on bt.id = lai.team_id
|
||||
|
|
@ -379,7 +382,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN bm_team bt on lai.team_id = bt.id
|
||||
LEFT JOIN bm_project bp ON lai.pro_id = bp.pro_id
|
||||
WHERE
|
||||
1=1
|
||||
lad.is_finished = '1'
|
||||
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
||||
<![CDATA[and DATE_FORMAT( lai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
||||
</if>
|
||||
|
|
@ -439,7 +442,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
FROM lease_apply_info lai
|
||||
LEFT JOIN lease_out_details lod ON lai.id = lod.parent_id
|
||||
WHERE
|
||||
1 = 1
|
||||
lod.is_finished = '1'
|
||||
<if test="leaseStyle != null and leaseStyle != '' ">
|
||||
AND lai.lease_style = #{leaseStyle}
|
||||
</if>
|
||||
|
|
|
|||
|
|
@ -110,6 +110,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="publishTask != null and publishTask != ''">
|
||||
publish_task,
|
||||
</if>
|
||||
<if test="isFinished!= null">
|
||||
is_finished,
|
||||
</if>
|
||||
create_time,
|
||||
update_time
|
||||
</trim>
|
||||
|
|
@ -147,6 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="publishTask != null and publishTask != ''">
|
||||
#{publishTask},
|
||||
</if>
|
||||
<if test="isFinished!= null">
|
||||
#{isFinished},
|
||||
</if>
|
||||
NOW(),
|
||||
NOW()
|
||||
</trim>
|
||||
|
|
@ -192,4 +198,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</if>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteById">
|
||||
delete from lease_out_details where parent_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue