退料接收单据完结

This commit is contained in:
mashuai 2025-07-11 16:27:40 +08:00
parent b7149164ff
commit 9483d7dd95
10 changed files with 210 additions and 13 deletions

View File

@ -232,6 +232,21 @@ public class BackReceiveController extends BaseController {
}
}
/**
* 退料接收-单据完结
* @param list
* @return
*/
@PreventRepeatSubmit
@PostMapping("/endBackOver")
public AjaxResult endBackOver(@RequestBody List<BackApplyInfo> list) {
try {
return backReceiveService.endBackOver(list);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Log(title = "退料接收-编号查询", businessType = BusinessType.INSERT)
@PostMapping("codeQuery")
public AjaxResult codeQuery(@RequestBody BackApplyInfo record) {

View File

@ -233,4 +233,25 @@ public interface BackReceiveMapper {
* @return
*/
BackApplyInfo getProAndTypeNum(BackApplyInfo backApplyInfo);
/**
* 获取退料列表
* @param backApplyInfo
* @return
*/
List<BackApplyInfo> getList(BackApplyInfo backApplyInfo);
/**
* 获取退料状态
* @param id
* @return
*/
List<BackApplyInfo> getBackStatusList(Integer id);
/**
* 获取退料信息
* @param id
* @return
*/
BackApplyInfo getBackApplyInfo(Integer id);
}

View File

@ -2,6 +2,7 @@ package com.bonus.sgzb.app.service;
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
import com.bonus.sgzb.app.domain.TmTask;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import java.util.List;
@ -102,4 +103,10 @@ public interface BackReceiveService {
List<TmTask> getScrapBackMachine(TmTask task);
/**
* 退料接收-单据完结
* @param list
* @return
*/
AjaxResult endBackOver(List<BackApplyInfo> list);
}

View File

@ -13,6 +13,7 @@ import com.bonus.sgzb.common.core.enums.TaskStatusEnum;
import com.bonus.sgzb.common.core.enums.TaskTypeEnum;
import com.bonus.sgzb.common.core.utils.DateUtils;
import com.bonus.sgzb.common.core.utils.StringHelper;
import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.common.security.utils.SecurityUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
@ -80,6 +81,28 @@ public class BackReceiveServiceImpl implements BackReceiveService {
}
}
}
List<BackApplyInfo> resultList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(backApplyInfos)) {
for (BackApplyInfo backApplyInfo : backApplyInfos) {
List<BackApplyInfo> allApplyInfos = backReceiveMapper.receiveView(backApplyInfo);
if (CollectionUtils.isNotEmpty(allApplyInfos)) {
for (BackApplyInfo applyInfo : allApplyInfos) {
// 根据角色决定是否添加到结果集
if (isUserInvolved(applyInfo, userId)) {
resultList.add(applyInfo);
}
}
}
if (CollectionUtils.isNotEmpty(resultList)) {
// 判断resultList中的状态是否全部为1已完成
boolean allCompleted = resultList.stream().allMatch(applyInfo -> "1".equals(applyInfo.getBackStatus()));
if (allCompleted) {
backApplyInfo.setTaskStatus("40");
backApplyInfo.setTaskName("退料完成");
}
}
}
}
}
return backApplyInfos;
}
@ -502,6 +525,51 @@ public class BackReceiveServiceImpl implements BackReceiveService {
return backReceiveMapper.getScrapBackMachine(task);
}
/**
* 退料接收-单据完结
* @param list
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult endBackOver(List<BackApplyInfo> list) {
if (CollectionUtils.isEmpty(list)) {
return AjaxResult.warn("请选择需要进行单据完结的数据!");
}
for (BackApplyInfo backApplyInfo : list) {
// 先根据id以及modelId查询此单子有没有进行退料如果退料则需先点击完成退料或者退料撤回操作
List<BackApplyInfo> allList = backReceiveMapper.getList(backApplyInfo);
if (CollectionUtils.isNotEmpty(allList)) {
return AjaxResult.warn("所勾选数据:" + allList.get(0).getTypeName() + "中有退料数据未处理,请先进行完成退料或撤回处理!");
}
}
for (BackApplyInfo backApplyInfo : list) {
backApplyInfo.setParentId(backApplyInfo.getId());
backApplyInfo.setTypeId(backApplyInfo.getModelId());
// 修改back_apply_details表的状态为1
int result = backReceiveMapper.updateStatus(backApplyInfo);
if (result == 0) {
return AjaxResult.warn("退料接收-单据完结异常!");
}
}
// 根据id查询back_apply_details表的状态如果全部都为1则退料完成
Integer id = list.get(0).getId();
List<BackApplyInfo> list1 = backReceiveMapper.getBackStatusList(id);
BackApplyInfo backApplyInfo = backReceiveMapper.getBackApplyInfo(id);
if (CollectionUtils.isNotEmpty(list1)) {
if (list1.size() == list1.stream().filter(item -> "1".equals(item.getBackStatus())).count()) {
// 修改任务表状态为完成
if (backApplyInfo != null) {
int res = updateTaskStatus(backApplyInfo.getTaskId(), 40);
if (res == 0) {
return AjaxResult.warn("退料接收-单据完结异常!");
}
}
}
}
return AjaxResult.success("退料接收-单据完结成功!");
}
private int insertRad(int taskId, List<BackApplyInfo> wxList) {
int result = 0;
if (wxList != null) {

View File

@ -1298,5 +1298,45 @@
AND subquery1.agreement_id = subquery2.agreement_id
</select>
<select id="getList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
SELECT
bai.id,
bai.task_id AS taskId,
bcd.type_id AS typeId,
SUM(bcd.back_num) AS backNum,
bcd.parent_id AS parentId,
bcd.create_by AS createBy,
bcd.ma_id AS maId,
mt2.type_name AS typeName,
mt.type_name AS typeCode
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE
bcd.parent_id = #{id} and bcd.type_id = #{modelId} and (bcd.is_finished is null or bcd.is_finished != 1)
GROUP By bcd.type_id,bcd.ma_id
</select>
<select id="getBackStatusList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
SELECT id AS id,
parent_id AS parentId,
type_id AS typeId,
back_status AS backStatus
FROM back_apply_details
where parent_id = #{id}
</select>
<select id="getBackApplyInfo" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
select id AS id,
code AS code,
task_id AS taskId,
back_person AS backPerson,
phone AS phone
from back_apply_info
where id = #{id}
</select>
</mapper>

View File

@ -178,4 +178,11 @@ public interface BackApplyMapper {
List<TypeTreeNode> getUseTypeTreeL3(List<Long> list4ParentIds);
List<TypeTreeNode> getUseTypeTreeL21(List<Long> list3ParentIds);
/**
* 查询退料申请列表
* @param backApplyInfo
* @return
*/
BackApplyInfo getList(BackApplyInfo backApplyInfo);
}

View File

@ -161,6 +161,17 @@ public class BackApplyServiceImpl implements BackApplyService {
bean.setCompanyId(companyId.toString());
}
List<BackApplyInfo> view = backApplyMapper.getView(bean);
if (CollUtil.isNotEmpty(view)) {
for (BackApplyInfo backApplyInfo : view) {
// 根据id以及typeId去back_check_details中查询退料数量
BackApplyInfo info = backApplyMapper.getList(backApplyInfo);
if (info == null) {
backApplyInfo.setNum("0");
} else {
backApplyInfo.setNum(info.getNum());
}
}
}
// 定义需要匹配的角色集合
List<String> allowedRoles = Arrays.asList("admin", "em01", "em02", "jjbz", "dm01", "dm07");
// 获取当前用户的角色集合

View File

@ -704,6 +704,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="getView" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
SELECT
bai.id AS id,
bai.back_person AS backPerson,
bai.phone AS phone,
bai.back_time as backTime,
@ -1081,13 +1082,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="getBackApplyDetailsTypeCount" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
select bad.type_id as typeId, sum(bad.audit_num) as backNum
from back_apply_details bad
LEFT join back_apply_info bai on bai.id = bad.parent_id
LEFT join tm_task tt on bai.task_id = tt.task_id
LEFT join tm_task_agreement tta on tta.task_id = tt.task_id
where tta.agreement_id = #{agreementId}
group by bad.type_id
SELECT
bcd.type_id AS typeId,
sum( bcd.back_num ) AS backNum
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
LEFT JOIN tm_task tt ON bai.task_id = tt.task_id
LEFT JOIN tm_task_agreement tta ON tta.task_id = tt.task_id
WHERE
tta.agreement_id = #{agreementId}
GROUP BY
bcd.type_id
</select>
<select id="getLeaseApplyDetailsTypeCount" resultType="com.bonus.sgzb.material.domain.LeaseApplyDetails">
@ -1182,4 +1188,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item}
</foreach>
</select>
<select id="getList" resultType="com.bonus.sgzb.material.domain.BackApplyInfo">
SELECT
bai.id,
bai.task_id AS taskId,
bcd.type_id AS typeId,
SUM(bcd.back_num) AS num,
bcd.parent_id AS parentId,
bcd.create_by AS createBy,
mt2.type_name AS typeName,
mt.type_name AS typeCode
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai ON bai.id = bcd.parent_id
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
WHERE
bcd.is_finished = 1
and bcd.parent_id = #{id}
and bcd.type_id = #{typeId}
GROUP By bcd.type_id
</select>
</mapper>

View File

@ -246,10 +246,10 @@
style="color: #67c23a"
v-if="scope.row.taskStatus == '38'"
>
已提交
退料已提交
</el-button>
<el-button type="text" v-if="scope.row.taskStatus == '39'">
退料核查
退料核查
</el-button>
<el-button
type="text"

View File

@ -987,13 +987,13 @@ export default {
this.selChangeList.map((e) => {
badId += e.badId + ','
})
// if (true) return
const { data: res } = await endBackBeforeQueryApi({
typeId,
id: this.queryParams.id,
})
if (res == 0) {
this.$message.error(
'当前存在未退料机具,请处理之后再点击完成退料!',
@ -1024,7 +1024,7 @@ export default {
return
}
//
this.$confirm('是否确定要单据完结?', '提示', {
this.$confirm('是否确定要单据完结?一经确定,不可撤回!', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@ -1035,7 +1035,7 @@ export default {
modelId: item.modelId,
}
})
try {
const res = await endBackOver(params)
this.getList()