退料限制及保有量
This commit is contained in:
parent
d9c09de3bb
commit
5f5ba22e0d
|
|
@ -213,4 +213,18 @@ public interface BackReceiveMapper {
|
|||
int updateStatus(BackApplyInfo record);
|
||||
|
||||
int finishBackCheckDetails(BackApplyInfo record);
|
||||
|
||||
/**
|
||||
* 修改退料记录表back_check_details为完成退料
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int updateBackCheckDetails(Long id);
|
||||
|
||||
/**
|
||||
* 根据查询协议id
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
String selectAgreementId(BackApplyInfo record);
|
||||
}
|
||||
|
|
@ -274,12 +274,35 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
int postStoreNum = backReceiveMapper.getmaChineByCt(record);
|
||||
record.setPostStoreNum(postStoreNum);
|
||||
}
|
||||
// 修改退料记录表back_check_details为完成退料(1)
|
||||
if (StringUtils.isNotBlank(record.getBadId())) {
|
||||
res = updateBackCheckDetails(record);
|
||||
if (res == 0) {
|
||||
throw new RuntimeException("修改back_check_details表异常");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("typeId为空");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改退料记录表back_check_details为完成退料(1)
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
private int updateBackCheckDetails(BackApplyInfo record) {
|
||||
int res = 0;
|
||||
// 对record中的badId进行分割
|
||||
String[] split = record.getBadId().split(",");
|
||||
for (String s : split) {
|
||||
long id = Long.parseLong(s);
|
||||
res += backReceiveMapper.updateBackCheckDetails(id);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private int selectTaskStatus(int taskId) {
|
||||
int taskStatus = backReceiveMapper.selectTaskStatus(taskId);
|
||||
if (taskStatus == 40) {
|
||||
|
|
@ -525,6 +548,8 @@ public class BackReceiveServiceImpl implements BackReceiveService {
|
|||
BackApplyInfo[] arr = record.getArr();
|
||||
if (arr.length > 0) {
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
// 退料核查中
|
||||
arr[i].setStatus("0");
|
||||
res = backReceiveMapper.insertCheckDetails(arr[i]);
|
||||
String manageType = arr[i].getManageType();
|
||||
if ("0".equals(manageType)) {
|
||||
|
|
|
|||
|
|
@ -302,6 +302,9 @@
|
|||
<if test="backStatus != null">
|
||||
back_status,
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status,
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
create_by,
|
||||
</if>
|
||||
|
|
@ -342,6 +345,9 @@
|
|||
<if test="backStatus != null">
|
||||
#{backStatus},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
#{status},
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
#{createBy},
|
||||
</if>
|
||||
|
|
@ -620,6 +626,11 @@
|
|||
<update id="finishBackCheckDetails">
|
||||
update back_check_details set is_finished = 1 where parent_id = #{parentId} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
|
||||
</update>
|
||||
|
||||
<update id="updateBackCheckDetails">
|
||||
update back_check_details set status = '1' where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteCheckDetails">
|
||||
delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
|
||||
<if test="maId != null and maId != ''">
|
||||
|
|
@ -720,7 +731,8 @@
|
|||
mt.manage_type as manageType,
|
||||
mt.company_id as companyId,
|
||||
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`,
|
||||
mtk.userId as userId
|
||||
mtk.userId as userId,
|
||||
aa.badId as badId
|
||||
FROM
|
||||
back_apply_details bad
|
||||
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
|
||||
|
|
@ -729,6 +741,7 @@
|
|||
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
GROUP_CONCAT(id) as badId,
|
||||
type_id as typeId,
|
||||
SUM(IFNULL(back_num,0)) as back_num
|
||||
FROM
|
||||
|
|
@ -1163,4 +1176,13 @@
|
|||
order by bad.create_time
|
||||
</select>
|
||||
|
||||
<select id="selectAgreementId" resultType="java.lang.String">
|
||||
SELECT
|
||||
agreement_id
|
||||
FROM
|
||||
tm_task_agreement
|
||||
WHERE
|
||||
task_id = #{taskId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -157,6 +157,10 @@ public class BackApplyController extends BaseController {
|
|||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
try {
|
||||
//查看本次退料申请是否合法,判断本次退料申请数量和之前的退料申请数量之和是否超过领料出库数量
|
||||
if (!backApplyService.isBackApplyNumberCorrect(bean)) {
|
||||
return AjaxResult.error("已申请退料数量加上本次退料申请数量,超过领料出库数量,请重试!");
|
||||
}
|
||||
//生成退料编码
|
||||
String code = backApplyService.genderBackCode();
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
package com.bonus.sgzb.material.mapper;
|
||||
|
||||
import com.bonus.sgzb.material.domain.BackApplyDto;
|
||||
import com.bonus.sgzb.material.domain.BackApplyInfo;
|
||||
import com.bonus.sgzb.material.domain.ScrapApplyDetails;
|
||||
import com.bonus.sgzb.material.domain.TypeTreeNode;
|
||||
import com.bonus.sgzb.material.domain.*;
|
||||
import com.bonus.sgzb.material.domain.po.BackApplyDetailsPo;
|
||||
import com.bonus.sgzb.material.domain.po.BackApplyInfoPo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
|
@ -159,4 +156,18 @@ public interface BackApplyMapper {
|
|||
void insertBackApplyDetails(BackApplyDetailsPo backApplyDetailsPoNew);
|
||||
|
||||
void updateBackApplyDetailsByParentId(BackApplyDetailsPo backApplyDetailsPoNew);
|
||||
|
||||
/**
|
||||
* 获取退料申请统计
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<BackApplyInfo> getBackApplyDetailsTypeCount(BackApplyInfo bean);
|
||||
|
||||
/**
|
||||
* 获取领料申请统计
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
List<LeaseApplyDetails> getLeaseApplyDetailsTypeCount(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,4 +129,11 @@ public interface BackApplyService {
|
|||
* @return
|
||||
*/
|
||||
AjaxResult auditAll(BackApplyDto dto);
|
||||
|
||||
/**
|
||||
* 退料申请提交
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
boolean isBackApplyNumberCorrect(BackApplyInfo bean);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author hay
|
||||
|
|
@ -469,6 +470,63 @@ public class BackApplyServiceImpl implements BackApplyService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退料提交数据校验
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isBackApplyNumberCorrect(BackApplyInfo bean) {
|
||||
// 已建退料数据
|
||||
Map<String, Integer> oldBackMap = new HashMap<>();
|
||||
// 已领出库数据
|
||||
Map<Integer, Integer> leaseMap = new HashMap<>();
|
||||
// 本次退料数据
|
||||
Map<String, Integer> thisBackMap = new HashMap<>();
|
||||
// 查看该协议已建立退料数据
|
||||
List<BackApplyInfo> oldBackTypes = backApplyMapper.getBackApplyDetailsTypeCount(bean);
|
||||
if (CollectionUtils.isNotEmpty(oldBackTypes)) {
|
||||
oldBackMap = oldBackTypes.stream().collect(Collectors.groupingBy(BackApplyInfo::getTypeId,
|
||||
Collectors.summingInt(BackApplyInfo::getBackNum)));
|
||||
}
|
||||
// 查看领料出库数据
|
||||
List<LeaseApplyDetails> leaseTypes = backApplyMapper.getLeaseApplyDetailsTypeCount(bean);
|
||||
if (CollectionUtils.isNotEmpty(leaseTypes)) {
|
||||
leaseMap = leaseTypes.stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
LeaseApplyDetails::getTypeId,
|
||||
Collectors.mapping(
|
||||
LeaseApplyDetails::getAlNum,
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.summingDouble(Double::doubleValue),
|
||||
Double::intValue
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
// 本次退料数据
|
||||
if (CollectionUtils.isNotEmpty(bean.getBackApplyDetails())) {
|
||||
thisBackMap = bean.getBackApplyDetails().stream()
|
||||
.collect(Collectors.groupingBy(
|
||||
BackApplyInfo::getTypeId,
|
||||
Collectors.mapping(
|
||||
info -> Integer.parseInt(info.getNum()),
|
||||
Collectors.summingInt(Integer::intValue)
|
||||
)
|
||||
));
|
||||
}
|
||||
// 判断3个list是否具备合法性
|
||||
for (Integer key : leaseMap.keySet()) {
|
||||
int oldBackNum = Objects.isNull(oldBackMap.get(String.valueOf(key))) ? 0 : oldBackMap.get(String.valueOf(key));
|
||||
int thisBackNum = Objects.isNull(thisBackMap.get(String.valueOf(key))) ? 0 : thisBackMap.get(String.valueOf(key));
|
||||
int leaseNum = Objects.isNull(leaseMap.get(key)) ? 0 : leaseMap.get(key);
|
||||
if (oldBackNum + thisBackNum > leaseNum) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private int auditAllDetails(BackApplyDto dto) {
|
||||
int re = 0;
|
||||
if (CollUtil.isNotEmpty(dto.getBackApplyList())) {
|
||||
|
|
|
|||
|
|
@ -1070,4 +1070,23 @@ 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>
|
||||
|
||||
<select id="getLeaseApplyDetailsTypeCount" resultType="com.bonus.sgzb.material.domain.LeaseApplyDetails">
|
||||
select lad.type_id as typeId, sum(lad.al_num) as alNum
|
||||
from lease_apply_details lad
|
||||
LEFT join lease_apply_info lai on lai.id = lad.parennt_id
|
||||
LEFT join tm_task tt on lai.task_id = tt.task_id
|
||||
LEFT join tm_task_agreement tta on tta.task_id = tt.task_id
|
||||
where tta.agreement_id = #{agreementId} and lad.`status` = '2'
|
||||
group by lad.type_id
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -87,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
LEFT JOIN ma_type mt ON mt.type_id = bcd.type_id
|
||||
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
|
||||
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
|
||||
where (bcd.status = '1' or bcd.status is null)
|
||||
GROUP BY
|
||||
mt.type_id
|
||||
) AS subquery2 ON subquery1.type_id = subquery2.type_id
|
||||
|
|
|
|||
Loading…
Reference in New Issue