材料站
This commit is contained in:
parent
7901d6fc1e
commit
cea9cb8390
|
|
@ -24,6 +24,8 @@ import com.bonus.material.basic.mapper.BmFileInfoMapper;
|
||||||
import com.bonus.material.clz.domain.BmTeam;
|
import com.bonus.material.clz.domain.BmTeam;
|
||||||
import com.bonus.material.clz.domain.vo.MaterialMaCodeVo;
|
import com.bonus.material.clz.domain.vo.MaterialMaCodeVo;
|
||||||
import com.bonus.material.clz.mapper.MaterialMachineMapper;
|
import com.bonus.material.clz.mapper.MaterialMachineMapper;
|
||||||
|
import com.bonus.material.common.domain.dto.SelectDto;
|
||||||
|
import com.bonus.material.common.domain.vo.AgreementVo;
|
||||||
import com.bonus.material.common.mapper.SelectMapper;
|
import com.bonus.material.common.mapper.SelectMapper;
|
||||||
import com.bonus.material.ma.domain.Type;
|
import com.bonus.material.ma.domain.Type;
|
||||||
import com.bonus.material.ma.mapper.TypeMapper;
|
import com.bonus.material.ma.mapper.TypeMapper;
|
||||||
|
|
@ -334,9 +336,97 @@ public class MaterialLeaseInfoServiceImpl implements MaterialLeaseInfoService {
|
||||||
} else {
|
} else {
|
||||||
detail.setUseNum(BigDecimal.ZERO);
|
detail.setUseNum(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
// 根据AgreementId查询机具库存
|
SelectDto selectDto = new SelectDto();
|
||||||
BigDecimal storageNum = materialLeaseInfoMapper.getStorageNum(info.getAgreementId(), detail.getTypeId());
|
selectDto.setProjectId(info.getProjectId().intValue());
|
||||||
detail.setStorageNum(storageNum);
|
List<AgreementVo> list = mapper.getAgreementInfoBy(selectDto);
|
||||||
|
// 先查第四层类型
|
||||||
|
List<TypeTreeNode> listL4 = new ArrayList<>();
|
||||||
|
List<TypeTreeNode> listL5 = new ArrayList<>();
|
||||||
|
List<TypeTreeNode> list7 = new ArrayList<>();
|
||||||
|
BackApplyInfo backApplyInfo = new BackApplyInfo();
|
||||||
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
for (AgreementVo agreementVo : list) {
|
||||||
|
backApplyInfo.setAgreementId(Long.valueOf(agreementVo.getAgreementId()));
|
||||||
|
listL4 = mapper.getUseTypeTreeL4(backApplyInfo);
|
||||||
|
if (!CollectionUtils.isEmpty(listL4)) {
|
||||||
|
listL4 = listL4.stream()
|
||||||
|
.filter(item -> StringUtils.isNotBlank(item.getMaterialName()) && StringUtils.isNotBlank(item.getTypeName()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 将listL5中typeId相同的数据进行num相加
|
||||||
|
for (TypeTreeNode node : listL4) {
|
||||||
|
// 根据node中的typeId查询listL5中相同数据,如果在listL5中存在,则将num相加,反之将node添加到list5中
|
||||||
|
TypeTreeNode node1 = listL5.stream()
|
||||||
|
.filter(item -> item.getTypeId() == (node.getTypeId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (node1 != null) {
|
||||||
|
node1.setNum(node1.getNum().add(node.getNum()));
|
||||||
|
}
|
||||||
|
if (node1 == null) {
|
||||||
|
listL5.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 根据工程id去协议表中查询协议id
|
||||||
|
MaterialLeaseApplyInfo bean = new MaterialLeaseApplyInfo();
|
||||||
|
bean.setProId(info.getProjectId());
|
||||||
|
List<BmAgreementInfo> listAgreement = materialLeaseInfoMapper.getAgreementIdByProId(bean);
|
||||||
|
if (!CollectionUtils.isEmpty(listAgreement)) {
|
||||||
|
for (BmAgreementInfo agreementInfo : listAgreement) {
|
||||||
|
bean.setAgreementId(agreementInfo.getAgreementId());
|
||||||
|
List<TypeTreeNode> list6 = materialLeaseInfoMapper.getUseTypeTree(bean);
|
||||||
|
if (!CollectionUtils.isEmpty(list6)) {
|
||||||
|
for (TypeTreeNode node : list6) {
|
||||||
|
// 根据node中的typeId查询listL7中相同数据,如果在listL7中存在,则将num相加,反之将node添加到list7中
|
||||||
|
TypeTreeNode node1 = list7.stream()
|
||||||
|
.filter(item -> item.getTypeId() == (node.getTypeId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (node1 != null) {
|
||||||
|
node1.setNum(node1.getNum().add(node.getNum()));
|
||||||
|
}
|
||||||
|
if (node1 == null) {
|
||||||
|
list7.add(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 根据协议id去clz_slt_agreement_info材料站协议表中查询在用设备,进行数据筛选去除
|
||||||
|
if (!CollectionUtils.isEmpty(listL5)) {
|
||||||
|
if (!CollectionUtils.isEmpty(list7)) {
|
||||||
|
// 将list5中typeId和list7中相同数据进行num相减,并剔除相减后为0的数据
|
||||||
|
Map<Long, BigDecimal> typeIdToNum = list7.stream()
|
||||||
|
.collect(Collectors.toMap(
|
||||||
|
TypeTreeNode::getTypeId,
|
||||||
|
TypeTreeNode::getNum,
|
||||||
|
BigDecimal::add
|
||||||
|
));
|
||||||
|
Iterator<TypeTreeNode> iterator = listL5.iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
TypeTreeNode node = iterator.next();
|
||||||
|
Long typeId = node.getTypeId();
|
||||||
|
// 获取要减去的值,默认值为BigDecimal.ZERO
|
||||||
|
BigDecimal subtractNum = typeIdToNum.getOrDefault(typeId, BigDecimal.ZERO);
|
||||||
|
// 计算新值,处理num为null的情况(若业务允许)
|
||||||
|
BigDecimal currentNum = Optional.ofNullable(node.getNum())
|
||||||
|
.orElse(BigDecimal.ZERO);
|
||||||
|
BigDecimal newNum = currentNum.subtract(subtractNum);
|
||||||
|
if (newNum.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
iterator.remove();
|
||||||
|
} else {
|
||||||
|
node.setNum(newNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 根据details中的typeId去list5中获取库存
|
||||||
|
listL5.stream()
|
||||||
|
.filter(node -> detail.getTypeId().equals(node.getTypeId()))
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(node -> detail.setStorageNum(node.getNum()));
|
||||||
|
}
|
||||||
|
}
|
||||||
// 获取编码详情
|
// 获取编码详情
|
||||||
// 移出maCodeList集合中状态不为在库的数据
|
// 移出maCodeList集合中状态不为在库的数据
|
||||||
List<MaterialLeaseMaCodeDto> maCodeVoList = materialLeaseInfoMapper.getCodeList(id, detail.getTypeId());
|
List<MaterialLeaseMaCodeDto> maCodeVoList = materialLeaseInfoMapper.getCodeList(id, detail.getTypeId());
|
||||||
|
|
|
||||||
|
|
@ -234,4 +234,6 @@ public interface SelectMapper {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getUserNameList(MaterialLeaseApplyInfo i8ProjectInfo);
|
List<String> getUserNameList(MaterialLeaseApplyInfo i8ProjectInfo);
|
||||||
|
|
||||||
|
List<BmProject> getProjectListByClz(BmProject bmProject);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,15 @@ public class SelectServiceImpl implements SelectService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getProjectList(BmProject bmProject) {
|
public AjaxResult getProjectList(BmProject bmProject) {
|
||||||
|
List<BmProject> bmProjects = new ArrayList<>();
|
||||||
if (bmProject.getIsApp() != null && bmProject.getIsApp()) {
|
if (bmProject.getIsApp() != null && bmProject.getIsApp()) {
|
||||||
if (bmProject.getTeamId() != null) {
|
if (bmProject.getTeamId() != null) {
|
||||||
bmProject.setUnitId(bmProject.getTeamId());
|
bmProjects = mapper.getProjectListByClz(bmProject);
|
||||||
|
} else {
|
||||||
|
bmProjects = mapper.getProjectListApp(bmProject);
|
||||||
}
|
}
|
||||||
List<BmProject> list = mapper.getProjectListApp(bmProject);
|
bmProjects.removeIf(Objects::isNull);
|
||||||
list.removeIf(Objects::isNull);
|
return AjaxResult.success(bmProjects);
|
||||||
return AjaxResult.success(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取登陆用户的组织ID
|
// 获取登陆用户的组织ID
|
||||||
|
|
|
||||||
|
|
@ -82,17 +82,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
tta.agreement_id,
|
tta.agreement_id,
|
||||||
bp.external_id,
|
bp.external_id,
|
||||||
bp.imp_unit,
|
bp.imp_unit,
|
||||||
bt.bzz_idcard
|
bt.bzz_idcard,
|
||||||
|
bai.unit_id,
|
||||||
|
bai.project_id
|
||||||
from
|
from
|
||||||
clz_lease_apply_info lai
|
clz_lease_apply_info lai
|
||||||
left join tm_task tt on lai.task_id = tt.task_id
|
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 tm_task_agreement tta ON tt.task_id = tta.task_id
|
||||||
|
left join bm_agreement_info bai ON tta.agreement_id = bai.agreement_id
|
||||||
left join clz_lease_apply_details lad on lai.id = lad.parent_id
|
left join clz_lease_apply_details lad on lai.id = lad.parent_id
|
||||||
left join bm_project bp on bp.pro_id = lai.project_id
|
left join bm_project bp on bp.pro_id = lai.project_id
|
||||||
left join bm_unit bt on bt.unit_id = lai.team_id
|
left join bm_unit bt on bt.unit_id = lai.team_id
|
||||||
left join sys_dept sd on sd.dept_id = bp.imp_unit
|
left join sys_dept sd on sd.dept_id = bp.imp_unit
|
||||||
left join sys_dict_data sda on tt.task_status = sda.dict_value
|
left join sys_dict_data sda on tt.task_status = sda.dict_value
|
||||||
and sda.dict_type = 'lease_task_status'
|
and sda.dict_type = 'clz_lease_apply_task_status'
|
||||||
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
|
left join ma_type mt on lad.type_id = mt.type_id and mt.del_flag = '0'
|
||||||
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
left join ma_type mt1 on mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||||
</sql>
|
</sql>
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
SELECT agreement_id AS agreementId,
|
SELECT agreement_id AS agreementId,
|
||||||
agreement_code AS agreementCode,
|
agreement_code AS agreementCode,
|
||||||
is_slt AS isSlt
|
is_slt AS isSlt
|
||||||
FROM 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 = #{projectId} AND status = '1'
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
@ -538,4 +538,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
WHERE post_id = '3de0eb390f3611efa1940242ac130004'
|
WHERE post_id = '3de0eb390f3611efa1940242ac130004'
|
||||||
AND depart_id = #{departId}
|
AND depart_id = #{departId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="getProjectListByClz" resultType="com.bonus.material.basic.domain.BmProject">
|
||||||
|
/*根据往来单位id关联协议查询工程*/
|
||||||
|
<if test="teamId != null">
|
||||||
|
SELECT DISTINCT bp.pro_id AS proId,
|
||||||
|
bp.pro_name AS proName
|
||||||
|
FROM bm_unit bu
|
||||||
|
LEFT JOIN clz_bm_agreement_info bai ON bu.unit_id = bai.unit_id AND bai.`status` = '1'
|
||||||
|
LEFT JOIN bm_project bp ON bai.project_id = bp.pro_id AND bp.del_flag = '0'
|
||||||
|
WHERE bu.unit_id = #{teamId} AND bu.del_flag = '0'
|
||||||
|
</if>
|
||||||
|
<if test="teamId == null">
|
||||||
|
SELECT pro_id AS proId,
|
||||||
|
pro_name AS proName
|
||||||
|
FROM bm_project
|
||||||
|
WHERE del_flag = '0'
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue