This commit is contained in:
parent
8ebfcc580f
commit
b507147335
|
|
@ -3,6 +3,7 @@ package com.bonus.sgzb.app.mapper;
|
||||||
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
import com.bonus.sgzb.app.domain.LeaseApplyDetails;
|
||||||
import com.bonus.sgzb.app.domain.LeaseOutDetailRecord;
|
import com.bonus.sgzb.app.domain.LeaseOutDetailRecord;
|
||||||
import com.bonus.sgzb.app.domain.TmTask;
|
import com.bonus.sgzb.app.domain.TmTask;
|
||||||
|
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
|
@ -54,4 +55,6 @@ public interface LeaseApplyDetailsMapper {
|
||||||
TmTask getOrderHead(String parentId);
|
TmTask getOrderHead(String parentId);
|
||||||
|
|
||||||
List<LeaseOutDetailRecord> getOrderBody(@Param("parentId") String parentId,@Param("typeId") String typeId);
|
List<LeaseOutDetailRecord> getOrderBody(@Param("parentId") String parentId,@Param("typeId") String typeId);
|
||||||
|
|
||||||
|
List<com.bonus.sgzb.material.domain.LeaseApplyDetails> getLeaseApplyDetailsTypeCount(BackApplyInfo bean);
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +40,7 @@ public interface BackApplyMapper {
|
||||||
*/
|
*/
|
||||||
String selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
|
String selectTaskNumByMonth(@Param("date") Date date, @Param("taskType") Integer taskType);
|
||||||
|
|
||||||
List<BackApplyInfo> getBackApplyDetailsTypeCount();
|
List<BackApplyInfo> getBackApplyDetailsTypeCount(BackApplyInfo bean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加
|
* 增加
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.bonus.sgzb.material.service.impl;
|
package com.bonus.sgzb.material.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.bonus.sgzb.app.mapper.LeaseApplyDetailsMapper;
|
||||||
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
import com.bonus.sgzb.base.api.domain.BackApplyInfo;
|
||||||
import com.bonus.sgzb.base.api.domain.MachinePart;
|
import com.bonus.sgzb.base.api.domain.MachinePart;
|
||||||
import com.bonus.sgzb.common.core.utils.DateUtils;
|
import com.bonus.sgzb.common.core.utils.DateUtils;
|
||||||
|
|
@ -19,7 +20,9 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hay
|
* @author hay
|
||||||
|
|
@ -31,6 +34,9 @@ public class BackApplyServiceImpl implements BackApplyService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BackApplyMapper backApplyMapper;
|
private BackApplyMapper backApplyMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LeaseApplyDetailsMapper leaseApplyDetailsMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TaskMapper tmTaskMapper;
|
private TaskMapper tmTaskMapper;
|
||||||
|
|
||||||
|
|
@ -89,15 +95,23 @@ public class BackApplyServiceImpl implements BackApplyService {
|
||||||
public boolean isBackApplyNumberCorrect(BackApplyInfo bean) {
|
public boolean isBackApplyNumberCorrect(BackApplyInfo bean) {
|
||||||
boolean isCorrect = true; //默认合法
|
boolean isCorrect = true; //默认合法
|
||||||
// 查看出库数据
|
// 查看出库数据
|
||||||
List<BackApplyInfo> backTypeList = backApplyMapper.getBackApplyDetailsTypeCount();
|
List<BackApplyInfo> backTypes = backApplyMapper.getBackApplyDetailsTypeCount(bean);
|
||||||
|
|
||||||
// 查看退料已审核数据
|
// 查看退料已审核数据
|
||||||
|
List<LeaseApplyDetails> leaseTypes = leaseApplyDetailsMapper.getLeaseApplyDetailsTypeCount(bean);
|
||||||
|
|
||||||
// 比较本次退料数据,是否大于前两者的差额,大于就报错
|
// 比较本次退料数据,是否大于前两者的差额,大于就报错
|
||||||
List<BackApplyInfo> backApplyDetails = bean.getBackApplyDetails();
|
List<BackApplyInfo> thisBackTypes = bean.getBackApplyDetails();
|
||||||
|
// 判断3个list是否具备合法性
|
||||||
|
Map<String, Integer> oldBackMap = backTypes.stream().collect(Collectors.groupingBy(BackApplyInfo::getTypeId,
|
||||||
|
Collectors.summingInt(BackApplyInfo::getBackNum)));
|
||||||
|
Map<Integer, Integer> leaseMap = leaseTypes.stream().collect(Collectors.groupingBy(LeaseApplyDetails::getTypeId,
|
||||||
|
Collectors.summingInt(LeaseApplyDetails::getAlNum)));
|
||||||
|
Map<String, Integer> thisBackMap = thisBackTypes.stream().collect(Collectors.groupingBy(BackApplyInfo::getTypeId,
|
||||||
|
Collectors.summingInt(BackApplyInfo::getNum)));
|
||||||
|
for (Integer key : leaseMap.keySet()) {
|
||||||
|
if (oldBackMap.get(String.valueOf(key)) + thisBackMap.get(String.valueOf(key)) > leaseMap.get(key)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return isCorrect;
|
return isCorrect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -585,4 +585,14 @@
|
||||||
</if>
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<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}
|
||||||
|
group by lad.type_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue