diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java index 69ff2f51..a354f695 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseApplyInfo.java @@ -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; diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseMaCodeDto.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseMaCodeDto.java index 7a0baacc..65bd3709 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseMaCodeDto.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseMaCodeDto.java @@ -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; } diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java index 8642a4c3..8953ce73 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/domain/lease/LeaseOutDetails.java @@ -114,6 +114,9 @@ public class LeaseOutDetails extends BaseEntity { @ApiModelProperty(value = "协议id") private Long agreementId; + @ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)") + private Integer isFinished; + /** * 领料出库机具编码集合 */ diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/MaMachineStatusEnum.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/MaMachineStatusEnum.java index 7e77f4e4..eb102a27 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/MaMachineStatusEnum.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/enums/MaMachineStatusEnum.java @@ -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; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java index 9976f843..222bfebb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/domain/LeaseApplyDetails.java @@ -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 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; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java index da56384b..da27c69f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseApplyDetailsMapper.java @@ -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 getCodeList(@Param("id") Long id, @Param("typeId") Long typeId); + List getCodeList(@Param("id") Long id, @Param("typeId") Long typeId); /** * 获取领料出库单详情 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java index 865a1096..92dffd96 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/mapper/LeaseOutDetailsMapper.java @@ -88,4 +88,11 @@ public interface LeaseOutDetailsMapper { * @return */ int deleteLeaseOutDetails(LeaseOutDetails leaseOutDetails); + + /** + * 删除lease_out_details + * @param ids + * @return + */ + int deleteById(Long[] ids); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index f32c78ec..133842d9 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -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 maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId()); + List 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 maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId()); + List 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(), - LeaseTaskStatusEnum.LEASE_TASK_TO_PUBLISHED.getStatus(), - leaseApplyRequestVo.getLeaseApplyInfo().getCompanyId(),thisMonthMaxOrder + 1, taskCode); + 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 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 maCodeVoList = leaseApplyDetailsMapper.getCodeList(dto.getId(), detail.getTypeId()); + List maCodeVoList = leaseApplyDetailsMapper.getCodeList(dto.getId(), detail.getTypeId()); if (!CollectionUtils.isEmpty(maCodeVoList)) { - detail.setMaCodeVoList(maCodeVoList); + detail.setMaCodeList(maCodeVoList); } } } @@ -732,23 +804,116 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { * @param parentId * @return */ - private AjaxResult insertPurchaseCheckDetails(List leaseApplyDetailsList, Long parentId) { - if (!CollectionUtils.isEmpty(leaseApplyDetailsList)) { - for (LeaseApplyDetails details : leaseApplyDetailsList) { - details.setParentId(parentId); // 设置info.parentId - details.setCreateTime(DateUtils.getNowDate()); - details.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName()); - } - // 批量插入详情数据 - int count = leaseApplyDetailsMapper.insertLeaseApplyDetailsList(leaseApplyDetailsList); - if (count > 0) { - return AjaxResult.success("新增任务成功", parentId); + private AjaxResult insertPurchaseCheckDetails(Long taskId, List 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); + if (count > 0) { + return AjaxResult.success("新增任务成功", parentId); + } else { + return AjaxResult.error("新增任务失败,lease_apply_detail详情表插入0条"); + } } else { - return AjaxResult.error("新增任务失败,lease_apply_detail详情表插入0条"); + return AjaxResult.success("新增任务成功", parentId); } + } + + /** + * 插入结算记录 + * @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 { - return AjaxResult.success("新增任务成功", parentId); + String agreementId = tmTaskAgreementMapper.getAgreementId(taskId.toString()); + Type maType = typeMapper.getMaType(record.getTypeId()); + maType.setFinalPrice(maType.getLeasePrice()); + res = sltAgreementInfoMapper.insSltInfo(record, agreementId, maType); } + return res; } /** @@ -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; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java index ce93048e..09dc09b7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseOutDetailsServiceImpl.java @@ -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())) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java index fb5fbddc..a68e0293 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -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 maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId()); + List maCodeVoList = leaseApplyDetailsMapper.getCodeList(id, detail.getTypeId()); if (!CollectionUtils.isEmpty(maCodeVoList)) { - detail.setMaCodeVoList(maCodeVoList); + detail.setMaCodeList(maCodeVoList); } } } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml index f4615d26..da35e49b 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/basic/ComplexQueryMapper.xml @@ -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 diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml index 58b0fe8e..e1c14594 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyDetailsMapper.xml @@ -283,25 +283,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - - + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml index 6fbe2f80..760bb88a 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseApplyInfoMapper.xml @@ -36,6 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -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' @@ -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' AND lai.lease_style = #{leaseStyle} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml index e9460dbc..33c647b8 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/lease/LeaseOutDetailsMapper.xml @@ -110,6 +110,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" publish_task, + + is_finished, + create_time, update_time @@ -147,6 +150,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{publishTask}, + + #{isFinished}, + NOW(), NOW() @@ -192,4 +198,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + delete from lease_out_details where parent_id in + + #{id} + + + \ No newline at end of file