提交退料优化
This commit is contained in:
parent
c1d1620d74
commit
f0001119dc
|
|
@ -240,4 +240,11 @@ public interface BackApplyInfoMapper {
|
|||
* @param 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
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -555,6 +558,17 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
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查询退料申请信息
|
||||
List<BackApplyInfo> applyInfoList = backApplyInfoMapper.selectBackDetails(backApplyInfo);
|
||||
// 设置更新信息
|
||||
|
|
@ -562,7 +576,7 @@ public class BackApplyInfoServiceImpl implements IBackApplyInfoService {
|
|||
backApplyInfo.setUpdateTime(DateUtils.getNowDate());
|
||||
backApplyInfo.setTaskStatus(2);
|
||||
// 更新任务表及退料申请表状态
|
||||
int result = updateTaskAndBackInfo(backApplyInfo);
|
||||
result += updateTaskAndBackInfo(backApplyInfo);
|
||||
if (result > 0 && CollectionUtils.isNotEmpty(applyInfoList)) {
|
||||
// 获取applyInfoList的typeId并生成集合
|
||||
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 bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
||||
WHERE
|
||||
1 = 1 and mm.ma_status = '2'
|
||||
<if test="unitId != null">
|
||||
and ba.unit_id = #{unitId}
|
||||
</if>
|
||||
<if test="proId != null">
|
||||
and ba.project_id = #{proId}
|
||||
</if>
|
||||
<if test="typeId != null">
|
||||
and mm.type_id = #{typeId}
|
||||
</if>
|
||||
1 = 1 and mm.ma_status = '2' and mm.type_id = #{typeId}
|
||||
AND mm.ma_id NOT IN (SELECT ma_id from back_check_details WHERE type_id = #{typeId})
|
||||
AND ba.unit_id = #{unitId}
|
||||
AND ba.project_id = #{proId}
|
||||
</select>
|
||||
|
||||
<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}
|
||||
</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 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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue