Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
535e9ccc2f
|
|
@ -401,4 +401,15 @@ public class MaterialLeaseInfoController extends BaseController {
|
||||||
return error("系统错误,请联系管理员");
|
return error("系统错误,请联系管理员");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料单号查询领料信息
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "领料单号查询领料信息")
|
||||||
|
@GetMapping("/getLeaseDataByCode")
|
||||||
|
public AjaxResult getLeaseDataByCode(LeaseTotalInfo info) {
|
||||||
|
return materialLeaseInfoService.getLeaseDataByCode(info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,9 @@ public class MaterialLeaseApplyDetails extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private List<MaterialLeaseMaCodeDto> maCodeList;
|
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) {
|
public MaterialLeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.parentId = parentId;
|
this.parentId = parentId;
|
||||||
|
|
|
||||||
|
|
@ -403,4 +403,18 @@ public interface MaterialLeaseInfoMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
MaterialLeaseApplyDetails getOutDetail(MaterialLeaseApplyDetails detail);
|
MaterialLeaseApplyDetails getOutDetail(MaterialLeaseApplyDetails detail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务单号,查询领料工程等信息
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
MaterialLeaseApplyInfo getProIdByCode(LeaseTotalInfo info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据任务单号,查询领料工器具等信息
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<MaterialLeaseApplyDetails> getLeaseDataByCode(LeaseTotalInfo info);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,4 +160,11 @@ public interface MaterialLeaseInfoService {
|
||||||
AjaxResult getInfoByCode(BmQrcodeInfo bmQrcodeInfo);
|
AjaxResult getInfoByCode(BmQrcodeInfo bmQrcodeInfo);
|
||||||
|
|
||||||
AjaxResult updateLeaseRemark(MaterialLeaseApplyInfo leaseApplyInfo);
|
AjaxResult updateLeaseRemark(MaterialLeaseApplyInfo leaseApplyInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 领料单号查询领料信息
|
||||||
|
* @param info
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult getLeaseDataByCode(LeaseTotalInfo info);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.bonus.common.biz.constant.MaterialConstants;
|
||||||
import com.bonus.common.biz.domain.BmFileInfo;
|
import com.bonus.common.biz.domain.BmFileInfo;
|
||||||
import com.bonus.common.biz.domain.TypeTreeBuild;
|
import com.bonus.common.biz.domain.TypeTreeBuild;
|
||||||
import com.bonus.common.biz.domain.TypeTreeNode;
|
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.LeaseOutDetails;
|
||||||
import com.bonus.common.biz.domain.lease.LeaseOutSign;
|
import com.bonus.common.biz.domain.lease.LeaseOutSign;
|
||||||
import com.bonus.common.biz.domain.lease.MaterialLeaseMaCodeDto;
|
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.TmTaskAgreementMapper;
|
||||||
import com.bonus.material.task.mapper.TmTaskMapper;
|
import com.bonus.material.task.mapper.TmTaskMapper;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.hibernate.validator.internal.util.StringHelper;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询总站点领料详情数据
|
* 查询总站点领料详情数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1415,4 +1415,39 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
parent_id = #{parentId}
|
parent_id = #{parentId}
|
||||||
AND type_id = #{typeId}
|
AND type_id = #{typeId}
|
||||||
</select>
|
</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>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue