TaskDetailServiceImpl.java
4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package com.huaheng.pc.task.taskDetail.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.pc.config.cycleCountPreference.domain.CycleCountPreference;
import com.huaheng.pc.config.cycleCountPreference.service.CycleCountPreferenceService;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.task.taskDetail.mapper.TaskDetailMapper;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import org.springframework.transaction.annotation.Transactional;
@Service
public class TaskDetailServiceImpl extends ServiceImpl<TaskDetailMapper, TaskDetail> implements TaskDetailService{
@Resource
private CycleCountDetailService cycleCountDetailService;
@Resource
private CycleCountPreferenceService cycleCountPreferenceService;
/**
* 盘点任务首选项
* @param taskDetailList
* @return
*/
@Transactional
@Override
public List<TaskDetail> preferenceRealize(List<TaskDetail> taskDetailList) {
/*查出盘点明细,找出盘点首选项,根据首选项显示字段*/
List<TaskDetail> taskDetails = new ArrayList<>();
for (TaskDetail item:taskDetailList){
//盘点明细
CycleCountDetail cycleCountDetailtemp = new CycleCountDetail();
cycleCountDetailtemp.setCycleCountHeadCode(item.getBillCode());
cycleCountDetailtemp.setId(item.getBillDetailId());
LambdaQueryWrapper<CycleCountDetail> detailLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountDetailtemp);
CycleCountDetail cycleCountDetail = cycleCountDetailService.getOne(detailLambdaQueryWrapper);
if(cycleCountDetail == null){
throw new SecurityException("没有找到子任务对应的盘点明细!");
}
//找盘点首选项
CycleCountPreference cycleCountPreferenceTemp = new CycleCountPreference();
cycleCountPreferenceTemp.setCode(cycleCountDetail.getPreferenceCode());
cycleCountPreferenceTemp.setWarehouseCode(cycleCountDetail.getWarehouseCode());
LambdaQueryWrapper<CycleCountPreference> preferenceLambdaQueryWrapper = Wrappers.lambdaQuery(cycleCountPreferenceTemp);
CycleCountPreference cycleCountPreference = cycleCountPreferenceService.getOne(preferenceLambdaQueryWrapper);
if(cycleCountPreference == null){
throw new SecurityException("没有找到盘点首选项!");
}
//根据首选项判断数据
if(cycleCountPreference.getPromptLocation() == false){
//库位
item.setFromLocation("");
item.setToLocation("");
}
if(cycleCountPreference.getPromptLpn() == false){
//容器
item.setContainerCode("");
}
if(cycleCountPreference.getPromptItem() == false){
//物料
item.setMaterialCode("");
item.setMaterialName("");
item.setMaterialUnit("");
item.setMaterialSpec("");
}
if(cycleCountPreference.getPromptQuantity() == false){
//系统数量
item.setQty(null);
}
taskDetails.add(item);
}
return taskDetails;
}
/**
* 根据任务头表id查询任务明细
* @param id
* @return
*/
@Override
public List<TaskDetail> findByTaskId(Integer id) {
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(TaskDetail::getTaskId, id);
return this.list(queryWrapper);
}
}