材料站领料单号一键出库

This commit is contained in:
hayu 2025-09-26 18:01:23 +08:00
parent fc22661725
commit 85887779fd
6 changed files with 152 additions and 0 deletions

View File

@ -401,4 +401,15 @@ public class MaterialLeaseInfoController extends BaseController {
return error("系统错误,请联系管理员");
}
}
/**
* 领料单号查询领料信息
* @param info
* @return
*/
@ApiOperation(value = "领料单号查询领料信息")
@GetMapping("/getLeaseDataByCode")
public AjaxResult getLeaseDataByCode(LeaseTotalInfo info) {
return materialLeaseInfoService.getLeaseDataByCode(info);
}
}

View File

@ -174,6 +174,9 @@ public class MaterialLeaseApplyDetails extends BaseEntity {
*/
private List<MaterialLeaseMaCodeDto> maCodeList;
private String maIds;
private String maCodes;
public MaterialLeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) {
this.id = id;
this.parentId = parentId;

View File

@ -403,4 +403,18 @@ public interface MaterialLeaseInfoMapper {
* @return
*/
MaterialLeaseApplyDetails getOutDetail(MaterialLeaseApplyDetails detail);
/**
* 根据任务单号查询领料工程等信息
* @param info
* @return
*/
MaterialLeaseApplyInfo getProIdByCode(LeaseTotalInfo info);
/**
* 根据任务单号查询领料工器具等信息
* @param info
* @return
*/
List<MaterialLeaseApplyDetails> getLeaseDataByCode(LeaseTotalInfo info);
}

View File

@ -160,4 +160,11 @@ public interface MaterialLeaseInfoService {
AjaxResult getInfoByCode(BmQrcodeInfo bmQrcodeInfo);
AjaxResult updateLeaseRemark(MaterialLeaseApplyInfo leaseApplyInfo);
/**
* 领料单号查询领料信息
* @param info
* @return
*/
AjaxResult getLeaseDataByCode(LeaseTotalInfo info);
}

View File

@ -6,6 +6,7 @@ import com.bonus.common.biz.constant.MaterialConstants;
import com.bonus.common.biz.domain.BmFileInfo;
import com.bonus.common.biz.domain.TypeTreeBuild;
import com.bonus.common.biz.domain.TypeTreeNode;
import com.bonus.common.biz.domain.lease.LeaseApplyInfo;
import com.bonus.common.biz.domain.lease.LeaseOutDetails;
import com.bonus.common.biz.domain.lease.LeaseOutSign;
import com.bonus.common.biz.domain.lease.MaterialLeaseMaCodeDto;
@ -48,6 +49,7 @@ import com.bonus.material.task.domain.TmTaskAgreement;
import com.bonus.material.task.mapper.TmTaskAgreementMapper;
import com.bonus.material.task.mapper.TmTaskMapper;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.internal.util.StringHelper;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -348,6 +350,86 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
}
@Override
public AjaxResult getLeaseDataByCode(LeaseTotalInfo info) {
try {
//查询该单号是否存在,及工程信息
MaterialLeaseApplyInfo leaseApplyInfo = materialLeaseInfoMapper.getProIdByCode(info);
if (leaseApplyInfo == null) {
return AjaxResult.error("未查询到该单号信息");
}
MaterialLeaseApplyRequestVo leaseApplyRequestVo = new MaterialLeaseApplyRequestVo();
leaseApplyRequestVo.setLeaseApplyInfo(leaseApplyInfo);
//查询单号下的详情信息
List<MaterialLeaseApplyDetails> detailsList = materialLeaseInfoMapper.getLeaseDataByCode(info);
leaseApplyRequestVo.setLeaseApplyDetailsList(detailsList);
for (MaterialLeaseApplyDetails details : leaseApplyRequestVo.getLeaseApplyDetailsList()){
if (!StringHelper.isNullOrEmptyString(details.getMaIds())){
//将maIds和maCodes用逗号分割
String[] maIds = details.getMaIds().split(",");
String[] maCodes = details.getMaCodes().split(",");
List<MaterialLeaseMaCodeDto> ma = new ArrayList<>();
for (int i = 0; i < maIds.length; i++){
MaterialLeaseMaCodeDto maCodeDto = new MaterialLeaseMaCodeDto();
maCodeDto.setMaCode(maCodes[i]);
maCodeDto.setMaId(Long.valueOf(maIds[i]));
maCodeDto.setTypeId(String.valueOf(details.getTypeId()));
ma.add(maCodeDto);
}
details.setMaCodeList(ma);
//过滤编码只保留在machineList中存在的数据
if (details.getMaCodeList().size() > 0) {
List<MaterialMaCodeVo> machineList = getMachineByProIdAndTypeId(leaseApplyInfo.getProId(), details.getTypeId());
//过滤maCodeList只保留在machineList中存在的maId
List<MaterialLeaseMaCodeDto> filteredMaCodeList = details.getMaCodeList().stream()
.filter(maCodeDto -> machineList.stream()
.anyMatch(machine -> machine.getMaId().equals(maCodeDto.getMaId())))
.collect(Collectors.toList());
// 更新details中的maCodeList
details.setMaCodeList(filteredMaCodeList);
details.setOutNum(BigDecimal.valueOf(details.getMaCodeList().size()));
}
}
}
return AjaxResult.success(leaseApplyRequestVo);
} catch (Exception e) {
log.error("查询总站点领料详情数据异常", e);
return AjaxResult.error("未查询到该单号信息");
}
}
private List<MaterialMaCodeVo> getMachineByProIdAndTypeId(Long proId,Long typeId){
MaterialLeaseApplyInfo dto = new MaterialLeaseApplyInfo();
dto.setProId(proId);
dto.setTypeId(String.valueOf(typeId));
// 获取所有机具列表
List<MaterialMaCodeVo> allMachines = materialLeaseInfoMapper.getMachineById(dto);
// 如果没有机具直接返回空列表
if (CollectionUtils.isEmpty(allMachines)) {
return new ArrayList<>();
}
// 获取已使用的机具列表
List<MaterialMaCodeVo> usedMachines = materialLeaseInfoMapper.getUseMachineById(dto);
// 如果没有已使用的机具则所有机具都是未使用的
if (CollectionUtils.isEmpty(usedMachines)) {
return allMachines;
}
// 创建已使用机具ID的Set提高查找效率
Set<Long> usedMachineIds = usedMachines.stream()
.map(MaterialMaCodeVo::getMaId)
.collect(Collectors.toSet());
// 筛选出未使用的机具
List<MaterialMaCodeVo> unusedMachines = allMachines.stream()
.filter(machine -> !usedMachineIds.contains(machine.getMaId()))
.collect(Collectors.toList());
return unusedMachines;
}
/**
* 查询总站点领料详情数据
*

View File

@ -1414,4 +1414,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
parent_id = #{parentId}
AND type_id = #{typeId}
</select>
<select id="getProIdByCode" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyInfo">
SELECT
tt.task_id as taskId,
bp.pro_id as proId,
bp.pro_name as proName
FROM
tm_task tt
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
LEFT JOIN bm_agreement_info bai on bai.agreement_id=tta.agreement_id
LEFT JOIN bm_project bp on bp.pro_id=bai.project_id
WHERE
tt.`code`=#{code}
</select>
<select id="getLeaseDataByCode" resultType="com.bonus.material.clz.domain.lease.MaterialLeaseApplyDetails">
SELECT
mt.type_id as typeId,
mt.type_name as typeName,
mt2.type_name AS maTypeName,
mt.manage_type AS manageType,
SUM(IFNULL( lod.out_num, 0 )) AS outNum,
GROUP_CONCAT(mm.ma_id ORDER BY mm.ma_id) AS maIds,
GROUP_CONCAT(mm.ma_code ORDER BY mm.ma_id) AS maCodes,
mt.unit_name as unitName
FROM
lease_out_details lod
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
LEFT JOIN ma_type mt ON lod.type_id = mt.type_id
AND mt.`level` = '4' AND mt.del_flag = '0'
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
AND mt2.`level` = '3' AND mt2.del_flag = '0'
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
WHERE
lai.`code` = #{code}
GROUP BY mt.type_id,mt.manage_type
</select>
</mapper>