班组退料优化
This commit is contained in:
parent
aba67051f6
commit
89a9ebdb94
|
|
@ -2214,7 +2214,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
// 更新结算表
|
||||
List<BackApplyInfo> allList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
||||
if (CollectionUtils.isNotEmpty(allList)) {
|
||||
int res = updateSlt4Bean(backApplyInfo, allList);
|
||||
int res = updateBzSlt4Bean(backApplyInfo, allList);
|
||||
// 检查机具是否领料
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("该机具未被领料使用");
|
||||
|
|
@ -2270,46 +2270,13 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), HttpCodeEnum.FAIL.getMsg());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 关键字搜索
|
||||
*
|
||||
* @param item
|
||||
* @param keyWord
|
||||
* @return
|
||||
*/
|
||||
private boolean containsBackKeyword(BackApplyVo item, String keyWord) {
|
||||
return (item.getTypeName() != null && item.getTypeName().contains(keyWord)) ||
|
||||
(item.getTypeModelName() != null && item.getTypeModelName().contains(keyWord)) ||
|
||||
(item.getBackPerson() != null && item.getBackPerson().contains(keyWord)) ||
|
||||
(item.getBackUnitName() != null && item.getBackUnitName().contains(keyWord)) ||
|
||||
(item.getBackProName() != null && item.getBackProName().contains(keyWord)) ||
|
||||
(item.getAgreementCode() != null && item.getAgreementCode().contains(keyWord)) ||
|
||||
(item.getBackCode() != null && item.getBackCode().contains(keyWord)) ||
|
||||
(item.getRepairCode() != null && item.getRepairCode().contains(keyWord)) ||
|
||||
(item.getMaCode() != null && item.getMaCode().contains(keyWord));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新任务表及退料申请表状态
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
private int updateTaskAndBackInfo(BackApplyInfo backApplyInfo) {
|
||||
int result = backApplyInfoMapper.updateTaskStatus(backApplyInfo);
|
||||
result += backApplyInfoMapper.updateBack(backApplyInfo);
|
||||
result += backApplyInfoMapper.updateBackDetails(backApplyInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新结算表
|
||||
* 处理班组退料结算协议
|
||||
* @param record
|
||||
* @param allList
|
||||
* @return
|
||||
*/
|
||||
private int updateSlt4Bean(BackApplyInfo record, List<BackApplyInfo> allList) {
|
||||
private int updateBzSlt4Bean(BackApplyInfo record, List<BackApplyInfo> allList) {
|
||||
for (BackApplyInfo bean : allList) {
|
||||
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
||||
// 查询是否存在班组数据
|
||||
|
|
@ -2367,6 +2334,72 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 关键字搜索
|
||||
*
|
||||
* @param item
|
||||
* @param keyWord
|
||||
* @return
|
||||
*/
|
||||
private boolean containsBackKeyword(BackApplyVo item, String keyWord) {
|
||||
return (item.getTypeName() != null && item.getTypeName().contains(keyWord)) ||
|
||||
(item.getTypeModelName() != null && item.getTypeModelName().contains(keyWord)) ||
|
||||
(item.getBackPerson() != null && item.getBackPerson().contains(keyWord)) ||
|
||||
(item.getBackUnitName() != null && item.getBackUnitName().contains(keyWord)) ||
|
||||
(item.getBackProName() != null && item.getBackProName().contains(keyWord)) ||
|
||||
(item.getAgreementCode() != null && item.getAgreementCode().contains(keyWord)) ||
|
||||
(item.getBackCode() != null && item.getBackCode().contains(keyWord)) ||
|
||||
(item.getRepairCode() != null && item.getRepairCode().contains(keyWord)) ||
|
||||
(item.getMaCode() != null && item.getMaCode().contains(keyWord));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 更新任务表及退料申请表状态
|
||||
* @param backApplyInfo
|
||||
* @return
|
||||
*/
|
||||
private int updateTaskAndBackInfo(BackApplyInfo backApplyInfo) {
|
||||
int result = backApplyInfoMapper.updateTaskStatus(backApplyInfo);
|
||||
result += backApplyInfoMapper.updateBack(backApplyInfo);
|
||||
result += backApplyInfoMapper.updateBackDetails(backApplyInfo);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新结算表
|
||||
* @param record
|
||||
* @param allList
|
||||
* @return
|
||||
*/
|
||||
private int updateSlt4Bean(BackApplyInfo record, List<BackApplyInfo> allList) {
|
||||
for (BackApplyInfo bean : allList) {
|
||||
List<SltAgreementInfo> infoList = backApplyInfoMapper.getStlInfo(bean);
|
||||
if (infoList.size() > 0) {
|
||||
BigDecimal backNum = bean.getBackNum();
|
||||
for (SltAgreementInfo info : infoList) {
|
||||
BigDecimal num = info.getBackNum();
|
||||
if (backNum.compareTo(num) == 0) {
|
||||
backApplyInfoMapper.updateStlInfo(info, record);
|
||||
break;
|
||||
} else if (backNum.compareTo(num) > 0) {
|
||||
backNum = backNum.subtract(num);
|
||||
backApplyInfoMapper.updateStlInfo(info, record);
|
||||
} else {
|
||||
BigDecimal many = num.subtract(backNum);
|
||||
backApplyInfoMapper.updateStlInfoTwo(info, record, backNum);
|
||||
backApplyInfoMapper.insStlInfoTwo(info, many);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成退料申请
|
||||
* @param backApplyInfo
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
package com.bonus.material.common.controller;
|
||||
|
||||
import com.bonus.common.core.exception.ServiceException;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.material.back.domain.BackApplyInfo;
|
||||
import com.bonus.material.basic.domain.BmProject;
|
||||
import com.bonus.material.basic.domain.BmUnit;
|
||||
import com.bonus.material.basic.mapper.BmUnitMapper;
|
||||
import com.bonus.material.common.domain.dto.SelectDto;
|
||||
import com.bonus.material.common.service.SelectService;
|
||||
import com.bonus.material.materialStation.domain.ProAuthorizeInfo;
|
||||
|
|
@ -27,6 +29,9 @@ public class SelectController {
|
|||
@Resource(name = "SelectService")
|
||||
private SelectService service;
|
||||
|
||||
@Resource
|
||||
private BmUnitMapper bmUnitMapper;
|
||||
|
||||
@ApiOperation(value = "往来单位下拉选")
|
||||
@PostMapping("getUnitList")
|
||||
public AjaxResult getUnitList(@RequestBody BmUnit bmUnit) {
|
||||
|
|
@ -202,6 +207,14 @@ public class SelectController {
|
|||
@ApiOperation(value = "在用设备类型树")
|
||||
@PostMapping("/getUseTypeTree")
|
||||
public AjaxResult getUseTypeTree(@RequestBody BackApplyInfo bean) {
|
||||
BmUnit queryUnitInfo = bmUnitMapper.selectBmUnitByUnitId(bean.getUnitId());
|
||||
if (queryUnitInfo != null && queryUnitInfo.getTypeId() == null) {
|
||||
throw new ServiceException("单位类型为空");
|
||||
}
|
||||
if (queryUnitInfo != null && queryUnitInfo.getTypeId() == 1731L) {
|
||||
// 获取班组在用量
|
||||
return service.getBzUseTypeTree(bean);
|
||||
}
|
||||
return service.getUseTypeTree(bean);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -292,4 +292,11 @@ public interface SelectMapper {
|
|||
* @return
|
||||
*/
|
||||
List<TypeTreeNode> getUseTypeClzTree(BackApplyInfo backApplyInfo);
|
||||
|
||||
/**
|
||||
* 获取班组在用量
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<TypeTreeNode> getBzUseTypeTreeL4(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,4 +250,11 @@ public interface SelectService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult getAgreementInfoByIdBack(SelectDto dto);
|
||||
|
||||
/**
|
||||
* 获取班组在用量
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getBzUseTypeTree(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -366,6 +366,44 @@ public class SelectServiceImpl implements SelectService {
|
|||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取班组在用量
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getBzUseTypeTree(BackApplyInfo bean) {
|
||||
List<TypeTreeNode> groupList = new ArrayList<>();
|
||||
List<TypeTreeNode> list = new ArrayList<>();
|
||||
List<TypeTreeNode> listL4 = new ArrayList<>();
|
||||
List<TypeTreeNode> listL3 = new ArrayList<>();
|
||||
List<TypeTreeNode> listL21 = new ArrayList<>();
|
||||
try {
|
||||
// 先查第四层类型
|
||||
listL4 = mapper.getBzUseTypeTreeL4(bean);
|
||||
if (CollectionUtils.isNotEmpty(listL4)) {
|
||||
List<Long> list4ParentIds = listL4.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList());
|
||||
// 根据第四层parentId 查第三层类型
|
||||
listL3 = mapper.getUseTypeTreeL3(list4ParentIds);
|
||||
List<Long> list3ParentIds = listL3.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList());
|
||||
// 根据第三层parentId 查第1.2层类型
|
||||
listL21 = mapper.getUseTypeTreeL21(list3ParentIds);
|
||||
list.addAll(listL4);
|
||||
list.addAll(listL3);
|
||||
list.addAll(listL21);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
// 创建树形结构(数据集合作为参数)
|
||||
TypeTreeBuild treeBuild = new TypeTreeBuild(list);
|
||||
// 原查询结果转换树形结构
|
||||
groupList = treeBuild.buildTree();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
AjaxResult.error("类型树-查询失败", e);
|
||||
}
|
||||
return AjaxResult.success(groupList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult getDeviceTypeTree(SelectDto dto) {
|
||||
List<TreeNode> groupList = new ArrayList<>();
|
||||
|
|
@ -518,45 +556,9 @@ public class SelectServiceImpl implements SelectService {
|
|||
List<TypeTreeNode> listL3 = new ArrayList<>();
|
||||
List<TypeTreeNode> listL21 = new ArrayList<>();
|
||||
try {
|
||||
// 判断单位是否为班组,如果为班组的话,把材料站的领用数据也查询出来
|
||||
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> clzAgreementInfos = mapper.getAgreementInfoByIdBack(new SelectDto().setProId(bean.getProId()).setUnitId(Math.toIntExact(bean.getUnitId())));
|
||||
// 如果在材料站该单位有签署协议
|
||||
if (CollectionUtils.isNotEmpty(clzAgreementInfos)) {
|
||||
bean.setClzAgreementId(Long.valueOf(clzAgreementInfos.get(0).getAgreementId()));
|
||||
} else {
|
||||
throw new ServiceException("该班组没有在机具签署✍️的协议");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Map<Long, TypeTreeNode> mergedMap = new HashMap<>();
|
||||
// 先查第四层类型
|
||||
listL4 = mapper.getUseTypeTreeL4(bean);
|
||||
if (CollectionUtils.isNotEmpty(listL4)) {
|
||||
// 将listL4中typeId相同数据进行合并,数量相加
|
||||
for (TypeTreeNode item : listL4) {
|
||||
Long typeId = item.getTypeId();
|
||||
if (mergedMap.containsKey(typeId)) {
|
||||
// 若存在,则将数量累加
|
||||
TypeTreeNode existingItem = mergedMap.get(typeId);
|
||||
existingItem.setNum(existingItem.getNum().add(item.getNum()));
|
||||
} else {
|
||||
// 若不存在,则将当前对象放入Map
|
||||
TypeTreeNode newItem = new TypeTreeNode();
|
||||
// 复制属性
|
||||
BeanUtil.copyProperties(item, newItem);
|
||||
mergedMap.put(typeId, newItem);
|
||||
}
|
||||
}
|
||||
// 将Map中的值转换为List
|
||||
listL4 = new ArrayList<>(mergedMap.values());
|
||||
List<Long> list4ParentIds = listL4.stream().map(TypeTreeNode::getParentId).collect(Collectors.toList());
|
||||
// 根据第四层parentId 查第三层类型
|
||||
listL3 = mapper.getUseTypeTreeL3(list4ParentIds);
|
||||
|
|
|
|||
|
|
@ -614,7 +614,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
agreement_code AS agreementCode,
|
||||
is_slt AS isSlt
|
||||
FROM clz_bm_agreement_info
|
||||
WHERE unit_id = #{unitId} AND project_id = #{proId} AND status = '1'
|
||||
WHERE unit_id = #{unitId} AND project_id = #{projectId} AND status = '1'
|
||||
</select>
|
||||
|
||||
<select id="getMaterialAgreementInfoByIdBack" resultType="com.bonus.material.common.domain.vo.AgreementVo">
|
||||
|
|
@ -880,4 +880,27 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
HAVING
|
||||
num > 0
|
||||
</select>
|
||||
|
||||
<select id="getBzUseTypeTreeL4" resultType="com.bonus.common.biz.domain.TypeTreeNode">
|
||||
SELECT
|
||||
mt.type_id as typeId,
|
||||
mt1.type_name as materialName,
|
||||
mt.type_name as typeName,
|
||||
mt.parent_id as parentId,
|
||||
mt.unit_name as unitName,
|
||||
mt.unit_value as unitValue,
|
||||
mt.manage_type as manageType,
|
||||
SUM(sai.num) AS num,
|
||||
mt.LEVEL as level,
|
||||
clai.lease_style as leaseStyle
|
||||
FROM
|
||||
ma_type mt
|
||||
LEFT JOIN clz_slt_agreement_info sai ON mt.type_id = sai.type_id
|
||||
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = '0'
|
||||
LEFT JOIN clz_lease_apply_info clai ON sai.lease_id = clai.id
|
||||
WHERE
|
||||
sai.STATUS = '0' and sai.agreement_id = #{agreementId}
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue