退料编辑
This commit is contained in:
parent
93be242b51
commit
15a2807189
|
|
@ -521,6 +521,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
||||||
}
|
}
|
||||||
List<BackApplyInfo> backApplyInfoList = receiveView(record);
|
List<BackApplyInfo> backApplyInfoList = receiveView(record);
|
||||||
if (!CollectionUtils.isEmpty(backApplyInfoList) && !CollectionUtils.isEmpty(useTypeTree)) {
|
if (!CollectionUtils.isEmpty(backApplyInfoList) && !CollectionUtils.isEmpty(useTypeTree)) {
|
||||||
|
// 将最大退料数量为0或者最大退料数量小于实际退料数量则移除
|
||||||
|
backApplyInfoList.removeIf(info -> info.getMaxBackNum() == 0);
|
||||||
for (TypeTreeNode typeTreeNode : useTypeTree) {
|
for (TypeTreeNode typeTreeNode : useTypeTree) {
|
||||||
for (BackApplyInfo applyInfo : backApplyInfoList) {
|
for (BackApplyInfo applyInfo : backApplyInfoList) {
|
||||||
if (String.valueOf(typeTreeNode.getTypeId()).equals(applyInfo.getModelId())) {
|
if (String.valueOf(typeTreeNode.getTypeId()).equals(applyInfo.getModelId())) {
|
||||||
|
|
|
||||||
|
|
@ -251,6 +251,17 @@ public class BackApplyController extends BaseController {
|
||||||
return AjaxResult.success("退料任务创建成功");
|
return AjaxResult.success("退料任务创建成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改退料申请
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "修改退料申请", businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("/updateBackApply")
|
||||||
|
public AjaxResult updateBackApply(@RequestBody BackApplyInfo bean) {
|
||||||
|
return backApplyService.updateBackApply(bean);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "退料无需审批接口,如需审批请勿使用")
|
@ApiOperation(value = "退料无需审批接口,如需审批请勿使用")
|
||||||
@Log(title = "退料申请提交--by重庆", businessType = BusinessType.INSERT)
|
@Log(title = "退料申请提交--by重庆", businessType = BusinessType.INSERT)
|
||||||
@PostMapping("/submitBackApplyByCq")
|
@PostMapping("/submitBackApplyByCq")
|
||||||
|
|
|
||||||
|
|
@ -152,4 +152,46 @@ public interface BackApplyMapper {
|
||||||
List<Integer> getTaskIdByIdAll(BackApplyDto dto);
|
List<Integer> getTaskIdByIdAll(BackApplyDto dto);
|
||||||
|
|
||||||
void updateTmTaskAll(BackApplyDto dto);
|
void updateTmTaskAll(BackApplyDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改退料申请
|
||||||
|
* @param backApplyInfo
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateBackApply(BackApplyInfo backApplyInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询明细
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BackApplyInfo> selectDetailsById(BackApplyInfo bean);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询退料明细
|
||||||
|
* @param backApplyDetail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<BackApplyInfo> selectBackDetailsById(BackApplyInfo backApplyDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改退料明细
|
||||||
|
* @param backApplyDetail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int update(BackApplyInfo backApplyDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除退料明细
|
||||||
|
* @param backApplyDetail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int delBackDetailsById(BackApplyInfo backApplyDetail);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询退料审核明细
|
||||||
|
* @param backApplyDetail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
BackApplyInfo selectCheckDetailsById(BackApplyInfo backApplyDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,4 +124,11 @@ public interface BackApplyService {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
AjaxResult auditAll(BackApplyDto dto);
|
AjaxResult auditAll(BackApplyDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改退料申请
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult updateBackApply(BackApplyInfo bean);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.bonus.sgzb.material.vo.TypeTreeBuild;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -407,10 +408,23 @@ public class BackApplyServiceImpl implements BackApplyService {
|
||||||
List<TypeTreeNode> listL4 = new ArrayList<>();
|
List<TypeTreeNode> listL4 = new ArrayList<>();
|
||||||
List<TypeTreeNode> listL3 = new ArrayList<>();
|
List<TypeTreeNode> listL3 = new ArrayList<>();
|
||||||
List<TypeTreeNode> listL21 = new ArrayList<>();
|
List<TypeTreeNode> listL21 = new ArrayList<>();
|
||||||
|
List<BackApplyInfo> infoList = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
|
/*// 根据id去back_check_details查询是否存在已经申请退料,存在则去除
|
||||||
|
if (bean.getId() != null) {
|
||||||
|
infoList = backApplyMapper.selectDetailsById(bean);
|
||||||
|
}*/
|
||||||
// 先查第四层类型
|
// 先查第四层类型
|
||||||
listL4 = backApplyMapper.getUseTypeTreeL4(bean);
|
listL4 = backApplyMapper.getUseTypeTreeL4(bean);
|
||||||
if (CollectionUtils.isNotEmpty(listL4)) {
|
if (CollectionUtils.isNotEmpty(listL4)) {
|
||||||
|
/*if (CollectionUtils.isNotEmpty(infoList)) {
|
||||||
|
// 将infoList中所有的typeId提取到一个Set中
|
||||||
|
Set<Long> infoTypeIds = infoList.stream()
|
||||||
|
.map(info -> Long.parseLong(info.getTypeId()))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
// 从listL4中移除那些typeId在infoTypeIds中的元素
|
||||||
|
listL4.removeIf(o -> infoTypeIds.contains(o.getTypeId()));
|
||||||
|
}*/
|
||||||
List<Long> list4ParentIds = listL4.stream().map(o -> o.getParentId()).collect(Collectors.toList());
|
List<Long> list4ParentIds = listL4.stream().map(o -> o.getParentId()).collect(Collectors.toList());
|
||||||
// 根据第四层parentId 查第三层类型
|
// 根据第四层parentId 查第三层类型
|
||||||
listL3 = backApplyMapper.getUseTypeTreeL3(list4ParentIds);
|
listL3 = backApplyMapper.getUseTypeTreeL3(list4ParentIds);
|
||||||
|
|
@ -540,6 +554,83 @@ public class BackApplyServiceImpl implements BackApplyService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改退料申请
|
||||||
|
* @param bean
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public AjaxResult updateBackApply(BackApplyInfo bean) {
|
||||||
|
if (bean == null || bean.getBackApplyInfo() == null || CollectionUtils.isEmpty(bean.getBackApplyDetails())) {
|
||||||
|
return AjaxResult.error("退料申请数据不能为空");
|
||||||
|
}
|
||||||
|
BackApplyInfo backApplyInfo = bean.getBackApplyInfo();
|
||||||
|
List<BackApplyInfo> backApplyDetails = bean.getBackApplyDetails();
|
||||||
|
for (BackApplyInfo backApplyDetail : backApplyDetails) {
|
||||||
|
backApplyDetail.setId(backApplyInfo.getId());
|
||||||
|
// 先去back_check_details查询该条数据退料情况
|
||||||
|
BackApplyInfo info = backApplyMapper.selectCheckDetailsById(backApplyDetail);
|
||||||
|
if (info != null && info.getNum() > backApplyDetail.getNum()) {
|
||||||
|
return AjaxResult.error(backApplyDetail.getTypeName() + "的退料数量不能小于已退料数量,情修改后重新提交");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int result = 0;
|
||||||
|
List<BackApplyInfo> infoList = new ArrayList<>();
|
||||||
|
List<BackApplyInfo> checkList = new ArrayList<>();
|
||||||
|
if (backApplyInfo.getId() != null) {
|
||||||
|
infoList = backApplyMapper.selectBackDetailsById(backApplyInfo);
|
||||||
|
checkList = backApplyMapper.selectDetailsById(bean);
|
||||||
|
if (CollectionUtils.isNotEmpty(checkList)) {
|
||||||
|
// 将checkList中所有的typeId提取到一个Set中
|
||||||
|
Set<String> infoTypeIds = checkList.stream()
|
||||||
|
.map(BackApplyInfo::getTypeId)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
// 从infoList中移除那些typeId在infoTypeIds中的元素
|
||||||
|
infoList.removeIf(o -> infoTypeIds.contains(o.getTypeId()));
|
||||||
|
}
|
||||||
|
backApplyInfo.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
result = backApplyMapper.updateBackApply(backApplyInfo);
|
||||||
|
if (result == 0) {
|
||||||
|
return AjaxResult.error("退料申请修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> typeIdList = backApplyDetails.stream().map(BackApplyInfo::getTypeId).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(infoList)) {
|
||||||
|
for (BackApplyInfo backApplyDetail : infoList) {
|
||||||
|
if (!typeIdList.contains(backApplyDetail.getTypeId())) {
|
||||||
|
// 进行删除操作
|
||||||
|
result = backApplyMapper.delBackDetailsById(backApplyDetail);
|
||||||
|
if (result == 0) {
|
||||||
|
return AjaxResult.error("退料申请删除失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (BackApplyInfo backApplyDetail : backApplyDetails) {
|
||||||
|
backApplyDetail.setId(backApplyInfo.getId());
|
||||||
|
// 先根据id和typeId查询,数据是否存在,存在则更新,不存在则新增
|
||||||
|
List<BackApplyInfo> list = backApplyMapper.selectBackDetailsById(backApplyDetail);
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
backApplyDetail.setUpdateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyDetail.setAuditNum(backApplyDetail.getNum());
|
||||||
|
result = backApplyMapper.update(backApplyDetail);
|
||||||
|
} else {
|
||||||
|
backApplyDetail.setCreateBy(SecurityUtils.getUsername());
|
||||||
|
backApplyDetail.setAuditNum(backApplyDetail.getNum());
|
||||||
|
result = backApplyMapper.upload(backApplyDetail);
|
||||||
|
}
|
||||||
|
if (result == 0) {
|
||||||
|
return AjaxResult.error("退料申请修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return AjaxResult.success("退料申请修改成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("退料申请修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int auditAllDetails(BackApplyDto dto) {
|
private int auditAllDetails(BackApplyDto dto) {
|
||||||
int re = 0;
|
int re = 0;
|
||||||
if (CollUtil.isNotEmpty(dto.getBackApplyList())) {
|
if (CollUtil.isNotEmpty(dto.getBackApplyList())) {
|
||||||
|
|
|
||||||
|
|
@ -362,6 +362,49 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
bai.id = #{id}
|
bai.id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateBackApply">
|
||||||
|
UPDATE back_apply_info
|
||||||
|
SET
|
||||||
|
<if test="backPerson != null and backPerson != ''">
|
||||||
|
back_person = #{backPerson},
|
||||||
|
</if>
|
||||||
|
<if test="phone != null and phone != ''">
|
||||||
|
phone = #{phone},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark = #{remark},
|
||||||
|
</if>
|
||||||
|
<if test="backTime != null and backTime != ''">
|
||||||
|
back_time = #{backTime},
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
update_by = #{updateBy},
|
||||||
|
</if>
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE
|
||||||
|
id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="update">
|
||||||
|
UPDATE back_apply_details
|
||||||
|
SET
|
||||||
|
<if test="num != null">
|
||||||
|
pre_num = #{num},
|
||||||
|
</if>
|
||||||
|
<if test="auditNum != null">
|
||||||
|
audit_num = #{auditNum},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null and remark != ''">
|
||||||
|
remark = #{remark},
|
||||||
|
</if>
|
||||||
|
<if test="updateBy != null and updateBy != ''">
|
||||||
|
update_by = #{updateBy},
|
||||||
|
</if>
|
||||||
|
update_time = NOW()
|
||||||
|
WHERE
|
||||||
|
parent_id = #{id} and type_id = #{typeId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="del">
|
<delete id="del">
|
||||||
DELETE
|
DELETE
|
||||||
FROM tm_task_agreement
|
FROM tm_task_agreement
|
||||||
|
|
@ -404,6 +447,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
<delete id="delBackDetailsById">
|
||||||
|
DELETE
|
||||||
|
FROM back_apply_details
|
||||||
|
WHERE parent_id = #{parentId} and type_id = #{typeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
<select id="getBackApplyList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
<select id="getBackApplyList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||||
SELECT
|
SELECT
|
||||||
bai.id,
|
bai.id,
|
||||||
|
|
@ -960,4 +1009,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
(SELECT * FROM back_apply_info bai2 WHERE bai2.id = #{id}) dd
|
(SELECT * FROM back_apply_info bai2 WHERE bai2.id = #{id}) dd
|
||||||
on bai1.task_id = dd.task_id
|
on bai1.task_id = dd.task_id
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectDetailsById" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||||
|
SELECT
|
||||||
|
parent_id as parentId,
|
||||||
|
type_id as typeId
|
||||||
|
FROM
|
||||||
|
back_check_details
|
||||||
|
where
|
||||||
|
parent_id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectBackDetailsById" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||||
|
SELECT
|
||||||
|
parent_id as parentId,
|
||||||
|
type_id as typeId
|
||||||
|
FROM
|
||||||
|
back_apply_details
|
||||||
|
where
|
||||||
|
parent_id = #{id}
|
||||||
|
<if test="typeId != null">
|
||||||
|
and type_id = #{typeId}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCheckDetailsById" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
|
||||||
|
SELECT
|
||||||
|
parent_id as parentId,
|
||||||
|
type_id as typeId,
|
||||||
|
sum(back_num) as num
|
||||||
|
FROM
|
||||||
|
back_check_details
|
||||||
|
where
|
||||||
|
parent_id = #{id} and type_id = #{typeId}
|
||||||
|
GROUP BY
|
||||||
|
parent_id,
|
||||||
|
type_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue