|
@@ -71,41 +71,29 @@ public class RepairSupplyService {
|
|
|
}
|
|
|
|
|
|
public List<RepairRegisterPartVo> partInfo(String repairId,Integer type) {
|
|
|
- LambdaQueryWrapper<PriceList> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(PriceList::getRepairId,repairId);
|
|
|
- wrapper.in(PriceList::getStatus,1);
|
|
|
- wrapper.eq(PriceList::getType,0);
|
|
|
- List<PriceList> list = priceListService.list(wrapper);
|
|
|
|
|
|
LambdaQueryWrapper<PartLog> wrapper2 = new LambdaQueryWrapper<>();
|
|
|
wrapper2.eq(PartLog::getRepairId,repairId);
|
|
|
- if(type == 0 ){ //出库
|
|
|
+ if(type == 0 || type == 2){ //出库
|
|
|
wrapper2.eq(PartLog::getStatus,1);
|
|
|
}
|
|
|
if(type == 1){ //回收
|
|
|
wrapper2.eq(PartLog::getStatus,2);
|
|
|
}
|
|
|
+ List<PartLog> partLogs = partLogService.list(wrapper2);
|
|
|
HashMap<Integer,PartLog> map = new HashMap<>();
|
|
|
- if(type != 2){
|
|
|
- List<PartLog> partLogs = partLogService.list(wrapper2);
|
|
|
- for (PartLog partLog : partLogs) {
|
|
|
- if(map.get(partLog.getPartId()) != null){
|
|
|
- PartLog partLog1 = map.get(partLog.getPartId());
|
|
|
- partLog1.setCount(partLog1.getCount() + partLog.getCount());
|
|
|
- }else {
|
|
|
- map.put(partLog.getPartId(),partLog);
|
|
|
- }
|
|
|
+ for (PartLog partLog : partLogs) {
|
|
|
+ if(map.get(partLog.getPartId()) != null){
|
|
|
+ PartLog partLog1 = map.get(partLog.getPartId());
|
|
|
+ partLog1.setCount(partLog1.getCount() + partLog.getCount());
|
|
|
+ }else {
|
|
|
+ map.put(partLog.getPartId(),partLog);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- HashMap<Integer,Integer> partPriceListMap = new HashMap<>();
|
|
|
- for (PriceList priceList : list) {
|
|
|
- partPriceListMap.merge(priceList.getPartId(), priceList.getCount(), Integer::sum);
|
|
|
- }
|
|
|
-
|
|
|
List<RepairRegisterPartVo> parts = new ArrayList<>();
|
|
|
|
|
|
- for (Integer partId : partPriceListMap.keySet()) {
|
|
|
+ for (Integer partId : map.keySet()) {
|
|
|
Part part = partService.getById(partId);
|
|
|
if(part == null){
|
|
|
continue;
|
|
@@ -113,18 +101,8 @@ public class RepairSupplyService {
|
|
|
RepairRegisterPartVo vo = new RepairRegisterPartVo();
|
|
|
vo.setPartId(partId);
|
|
|
vo.setPartName(part.getPartName());
|
|
|
- vo.setPartCount(partPriceListMap.get(partId));
|
|
|
+ vo.setPartCount(map.get(partId).getCount());
|
|
|
vo.setPartNum(part.getPartNum());
|
|
|
- if(type != 2){
|
|
|
- PartLog partLog = map.get(part.getPartId());
|
|
|
- if(partLog != null){
|
|
|
- Integer count = partLog.getCount();
|
|
|
- vo.setPartCount(vo.getPartCount() - count);
|
|
|
- }
|
|
|
- if(vo.getPartCount() <=0){
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
parts.add(vo);
|
|
|
}
|
|
|
return parts;
|