提交退料优化
This commit is contained in:
parent
c1d1620d74
commit
f0001119dc
|
|
@ -240,4 +240,11 @@ public interface BackApplyInfoMapper {
|
||||||
* @param many
|
* @param many
|
||||||
*/
|
*/
|
||||||
void insStlInfoTwo(@Param("info")SltAgreementInfo info, @Param("many")Integer many);
|
void insStlInfoTwo(@Param("info")SltAgreementInfo info, @Param("many")Integer many);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新详情
|
||||||
|
* @param applyDetail
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateBackApplyDetails(BackApplyDetails applyDetail);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -544,6 +544,9 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AjaxResult getMachineById(BackApplyInfo dto) {
|
public AjaxResult getMachineById(BackApplyInfo dto) {
|
||||||
|
if (dto == null || dto.getUnitId() == null || dto.getProId() == null || StringUtils.isBlank(dto.getTypeId())) {
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "参数不能为空");
|
||||||
|
}
|
||||||
return AjaxResult.success(backApplyInfoMapper.getMachineById(dto));
|
return AjaxResult.success(backApplyInfoMapper.getMachineById(dto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -555,6 +558,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public AjaxResult submitBackApply(BackApplyInfo backApplyInfo) {
|
public AjaxResult submitBackApply(BackApplyInfo backApplyInfo) {
|
||||||
|
int result = 0;
|
||||||
|
//先查询退料详情信息
|
||||||
|
List<BackApplyDetails> applyDetails = backApplyInfoMapper.selectBackApplyDetailsListByTaskId(backApplyInfo.getId());
|
||||||
|
if (CollectionUtils.isNotEmpty(applyDetails)) {
|
||||||
|
for (BackApplyDetails applyDetail : applyDetails) {
|
||||||
|
if (applyDetail.getPreNum() > applyDetail.getNum()) {
|
||||||
|
return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "退料数量不能大于在用数量");
|
||||||
|
}
|
||||||
|
result += backApplyInfoMapper.updateBackApplyDetails(applyDetail);
|
||||||
|
}
|
||||||
|
}
|
||||||
// 根据传入的id查询退料申请信息
|
// 根据传入的id查询退料申请信息
|
||||||
List<BackApplyInfo> applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
List<BackApplyInfo> applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
||||||
// 设置更新信息
|
// 设置更新信息
|
||||||
|
|
@ -562,7 +576,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
||||||
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
||||||
backApplyInfo.setTaskStatus(2);
|
backApplyInfo.setTaskStatus(2);
|
||||||
// 更新任务表及退料申请表状态
|
// 更新任务表及退料申请表状态
|
||||||
int result = updateTaskAndBackInfo(backApplyInfo);
|
result += updateTaskAndBackInfo(backApplyInfo);
|
||||||
if (result > 0 && CollectionUtils.isNotEmpty(applyInfoList)) {
|
if (result > 0 && CollectionUtils.isNotEmpty(applyInfoList)) {
|
||||||
// 获取applyInfoList的typeId并生成集合
|
// 获取applyInfoList的typeId并生成集合
|
||||||
List<String> typeIdList = applyInfoList.stream()
|
List<String> typeIdList = applyInfoList.stream()
|
||||||
|
|
|
||||||
|
|
@ -108,16 +108,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
||||||
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1 and mm.ma_status = '2'
|
1 = 1 and mm.ma_status = '2' and mm.type_id = #{typeId}
|
||||||
<if test="unitId != null">
|
AND mm.ma_id NOT IN (SELECT ma_id from back_check_details WHERE type_id = #{typeId})
|
||||||
and ba.unit_id = #{unitId}
|
AND ba.unit_id = #{unitId}
|
||||||
</if>
|
AND ba.project_id = #{proId}
|
||||||
<if test="proId != null">
|
|
||||||
and ba.project_id = #{proId}
|
|
||||||
</if>
|
|
||||||
<if test="typeId != null">
|
|
||||||
and mm.type_id = #{typeId}
|
|
||||||
</if>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectBackApplyInfoById" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
<select id="selectBackApplyInfoById" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
||||||
|
|
@ -555,6 +549,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
where id = #{info.id}
|
where id = #{info.id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateBackApplyDetails">
|
||||||
|
update back_apply_details set use_num = use_num - COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<insert id="insStlInfoTwo">
|
<insert id="insStlInfoTwo">
|
||||||
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time)
|
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id,lease_type,create_time)
|
||||||
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId},#{info.leaseType},now());
|
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId},#{info.leaseType},now());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue