refactor(bonus-material): 优化退料申请和租赁相关功能- 增加单位类型判断逻辑,针对班组类型添加特殊处理
- 改进协议 ID 查询逻辑,支持通过不同方式获取协议信息 - 优化 SQL 查询语句,提高数据查询效率 - 重构部分代码结构,提升可读性和可维护性
This commit is contained in:
parent
e72f810b2a
commit
9f602eb078
|
|
@ -114,6 +114,9 @@ public class LeaseOutDetails extends BaseEntity {
|
||||||
@ApiModelProperty(value = "项目部协议id")
|
@ApiModelProperty(value = "项目部协议id")
|
||||||
private Long projectUnitAgreementId;
|
private Long projectUnitAgreementId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "项目部单位id")
|
||||||
|
private Long projectUnitId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)")
|
@ApiModelProperty(value = "是否完成 (0:未完成 1:已完成)")
|
||||||
private Integer isFinished;
|
private Integer isFinished;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.bonus.material.basic.domain.BmAgreementInfo;
|
||||||
import com.bonus.material.basic.domain.BmUnit;
|
import com.bonus.material.basic.domain.BmUnit;
|
||||||
import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
import com.bonus.material.basic.mapper.BmAgreementInfoMapper;
|
||||||
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||||
|
import com.bonus.material.basic.mapper.BmUnitMapper;
|
||||||
import com.bonus.material.clz.domain.back.MaterialBackApplyDetails;
|
import com.bonus.material.clz.domain.back.MaterialBackApplyDetails;
|
||||||
import com.bonus.material.clz.domain.back.MaterialBackApplyInfo;
|
import com.bonus.material.clz.domain.back.MaterialBackApplyInfo;
|
||||||
import com.bonus.material.clz.mapper.MaterialBackInfoMapper;
|
import com.bonus.material.clz.mapper.MaterialBackInfoMapper;
|
||||||
|
|
@ -45,6 +46,7 @@ import com.bonus.material.back.service.IBackApplyInfoService;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 退料任务Service业务层处理
|
* 退料任务Service业务层处理
|
||||||
|
|
@ -89,6 +91,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
@Resource
|
@Resource
|
||||||
private BmAgreementInfoMapper bmAgreementInfoMapper;
|
private BmAgreementInfoMapper bmAgreementInfoMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BmUnitMapper bmUnitMapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询退料任务 - 性能优化版
|
* 查询退料任务 - 性能优化版
|
||||||
*
|
*
|
||||||
|
|
@ -923,7 +928,30 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult submitBackApply(BackApplyInfo backApplyInfo) {
|
public AjaxResult submitBackApply(@NotNull(message = "参数不能为空") BackApplyInfo backApplyInfo) {
|
||||||
|
if (backApplyInfo.getUnitId() == null || backApplyInfo.getProId() == null) {
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "参数不能为空");
|
||||||
|
}
|
||||||
|
BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(backApplyInfo.getUnitId());
|
||||||
|
if (queryUnitInfo.getTypeId() == null) {
|
||||||
|
throw new ServiceException("单位类型为空");
|
||||||
|
}
|
||||||
|
// 如果单位类型为班组,则查询该班在机具签署✍️的协议ID
|
||||||
|
LeaseOutDetails leaseOutDetail = new LeaseOutDetails();
|
||||||
|
if (queryUnitInfo.getTypeId() == 1731L) {
|
||||||
|
// 查询班组挂靠的项目部协议信息
|
||||||
|
leaseOutDetail = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(
|
||||||
|
Math.toIntExact(backApplyInfo.getUnitId()),
|
||||||
|
Math.toIntExact(backApplyInfo.getProId())
|
||||||
|
);
|
||||||
|
if (leaseOutDetail == null) {
|
||||||
|
throw new ServiceException("项目部协议信息查询为空");
|
||||||
|
}
|
||||||
|
// 把后续流程设置为项目部的协议进行处理
|
||||||
|
backApplyInfo.setAgreementId(leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
backApplyInfo.setUnitId(leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
}
|
||||||
|
|
||||||
List<BackApplyInfo> codeList = new ArrayList<>();
|
List<BackApplyInfo> codeList = new ArrayList<>();
|
||||||
// 根据传入的id查询退料申请信息
|
// 根据传入的id查询退料申请信息
|
||||||
List<BackApplyInfo> applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
List<BackApplyInfo> applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
||||||
|
|
@ -958,6 +986,14 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
Long agreementId = backApplyInfoMapper.selectAgreementId(backApplyInfo);
|
Long agreementId = backApplyInfoMapper.selectAgreementId(backApplyInfo);
|
||||||
// 先查第四层类型
|
// 先查第四层类型
|
||||||
backApplyInfo.setAgreementId(agreementId);
|
backApplyInfo.setAgreementId(agreementId);
|
||||||
|
// 如果单位类型为班组,则查询该班在机具签署✍️的协议ID
|
||||||
|
if (queryUnitInfo.getTypeId() == 1731L) {
|
||||||
|
// 把后续流程设置为项目部的协议进行处理
|
||||||
|
if (leaseOutDetail.getProjectUnitAgreementId() != null) {
|
||||||
|
backApplyInfo.setAgreementId(leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
backApplyInfo.setUnitId(leaseOutDetail.getProjectUnitAgreementId());
|
||||||
|
}
|
||||||
|
}
|
||||||
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
List<TypeTreeNode> listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
||||||
if (CollectionUtils.isNotEmpty(applyDetails)) {
|
if (CollectionUtils.isNotEmpty(applyDetails)) {
|
||||||
for (BackApplyDetails applyDetail : applyDetails) {
|
for (BackApplyDetails applyDetail : applyDetails) {
|
||||||
|
|
@ -2201,9 +2237,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
||||||
// 查询是否存在班组数据
|
// 查询是否存在班组数据
|
||||||
List<SltAgreementInfo> tbList = backApplyInfoMapper.getTbList(bean);
|
List<SltAgreementInfo> tbList = backApplyInfoMapper.getTbList(bean);
|
||||||
|
if (CollectionUtils.isEmpty(infoList)) {
|
||||||
|
// 退料单位的协议ID如果查不到,就通过别的协议查(例如班组的协议查不到,可能是项目部去领用的)
|
||||||
|
if (!Objects.equals(record.getAgreementId(), bean.getAgreementId())) {
|
||||||
|
infoList = backApplyInfoMapper.getStlInfo(bean.setAgreementId(record.getAgreementId()));
|
||||||
if (CollectionUtils.isEmpty(infoList)) {
|
if (CollectionUtils.isEmpty(infoList)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
BigDecimal backNum = bean.getBackNum();
|
BigDecimal backNum = bean.getBackNum();
|
||||||
// 遍历每个typeId
|
// 遍历每个typeId
|
||||||
for (SltAgreementInfo info : infoList) {
|
for (SltAgreementInfo info : infoList) {
|
||||||
|
|
|
||||||
|
|
@ -263,6 +263,8 @@ public interface SelectMapper {
|
||||||
*/
|
*/
|
||||||
List<AgreementVo> getAgreementInfoByIdBack(SelectDto dto);
|
List<AgreementVo> getAgreementInfoByIdBack(SelectDto dto);
|
||||||
|
|
||||||
|
List<AgreementVo> getMaterialAgreementInfoByIdBack(SelectDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取无需授权的项目部和后勤单位
|
* 获取无需授权的项目部和后勤单位
|
||||||
* @param bmUnit
|
* @param bmUnit
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,15 @@ package com.bonus.material.common.service.impl;
|
||||||
import com.alibaba.nacos.common.utils.StringUtils;
|
import com.alibaba.nacos.common.utils.StringUtils;
|
||||||
import com.bonus.common.biz.config.DateTimeHelper;
|
import com.bonus.common.biz.config.DateTimeHelper;
|
||||||
import com.bonus.common.biz.domain.*;
|
import com.bonus.common.biz.domain.*;
|
||||||
|
import com.bonus.common.core.exception.ServiceException;
|
||||||
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.back.domain.BackApplyInfo;
|
import com.bonus.material.back.domain.BackApplyInfo;
|
||||||
import com.bonus.material.basic.domain.BmProject;
|
import com.bonus.material.basic.domain.BmProject;
|
||||||
import com.bonus.material.basic.domain.BmUnit;
|
import com.bonus.material.basic.domain.BmUnit;
|
||||||
|
import com.bonus.material.basic.mapper.BmUnitMapper;
|
||||||
|
import com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo;
|
||||||
|
import com.bonus.material.clz.service.MaterialLeaseInfoService;
|
||||||
import com.bonus.material.common.domain.dto.SelectDto;
|
import com.bonus.material.common.domain.dto.SelectDto;
|
||||||
import com.bonus.material.common.domain.vo.AgreementVo;
|
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||||
import com.bonus.material.common.domain.vo.SelectVo;
|
import com.bonus.material.common.domain.vo.SelectVo;
|
||||||
|
|
@ -18,6 +22,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
@ -32,6 +37,12 @@ public class SelectServiceImpl implements SelectService {
|
||||||
@Resource(name = "SelectMapper")
|
@Resource(name = "SelectMapper")
|
||||||
private SelectMapper mapper;
|
private SelectMapper mapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BmUnitMapper bmUnitMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MaterialLeaseInfoService materialLeaseInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 单位下拉类型树
|
* 单位下拉类型树
|
||||||
* @param bmUnit
|
* @param bmUnit
|
||||||
|
|
@ -264,7 +275,7 @@ public class SelectServiceImpl implements SelectService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getUnitListLease(BmUnit bmUnit) {
|
public AjaxResult getUnitListLease(@NotNull(message = "参数不能为空") BmUnit bmUnit) {
|
||||||
// 获取登陆用户的组织ID
|
// 获取登陆用户的组织ID
|
||||||
Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||||
if (null == thisLoginUserDeptId || 0 == thisLoginUserDeptId) {
|
if (null == thisLoginUserDeptId || 0 == thisLoginUserDeptId) {
|
||||||
|
|
@ -509,12 +520,28 @@ public class SelectServiceImpl implements SelectService {
|
||||||
try {
|
try {
|
||||||
// 判断单位是否为班组,如果为班组的话,把材料站的领用数据也查询出来
|
// 判断单位是否为班组,如果为班组的话,把材料站的领用数据也查询出来
|
||||||
if (bean.getUnitId() != null && bean.getProId() != null) {
|
if (bean.getUnitId() != null && bean.getProId() != null) {
|
||||||
|
BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(bean.getUnitId());
|
||||||
|
if (queryUnitInfo.getTypeId() == null) {
|
||||||
|
throw new ServiceException("单位类型为空");
|
||||||
|
}
|
||||||
|
// 如果单位类型为班组,则查询该班在机具签署✍️的协议ID
|
||||||
|
if (queryUnitInfo.getTypeId() == 1731L) {
|
||||||
|
// List<AgreementVo> agreementInfos = mapper.getMaterialAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(queryUnitInfo.getUnitId())));
|
||||||
|
// if (CollectionUtils.isNotEmpty(agreementInfos)) {
|
||||||
|
// bean.setClzAgreementId(Long.valueOf(agreementInfos.get(0).getAgreementId()));
|
||||||
|
// } else {
|
||||||
|
// throw new ServiceException("该班组没有在机具签署✍️的协议");
|
||||||
|
// }
|
||||||
List<AgreementVo> clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId())));
|
List<AgreementVo> clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId())));
|
||||||
// 如果在材料站该单位有签署协议,说明该单位是班组
|
// 如果在材料站该单位有签署协议
|
||||||
if (CollectionUtils.isNotEmpty(clzAgreementInfos)) {
|
if (CollectionUtils.isNotEmpty(clzAgreementInfos)) {
|
||||||
bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId()));
|
bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId()));
|
||||||
|
} else {
|
||||||
|
throw new ServiceException("该班组没有在机具签署✍️的协议");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// 先查第四层类型
|
// 先查第四层类型
|
||||||
listL4 = mapper.getUseTypeTreeL4(bean);
|
listL4 = mapper.getUseTypeTreeL4(bean);
|
||||||
if (CollectionUtils.isNotEmpty(listL4)) {
|
if (CollectionUtils.isNotEmpty(listL4)) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.bonus.material.lease.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseConfirmSign;
|
import com.bonus.common.biz.domain.lease.LeaseConfirmSign;
|
||||||
|
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutSign;
|
import com.bonus.common.biz.domain.lease.LeaseOutSign;
|
||||||
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
import com.bonus.material.lease.domain.LeaseApplyDetails;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
@ -99,7 +100,7 @@ public interface LeaseApplyInfoMapper {
|
||||||
* @param projectId 工程id
|
* @param projectId 工程id
|
||||||
* @return 挂靠的项目部协议id
|
* @return 挂靠的项目部协议id
|
||||||
*/
|
*/
|
||||||
Long selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId);
|
LeaseOutDetails selectProjectUnitAgreementIdByTeamAndProject(@Param("teamId") Integer teamId, @Param("projectId") Integer projectId);
|
||||||
|
|
||||||
String getTaskId(Long parentId);
|
String getTaskId(Long parentId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,7 @@ public class LeaseOutDetailsServiceImpl implements ILeaseOutDetailsService {
|
||||||
// 暂存现在出库的班组单位ID
|
// 暂存现在出库的班组单位ID
|
||||||
Integer thisOutId = record.getLeaseUnitId();
|
Integer thisOutId = record.getLeaseUnitId();
|
||||||
// 查询班组挂靠的项目部协议ID
|
// 查询班组挂靠的项目部协议ID
|
||||||
Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId());
|
Long projectUnitAgreementId = leaseApplyInfoMapper.selectProjectUnitAgreementIdByTeamAndProject(record.getLeaseUnitId(), record.getLeaseProjectId()).getProjectUnitAgreementId();
|
||||||
if (projectUnitAgreementId != null && projectUnitAgreementId > GlobalConstants.INT_0) {
|
if (projectUnitAgreementId != null && projectUnitAgreementId > GlobalConstants.INT_0) {
|
||||||
record.setProjectUnitAgreementId(projectUnitAgreementId);
|
record.setProjectUnitAgreementId(projectUnitAgreementId);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -613,7 +613,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
agreement_code AS agreementCode,
|
agreement_code AS agreementCode,
|
||||||
is_slt AS isSlt
|
is_slt AS isSlt
|
||||||
FROM clz_bm_agreement_info
|
FROM clz_bm_agreement_info
|
||||||
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
|
WHERE unit_id = #{unitId} AND project_id = #{proId} AND status = '1'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getMaterialAgreementInfoByIdBack" resultType="com.bonus.material.common.domain.vo.AgreementVo">
|
||||||
|
SELECT agreement_id AS agreementId,
|
||||||
|
agreement_code AS agreementCode,
|
||||||
|
is_slt AS isSlt
|
||||||
|
FROM bm_agreement_info
|
||||||
|
WHERE unit_id = #{unitId} AND project_id = #{proId} AND status = '1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUnitListXm" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
<select id="getUnitListXm" resultType="com.bonus.common.biz.domain.ProjectTreeNode">
|
||||||
|
|
@ -844,7 +852,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN `micro-tool`.bzgl_bz bzgl_bz ON bzgl_bz.bzmc = bu.unit_name
|
LEFT JOIN `micro-tool`.bzgl_bz bzgl_bz ON bzgl_bz.bzmc = bu.unit_name
|
||||||
LEFT JOIN `uni_org`.org_user org_user ON bzgl_bz.bzz_idcard = org_user.id_card
|
LEFT JOIN `uni_org`.org_user org_user ON bzgl_bz.bzz_idcard = org_user.id_card
|
||||||
WHERE bu.del_flag = '0'
|
WHERE bu.del_flag = '0'
|
||||||
and bzgl_bz.project_id = #{externalId}
|
<!-- and bzgl_bz.project_id = #{externalId}-->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getUseTypeClzTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
<select id="getUseTypeClzTree" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||||
|
|
|
||||||
|
|
@ -850,9 +850,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where unit_id = #{unitId}
|
where unit_id = #{unitId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectProjectUnitAgreementIdByTeamAndProject" resultType="java.lang.Long">
|
<select id="selectProjectUnitAgreementIdByTeamAndProject" resultType="com.bonus.common.biz.domain.lease.LeaseOutDetails">
|
||||||
SELECT
|
SELECT
|
||||||
baii.agreement_id AS projectUnitAgreementId
|
baii.agreement_id AS projectUnitAgreementId, bai.project_unit_id AS projectUnitId
|
||||||
FROM
|
FROM
|
||||||
bm_agreement_info bai
|
bm_agreement_info bai
|
||||||
LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}
|
LEFT JOIN bm_agreement_info baii ON baii.unit_id = bai.project_unit_id AND baii.project_id = #{projectId}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue