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 56253512..6747aa2e 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 @@ -152,6 +152,12 @@ public class LeaseApplyDetails extends BaseEntity { @ApiModelProperty(value = "发布批次") private String publishTask; + @ApiModelProperty(value = "领料单位") + private String leaseUnit; + + @ApiModelProperty(value = "租赁工程") + private String leaseProject; + 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 2691fae9..8c874868 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 @@ -142,4 +142,17 @@ public interface LeaseApplyDetailsMapper { */ List getDetailsPublish(@Param("keyWord") String keyWord, @Param("publishTask") String publishTask); + /** + * 根据领料任务id查询领料任务详细 + * @param leaseApplyDetails + * @return + */ + LeaseApplyDetails selectInfo(LeaseApplyDetails leaseApplyDetails); + + /** + * 根据领用任务批次查询领用任务详细 + * @param leaseApplyDetails + * @return + */ + List selectPublishDetails(LeaseApplyDetails leaseApplyDetails); } 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 02bda9d5..5ce6f25e 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 @@ -88,7 +88,21 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { leaseApplyInfo.setUserId(userId); Optional optionalInfo = Optional.ofNullable(leaseApplyInfoMapper.selectLeaseApplyInfoById(leaseApplyInfo)); LeaseApplyRequestVo leaseApplyRequestVo = new LeaseApplyRequestVo(); - + // 查询领用出库数据 + if (StringUtils.isNotBlank(publishTask)) { + List leaseApplyOutList = leaseApplyInfoMapper.selectPublishList(leaseApplyInfo); + if (!CollectionUtils.isEmpty(leaseApplyOutList)) { + LeaseApplyInfo applyInfo = leaseApplyOutList.get(0); + if (applyInfo.getPreCountNum().compareTo(applyInfo.getAlNum()) == 0) { + applyInfo.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus()); + applyInfo.setTaskStatusName(LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatusName()); + } else { + applyInfo.setTaskStatus(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatus()); + applyInfo.setTaskStatusName(LeaseTaskStatusEnum.LEASE_TASK_IN_PROGRESS.getStatusName()); + } + optionalInfo = Optional.of(leaseApplyOutList.get(0)); + } + } optionalInfo.ifPresent(info -> { BmFileInfo bmFileInfo = new BmFileInfo(); bmFileInfo.setModelId(id); @@ -113,7 +127,26 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { leaseApplyRequestVo.setLeaseApplyInfo(info); // 获取领料单详情 List details = leaseApplyDetailsMapper.selectLeaseApplyDetailsList(new LeaseApplyDetails(info.getId(), keyword, userId)); + // 走单独的领用详情查询 + if (StringUtils.isNotBlank(publishTask)) { + // 根据领用批次查询领用详情 + details = leaseApplyDetailsMapper.getDetailsPublish(keyword, publishTask); + if (!CollectionUtils.isEmpty(details)) { + for (LeaseApplyDetails detail : details) { + if (detail.getPreNum().compareTo(detail.getAlNum()) == 0) { + detail.setStatus("2"); + } else { + detail.setStatus("1"); + } + } + } + } if (!CollectionUtils.isEmpty(details)) { + /*if (StringUtils.isNotBlank(keyword)) { + details = details.stream() + .filter(item -> containsDetailsKeyword(item, keyword)) + .collect(Collectors.toList()); + }*/ leaseApplyRequestVo.setLeaseApplyDetailsList(details); for (LeaseApplyDetails detail : details) { // 获取编码详情 @@ -125,23 +158,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } }); - // 走单独的领用详情查询 - if (StringUtils.isNotBlank(publishTask)) { - LeaseApplyRequestVo info = new LeaseApplyRequestVo(); - // 根据领用批次查询领用详情 - List details = leaseApplyDetailsMapper.getDetailsPublish(keyword,publishTask); - if (!CollectionUtils.isEmpty(details)) { - for (LeaseApplyDetails detail : details) { - if (detail.getOutNum().compareTo(detail.getAlNum()) == 0) { - detail.setStatus("2"); - } else { - detail.setStatus("1"); - } - } - info.setLeaseApplyDetailsList(details); - } - return info; - } return leaseApplyRequestVo; } catch (Exception e) { @@ -151,7 +167,6 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { } } - /** * 查询领料任务列表 * @@ -741,7 +756,12 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { */ @Override public LeaseApplyDetails getInnerById(LeaseApplyDetails leaseApplyDetails) { - return leaseApplyDetailsMapper.getInnerById(leaseApplyDetails); + LeaseApplyDetails info = leaseApplyDetailsMapper.getInnerById(leaseApplyDetails); + // 根据领用批次查询领用详情 + if (StringUtils.isNotBlank(leaseApplyDetails.getPublishTask())) { + info = leaseApplyDetailsMapper.selectInfo(leaseApplyDetails); + } + return info; } /** @@ -751,7 +771,11 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { */ @Override public List getDetailsById(LeaseApplyDetails leaseApplyDetails) { - return leaseApplyDetailsMapper.getDetailsById(leaseApplyDetails); + List list = leaseApplyDetailsMapper.getDetailsById(leaseApplyDetails); + if (StringUtils.isNotBlank(leaseApplyDetails.getPublishTask())) { + list = leaseApplyDetailsMapper.selectPublishDetails(leaseApplyDetails); + } + return list; } /** 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 0390062e..5e931173 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 @@ -163,7 +163,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { @Transactional(rollbackFor = Exception.class) public AjaxResult leaseOut(LeaseOutDetails record) { int res = 0; - try { + /*try {*/ // 1、判断库存是否足够 boolean isEnough = checkStorageIsEnough(record); record.setPreStoreNum(getStorageNum(record)); @@ -209,10 +209,10 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { } else { return AjaxResult.error("已领数量大于预领数量或该机具未在库"); } - } catch (Exception e) { + /*} catch (Exception e) { log.error(e.getMessage()); return AjaxResult.error("出库失败"); - } + }*/ return AjaxResult.success("出库成功"); } @@ -364,7 +364,11 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService { String taskId = leaseApplyInfoMapper.getTaskId(record.getParentId()); // 领用任务状态改为已完成 res = tmTaskMapper.updateTaskStatus(taskId, LeaseTaskStatusEnum.LEASE_TASK_FINISHED.getStatus()); + if (res == 0) { + throw new RuntimeException("领用任务状态修改失败"); + } } + res = 1; return res; } // 进行状态判断 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 96ab0492..71e36e15 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 @@ -719,7 +719,7 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { boolean allMatch = true; if (!CollectionUtils.isEmpty(leaseApplyDetails)) { for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { - if (leaseApplyDetail.getPreNum().compareTo(leaseApplyDetail.getPublishNum()) <= 0) { + if (leaseApplyDetail.getPreNum().compareTo(leaseApplyDetail.getPublishNum()) > 0) { allMatch = false; break; } 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 892de484..b83a5014 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 @@ -277,7 +277,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.del_flag = '0' LEFT JOIN tm_task tt ON bs.task_id = tt.task_id - WHERE bs.in_num != 0 + WHERE bs.in_num != 0 and and bs.result_msg = '操作成功' and ( CASE @@ -320,7 +320,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN bs.out_type = '1' THEN '数量' WHEN bs.out_type = '2' THEN '二维码' WHEN bs.out_type = '3' THEN '标准箱' - ELSE '未知入库方式' + ELSE '未知出库方式' END AS outStyle, mt3.type_id as firstTypeId, mt2.type_id as secondTypeId @@ -339,7 +339,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id AND mt3.del_flag = '0' LEFT JOIN tm_task tt ON bs.task_id = tt.task_id - WHERE bs.out_num != 0 + WHERE bs.out_num != 0 and bs.result_msg = '操作成功' and bui.unit_id = #{unitId} @@ -353,7 +353,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHEN bs.out_type = '1' THEN '数量' WHEN bs.out_type = '2' THEN '二维码' WHEN bs.out_type = '3' THEN '标准箱' - ELSE '未知入库方式' + ELSE '未知出库方式' END = #{outStyle} ) @@ -633,7 +633,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN tm_task tt ON bs.task_id = tt.task_id LEFT JOIN ma_type_keeper mtk ON mtk.type_id = bs.type_id LEFT JOIN sys_user su ON mtk.user_id = su.user_id - WHERE bs.in_num != 0 + WHERE bs.in_num != 0 and bs.result_msg = '操作成功' AND bs.type_id = #{typeId} 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 762391c3..eba36149 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 @@ -414,32 +414,124 @@ 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 6ee649a4..844893be 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 @@ -264,14 +264,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bp.pro_name AS leaseProject, bai.agreement_code AS agreementCode, IFNULL( sum( lpd.num ), 0 ) AS preCountNum, - IFNULL( sum( lod.out_num ), 0 ) AS alNum, - GROUP_CONCAT( mt1.type_name ) AS maTypeNames, + IFNULL(lod.num, 0) AS alNum, + GROUP_CONCAT( DISTINCT mt1.type_name ) AS maTypeNames, lpd.publish_task AS publishTask FROM lease_publish_details lpd LEFT JOIN lease_apply_info lai ON lai.id = lpd.parent_id LEFT JOIN tm_task tt ON lai.task_id = tt.task_id - LEFT JOIN lease_out_details lod ON lpd.parent_id = lod.parent_id + LEFT JOIN (SELECT IFNULL( sum(out_num ), 0) AS num, parent_id, publish_task from lease_out_details + GROUP BY parent_id, publish_task) lod ON lpd.parent_id = lod.parent_id AND lpd.publish_task = lod.publish_task LEFT JOIN bm_unit bu ON bu.unit_id = lpd.unit_id LEFT JOIN bm_project bp ON bp.pro_id = lpd.project_id @@ -282,10 +283,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND mt1.del_flag = '0' LEFT JOIN bm_agreement_info bai ON lpd.unit_id = bai.unit_id AND lpd.project_id = bai.project_id + + JOIN ma_type_keeper mtk ON mtk.type_id = lpd.type_id AND mtk.user_id = #{userId} + where 1 = 1 + + AND lai.id = #{id} + + + AND lpd.publish_task = #{publishTask} + GROUP BY lpd.publish_task ORDER BY diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskAgreementMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskAgreementMapper.xml index 1357a930..58cb2a56 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskAgreementMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/task/TmTaskAgreementMapper.xml @@ -106,7 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"